Skip to content

Commit d428711

Browse files
author
Vikhyath Mondreti
committed
fix(search): keep admin setup out of member integrations
1 parent 27b6d5b commit d428711

2 files changed

Lines changed: 24 additions & 21 deletions

File tree

‎apps/sim/app/o/[organizationId]/integrations/live-member-integrations.test.tsx‎

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -122,10 +122,12 @@ describe('live member connection states', () => {
122122
it.each([
123123
['disabled', { credentialGroup: { ...group, status: 'disabled' } }],
124124
['unconfigured', { credentialGroup: null }],
125-
])('does not offer a connection when %s', async (_name, overrides) => {
125+
])('disables connection when %s', async (_name, overrides) => {
126126
mocks.inventory.mockReturnValue({ data: inventory(overrides) })
127127
await render()
128-
expect(button('Connect')).toBeUndefined()
128+
expect(button('Connect')?.disabled).toBe(true)
129+
await act(async () => button('Connect')!.click())
130+
expect(mocks.connect).not.toHaveBeenCalled()
129131
})
130132
it('shows the current account and reconnect action without enabling a disabled integration', async () => {
131133
mocks.inventory.mockReturnValue({
@@ -192,13 +194,21 @@ describe('live member connection states', () => {
192194
await render()
193195
expect(container.textContent).toBe('')
194196
})
195-
it('sends admins to Credential Groups when member sign-in is not configured', async () => {
196-
mocks.inventory.mockReturnValue({ data: inventory({ credentialGroup: null, canManage: true }) })
197-
await render()
198-
expect(container.querySelector('a')?.getAttribute('href')).toBe(
199-
'/o/org/settings/connected-accounts'
200-
)
201-
})
197+
it.each([false, true])(
198+
'keeps Slack app setup out of member Integrations, admin=%s',
199+
async (canManage) => {
200+
mocks.policies.mockReturnValue({ data: [{ connectorType: 'slack', approved: true }] })
201+
mocks.inventory.mockReturnValue({ data: inventory({ canManage }) })
202+
await render()
203+
expect(container.textContent).toContain('Slack')
204+
expect(container.textContent).toContain('Not configured')
205+
expect(container.textContent).not.toContain('Finish setup')
206+
expect(container.querySelector('a')).toBeNull()
207+
expect(button('Connect')?.disabled).toBe(true)
208+
await act(async () => button('Connect')!.click())
209+
expect(mocks.connect).not.toHaveBeenCalled()
210+
}
211+
)
202212
it('explains service-account scope without hiding member connection controls', async () => {
203213
mocks.policies.mockReturnValue({
204214
data: [

‎apps/sim/app/o/[organizationId]/integrations/live-member-integrations.tsx‎

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

3-
import { Chip, ChipLink, toast } from '@sim/emcn'
3+
import { Chip, toast } from '@sim/emcn'
44
import type { OrganizationAccountConnectionResponse } from '@/lib/api/contracts/organization-accounts'
5-
import { organizationRoutes } from '@/lib/navigation/paths'
65
import { connectorDisplayName, SEARCH_SOURCE_TYPES } from '@/lib/sim-search/connectors'
76
import { LIVE_SEARCH_SCOPE_FIELDS } from '@/lib/sim-search/live/policy-schema'
87
import { DisconnectAccountMenu } from '@/app/o/[organizationId]/integrations/disconnect-account-menu'
@@ -149,7 +148,7 @@ export function LiveMemberIntegrations({ organizationId, search }: LiveMemberInt
149148
: group && group.status !== 'active'
150149
? 'Connections are paused by your organization'
151150
: !ready
152-
? 'An admin needs to finish connection setup'
151+
? 'Not configured'
153152
: accounts.length
154153
? scope
155154
: undefined
@@ -191,10 +190,10 @@ export function LiveMemberIntegrations({ organizationId, search }: LiveMemberInt
191190
Reconnect{accounts.length > 1 ? ` ${account.displayName}` : ''}
192191
</Chip>
193192
))}
194-
{ready ? (
193+
{approved && (
195194
<Chip
196195
variant={accounts.length ? undefined : 'primary'}
197-
disabled={pending}
196+
disabled={pending || !ready}
198197
onClick={() =>
199198
connect.mutate(
200199
{
@@ -216,13 +215,7 @@ export function LiveMemberIntegrations({ organizationId, search }: LiveMemberInt
216215
? 'Add account'
217216
: 'Connect'}
218217
</Chip>
219-
) : data.canManage && approved ? (
220-
<ChipLink
221-
href={organizationRoutes(organizationId).settingsSection('connected-accounts')}
222-
>
223-
Finish setup
224-
</ChipLink>
225-
) : null}
218+
)}
226219
</div>
227220
}
228221
/>

0 commit comments

Comments
 (0)