Skip to content

Commit ca659d2

Browse files
committed
fix(search): align account actions and simplify tool rows
1 parent a2b3d4d commit ca659d2

7 files changed

Lines changed: 90 additions & 68 deletions

File tree

-22.1 KB
Loading
15 KB
Loading

‎apps/sim/app/o/[organizationId]/integrations/account-connection-actions.tsx‎

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

33
import { useState } from 'react'
4-
import { Chip, ChipConfirmModal, ChipModalError } from '@sim/emcn'
4+
import { ChipConfirmModal, ChipModalError } from '@sim/emcn'
5+
import { type SettingsAction, SettingsActionChips } from '@/components/settings/settings-header'
56
import type { ViewerSearchSourceAccount } from '@/lib/api/contracts/knowledge/connectors'
67
import { useDisconnectPersonalOrganizationAccount } from '@/hooks/queries/organization-accounts'
78

@@ -32,48 +33,57 @@ export function AccountConnectionActions({
3233
const disconnect = useDisconnectPersonalOrganizationAccount(organizationId)
3334
const [confirming, setConfirming] = useState(false)
3435
const pending = connectionPending || disconnect.isPending
36+
const actions: SettingsAction[] = []
37+
if (account) {
38+
actions.push({
39+
id: 'reconnect',
40+
text: 'Reconnect',
41+
disabled: pending || !canReconnect,
42+
onSelect: onReconnect,
43+
})
44+
}
45+
if (onConnect) {
46+
actions.push({
47+
id: 'connect',
48+
text: connectLabel,
49+
disabled: pending || !canConnect,
50+
onSelect: onConnect,
51+
})
52+
}
53+
if (account) {
54+
actions.push({
55+
id: 'delete',
56+
text: 'Disconnect',
57+
textTone: 'error',
58+
disabled: pending,
59+
onSelect: () => {
60+
disconnect.reset()
61+
setConfirming(true)
62+
},
63+
})
64+
}
3565
return (
3666
<>
67+
<SettingsActionChips actions={actions} />
3768
{account && (
38-
<Chip disabled={pending || !canReconnect} onClick={onReconnect}>
39-
Reconnect
40-
</Chip>
41-
)}
42-
{onConnect && (
43-
<Chip disabled={pending || !canConnect} onClick={onConnect}>
44-
{connectLabel}
45-
</Chip>
46-
)}
47-
{account && (
48-
<>
49-
<Chip
50-
disabled={pending}
51-
onClick={() => {
52-
disconnect.reset()
53-
setConfirming(true)
54-
}}
55-
>
56-
Disconnect
57-
</Chip>
58-
<ChipConfirmModal
59-
open={confirming}
60-
onOpenChange={(open) => {
61-
if (!disconnect.isPending) setConfirming(open)
62-
}}
63-
title={`Disconnect ${integrationName}`}
64-
text={`Disconnect ${account.displayName} from all ${integrationName} connections in this organization. Workflows using this account will also lose access. You can reconnect later.`}
65-
confirm={{
66-
label: 'Disconnect',
67-
pendingLabel: 'Disconnecting',
68-
pending: disconnect.isPending,
69-
disabled: disconnect.isPending,
70-
onClick: () =>
71-
disconnect.mutate(account.credentialId, { onSuccess: () => setConfirming(false) }),
72-
}}
73-
>
74-
<ChipModalError>{disconnect.error?.message}</ChipModalError>
75-
</ChipConfirmModal>
76-
</>
69+
<ChipConfirmModal
70+
open={confirming}
71+
onOpenChange={(open) => {
72+
if (!disconnect.isPending) setConfirming(open)
73+
}}
74+
title={`Disconnect ${integrationName}`}
75+
text={`Disconnect ${account.displayName} from all ${integrationName} connections in this organization. Workflows using this account will also lose access. You can reconnect later.`}
76+
confirm={{
77+
label: 'Disconnect',
78+
pendingLabel: 'Disconnecting',
79+
pending: disconnect.isPending,
80+
disabled: disconnect.isPending,
81+
onClick: () =>
82+
disconnect.mutate(account.credentialId, { onSuccess: () => setConfirming(false) }),
83+
}}
84+
>
85+
<ChipModalError>{disconnect.error?.message}</ChipModalError>
86+
</ChipConfirmModal>
7787
)}
7888
</>
7989
)

‎apps/sim/app/o/[organizationId]/integrations/accounts/[credentialId]/tool-permissions.tsx‎

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -206,31 +206,29 @@ function ToolPermissionGroup({
206206
/>
207207
}
208208
>
209-
<div className='divide-y divide-[var(--border)]'>
210-
{visible.map((tool) => (
211-
<div
212-
key={tool.toolId}
213-
className='flex flex-col items-start gap-3 py-3 sm:flex-row sm:items-center sm:justify-between'
214-
>
215-
<div className='min-w-0 flex-1'>
216-
<Tooltip.Root>
217-
<Tooltip.Trigger asChild>
218-
<span className='text-[var(--text-body)] text-small'>{tool.name}</span>
219-
</Tooltip.Trigger>
220-
<Tooltip.Content>{tool.description}</Tooltip.Content>
221-
</Tooltip.Root>
222-
</div>
223-
<ChipSwitch
224-
className='max-w-full shrink-0'
225-
options={options}
226-
value={tool.policy}
227-
disabled={pending}
228-
aria-label={`${tool.name} permission`}
229-
onChange={(policy) => onChange({ kind: 'tool', toolId: tool.toolId, policy })}
230-
/>
209+
{visible.map((tool) => (
210+
<div
211+
key={tool.toolId}
212+
className='flex flex-col items-start gap-3 py-3 sm:flex-row sm:items-center sm:justify-between'
213+
>
214+
<div className='min-w-0 flex-1'>
215+
<Tooltip.Root>
216+
<Tooltip.Trigger asChild>
217+
<span className='text-[var(--text-body)] text-small'>{tool.name}</span>
218+
</Tooltip.Trigger>
219+
<Tooltip.Content>{tool.description}</Tooltip.Content>
220+
</Tooltip.Root>
231221
</div>
232-
))}
233-
</div>
222+
<ChipSwitch
223+
className='max-w-full shrink-0'
224+
options={options}
225+
value={tool.policy}
226+
disabled={pending}
227+
aria-label={`${tool.name} permission`}
228+
onChange={(policy) => onChange({ kind: 'tool', toolId: tool.toolId, policy })}
229+
/>
230+
</div>
231+
))}
234232
{!visible.length && (
235233
<SettingsEmptyState variant='inline'>No matching tools</SettingsEmptyState>
236234
)}

‎apps/sim/lib/credentials/managed-oauth.integration.ts‎

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { jsonResponse } from '@sim/testing/helpers/http'
1111
import { generateId } from '@sim/utils/id'
1212
import { eq } from 'drizzle-orm'
1313
import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it, vi } from 'vitest'
14-
import { getPublicCredentialGroupEnrollment } from '@/lib/credential-groups/enrollments'
14+
import { getAuthorizedPublicCredentialGroupEnrollment } from '@/lib/credential-groups/enrollments'
1515
import type { CredentialGroupProviderPolicy } from '@/lib/credential-groups/provider-adapter'
1616
import { getCredentialGroupProviderAdapter } from '@/lib/credential-groups/provider-registry'
1717
import {
@@ -30,6 +30,14 @@ const groupId = generateId()
3030
const enrollmentId = generateId()
3131
const credentialId = generateId()
3232
const invitationToken = generateId()
33+
const enrollmentIdentity = {
34+
userId,
35+
enrollmentId,
36+
credentialGroupId: groupId,
37+
organizationId,
38+
email: `${userId}@example.test`,
39+
invitationTokenHash: sha256Hex(invitationToken),
40+
}
3341
const instanceUrl = 'https://managed-destination-fixture.my.salesforce.com'
3442
let policy: CredentialGroupProviderPolicy
3543
let accessToken: string
@@ -212,7 +220,7 @@ describe('managed Salesforce destination resolution', () => {
212220

213221
describe('managed enrollment scope status', () => {
214222
it('keeps a fully granted account connected when only its stored scope fingerprint differs', async () => {
215-
const enrollment = await getPublicCredentialGroupEnrollment(invitationToken)
223+
const enrollment = await getAuthorizedPublicCredentialGroupEnrollment(enrollmentIdentity)
216224
expect(enrollment?.options[0]?.connections[0]?.status).toBe('connected')
217225
})
218226

@@ -222,7 +230,7 @@ describe('managed enrollment scope status', () => {
222230
.update(credential)
223231
.set({ grantedScopes: ['api'] })
224232
.where(eq(credential.id, credentialId))
225-
const enrollment = await getPublicCredentialGroupEnrollment(invitationToken)
233+
const enrollment = await getAuthorizedPublicCredentialGroupEnrollment(enrollmentIdentity)
226234
expect(enrollment?.options[0]?.connections[0]?.status).toBe('needs_reauth')
227235
await expect(resolve()).resolves.toMatchObject({ instanceUrl })
228236
})

‎apps/sim/scripts/test-assistant-actions-e2e.ts‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -876,6 +876,8 @@ try {
876876
const editedBody = 'Please confirm the owner by Friday.\nThank you.'
877877
await plain.getByRole('textbox', { name: 'Message', exact: true }).fill(editedBody)
878878
await expect(plain.getByRole('textbox', { name: 'To', exact: true })).toHaveCount(0)
879+
await plain.scrollIntoViewIfNeeded()
880+
await capture('email-review-edit')
879881
await plain.getByRole('button', { name: 'Done', exact: true }).click()
880882
await expect(plain.getByRole('region', { name: 'Message preview', exact: true })).toHaveText(
881883
editedBody
@@ -1097,7 +1099,12 @@ try {
10971099
.nth(0)
10981100
.getByRole('textbox', { name: 'Summary', exact: true })
10991101
.fill('Publish the reviewed launch checklist')
1102+
await reviewCards.nth(0).scrollIntoViewIfNeeded()
1103+
await capture('action-review-edit-mobile')
1104+
await page.setViewportSize({ width: 1440, height: 1000 })
1105+
await reviewCards.nth(0).scrollIntoViewIfNeeded()
11001106
await capture('action-review-edit')
1107+
await page.setViewportSize({ width: 390, height: 844 })
11011108
await reviewCards.nth(0).getByRole('button', { name: 'Done', exact: true }).click()
11021109
await expect(
11031110
reviewCards.nth(0).getByText('Publish the reviewed launch checklist', { exact: true })

‎scripts/check-unused-exports.baseline.json‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4193,7 +4193,6 @@
41934193
"apps/sim/lib/core/async-jobs/index.ts#getCurrentBackendType",
41944194
"apps/sim/lib/core/async-jobs/index.ts#resetJobQueueCache",
41954195
"apps/sim/lib/core/async-jobs/types.ts#AsyncExecutionCorrelationSource",
4196-
"apps/sim/lib/core/config/env-flags.ts#isEnterpriseEnabled",
41974196
"apps/sim/lib/core/config/feature-flags.ts#FeatureFlagRule",
41984197
"apps/sim/lib/core/http/classes.ts#DELIVERY_CLASSES",
41994198
"apps/sim/lib/core/http/classes.ts#DeliveryClass",

0 commit comments

Comments
 (0)