Skip to content

Commit 77371b4

Browse files
fix(slack): show setup completion as a toast
1 parent 26b2ac0 commit 77371b4

3 files changed

Lines changed: 21 additions & 9 deletions

File tree

‎apps/sim/app/o/[organizationId]/settings/components/organization-search-slack.test.tsx‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/** @vitest-environment jsdom */
22
import { act, type ReactNode } from 'react'
3+
import { ToastProvider } from '@sim/emcn'
34
import { createRoot, type Root } from 'react-dom/client'
45
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
56
import type { SlackSearchInstallationView } from '@/lib/api/contracts/knowledge/slack'
@@ -93,7 +94,13 @@ async function render(installed = false) {
9394
},
9495
})
9596
}
96-
await act(async () => root.render(<OrganizationSearchSlack />))
97+
await act(async () =>
98+
root.render(
99+
<ToastProvider>
100+
<OrganizationSearchSlack />
101+
</ToastProvider>
102+
)
103+
)
97104
}
98105
function button(label: string) {
99106
const scope = document.querySelector('[role="dialog"]') ?? document

‎apps/sim/app/o/[organizationId]/settings/components/organization-search-slack.tsx‎

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use client'
22

3-
import { useState } from 'react'
4-
import { Chip, ChipConfirmModal, ChipLink, ChipModalError, ChipTag } from '@sim/emcn'
3+
import { useEffect, useRef, useState } from 'react'
4+
import { Chip, ChipConfirmModal, ChipLink, ChipModalError, ChipTag, useToast } from '@sim/emcn'
55
import { useQueryState } from 'nuqs'
66
import { SlackIcon } from '@/components/icons'
77
import { SlackSearchSetupWizard } from '@/components/integrations/slack-search-setup-wizard'
@@ -26,6 +26,8 @@ import {
2626

2727
/** Organization-owned Search bots are installed through the dedicated OAuth wizard. */
2828
export function OrganizationSearchSlack() {
29+
const setupToastShown = useRef(false)
30+
const { toast } = useToast()
2931
const { organization, viewer } = useOrganizationContext()
3032
const installations = useSlackSearchInstallations(viewer.isAdmin ? organization.id : undefined)
3133
const configure = useConfigureSlackSearch()
@@ -41,6 +43,14 @@ export function OrganizationSearchSlack() {
4143
initialName?: string
4244
} | null>(null)
4345
const [removeTarget, setRemoveTarget] = useState<{ id: string; name: string } | null>(null)
46+
47+
useEffect(() => {
48+
if (!viewer.isAdmin || setupResult !== 'complete' || setupToastShown.current) return
49+
setupToastShown.current = true
50+
toast.success('Slack connected')
51+
void setSetupResult(null)
52+
}, [viewer.isAdmin, setupResult, setSetupResult, toast])
53+
4454
if (!viewer.isAdmin) return null
4555
const busy = configure.isPending || remove.isPending
4656
const bots = installations.data?.bots ?? []
@@ -54,12 +64,6 @@ export function OrganizationSearchSlack() {
5464
return (
5565
<SettingsPanel>
5666
<div className='flex max-w-xl flex-col gap-4'>
57-
{setupResult === 'complete' && (
58-
<div role='status' className='flex items-center justify-between gap-2'>
59-
<p className='text-[var(--text-body)] text-sm'>Slack is connected and ready to use.</p>
60-
<Chip onClick={() => void setSetupResult(null)}>Dismiss</Chip>
61-
</div>
62-
)}
6367
<SettingsSection label='Connection'>
6468
{installations.error ? (
6569
<SettingsQueryErrorState

‎apps/sim/lib/credential-groups/slack-managed-users.test.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ const shared = vi.hoisted(() => ({
3434
flag: vi.fn(),
3535
}))
3636
vi.mock('@/lib/core/config/env', () => ({ env: shared.env }))
37+
vi.mock('@/lib/core/config/env-flags', () => ({ isHosted: true }))
3738
vi.mock('@/lib/core/config/feature-flags', () => ({ isFeatureEnabled: shared.flag }))
3839

3940
vi.mock('@/lib/core/config/redis', () => ({ getRedisClient: () => redis }))

0 commit comments

Comments
 (0)