Skip to content

Commit 266bf0d

Browse files
Bill LeoutsakosBill Leoutsakos
authored andcommitted
refactor(plaid): share service account form
1 parent c30070f commit 266bf0d

8 files changed

Lines changed: 307 additions & 454 deletions

File tree

apps/sim/app/workspace/[workspaceId]/integrations/components/connect-service-account-modal/connect-service-account-modal.tsx

Lines changed: 12 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,19 @@ import { getErrorMessage } from '@sim/utils/errors'
1515
import { isApiClientError } from '@/lib/api/client/errors'
1616
import { serviceAccountJsonSchema } from '@/lib/api/contracts/credentials'
1717
import {
18-
type ClientCredentialAccountProviderId,
19-
getClientCredentialAccountDescriptor,
20-
} from '@/lib/credentials/client-credential-accounts/descriptors'
18+
getServiceAccountFormDescriptor,
19+
type ServiceAccountFormProviderId,
20+
} from '@/lib/credentials/service-account-form-descriptors'
2121
import {
2222
getTokenServiceAccountDescriptor,
2323
type TokenServiceAccountProviderId,
2424
} from '@/lib/credentials/token-service-accounts/descriptors'
2525
import { getServiceAccountCoverageSentence } from '@/lib/integrations/credential-display'
2626
import {
2727
ATLASSIAN_SERVICE_ACCOUNT_PROVIDER_ID,
28-
PLAID_SERVICE_ACCOUNT_PROVIDER_ID,
2928
SLACK_CUSTOM_BOT_PROVIDER_ID,
3029
} from '@/lib/oauth/types'
31-
import { ClientCredentialAccountModal } from '@/app/workspace/[workspaceId]/integrations/components/connect-service-account-modal/client-credential-account-modal'
32-
import { PlaidServiceAccountModal } from '@/app/workspace/[workspaceId]/integrations/components/connect-service-account-modal/plaid-service-account-modal'
30+
import { ServiceAccountFormModal } from '@/app/workspace/[workspaceId]/integrations/components/connect-service-account-modal/service-account-form-modal'
3331
import { TokenServiceAccountModal } from '@/app/workspace/[workspaceId]/integrations/components/connect-service-account-modal/token-service-account-modal'
3432
import { ConnectSlackBotModal } from '@/app/workspace/[workspaceId]/integrations/components/connect-slack-bot-modal/connect-slack-bot-modal'
3533
import { withBrandIcon } from '@/blocks/brand-icon'
@@ -46,9 +44,8 @@ export type ServiceAccountProviderId =
4644
| typeof GOOGLE_SERVICE_ACCOUNT_PROVIDER_ID
4745
| typeof ATLASSIAN_SERVICE_ACCOUNT_PROVIDER_ID
4846
| typeof SLACK_CUSTOM_BOT_PROVIDER_ID
49-
| typeof PLAID_SERVICE_ACCOUNT_PROVIDER_ID
5047
| TokenServiceAccountProviderId
51-
| ClientCredentialAccountProviderId
48+
| ServiceAccountFormProviderId
5249

5350
/** Sim setup guides for each provider, docked bottom-left of each modal. */
5451
const GOOGLE_SERVICE_ACCOUNT_DOCS_URL = 'https://docs.sim.ai/integrations/google-service-account'
@@ -139,8 +136,9 @@ interface ConnectServiceAccountModalProps {
139136
* - `atlassian-service-account`: API token + site domain. Validated by the
140137
* server against the Atlassian API; user-facing errors are mapped from the
141138
* route's `error.code`.
142-
* - `plaid-service-account`: application client ID + environment secret + one
143-
* Item access token. Validated server-side against Plaid `/item/get`.
139+
* - descriptor-backed providers: field-driven forms for client-credential
140+
* providers and Plaid Item credentials. Verification remains provider-specific
141+
* on the server.
144142
*/
145143
export function ConnectServiceAccountModal({
146144
open,
@@ -154,14 +152,14 @@ export function ConnectServiceAccountModal({
154152
credentialDescription,
155153
onCreated,
156154
}: ConnectServiceAccountModalProps) {
157-
const clientCredentialDescriptor = getClientCredentialAccountDescriptor(serviceAccountProviderId)
158-
if (clientCredentialDescriptor) {
155+
const serviceAccountFormDescriptor = getServiceAccountFormDescriptor(serviceAccountProviderId)
156+
if (serviceAccountFormDescriptor) {
159157
return (
160-
<ClientCredentialAccountModal
158+
<ServiceAccountFormModal
161159
open={open}
162160
onOpenChange={onOpenChange}
163161
workspaceId={workspaceId}
164-
descriptor={clientCredentialDescriptor}
162+
descriptor={serviceAccountFormDescriptor}
165163
serviceName={serviceName}
166164
serviceIcon={serviceIcon}
167165
credentialId={credentialId}
@@ -216,21 +214,6 @@ export function ConnectServiceAccountModal({
216214
/>
217215
)
218216
}
219-
if (serviceAccountProviderId === PLAID_SERVICE_ACCOUNT_PROVIDER_ID) {
220-
return (
221-
<PlaidServiceAccountModal
222-
open={open}
223-
onOpenChange={onOpenChange}
224-
workspaceId={workspaceId}
225-
serviceName={serviceName}
226-
serviceIcon={serviceIcon}
227-
credentialId={credentialId}
228-
initialDisplayName={credentialDisplayName}
229-
initialDescription={credentialDescription}
230-
onCreated={onCreated}
231-
/>
232-
)
233-
}
234217
return (
235218
<GoogleServiceAccountModal
236219
open={open}

apps/sim/app/workspace/[workspaceId]/integrations/components/connect-service-account-modal/plaid-service-account-modal.tsx

Lines changed: 0 additions & 281 deletions
This file was deleted.

0 commit comments

Comments
 (0)