Skip to content

Commit 0373899

Browse files
committed
fix credential collab logic issue
1 parent 9d97918 commit 0373899

4 files changed

Lines changed: 18 additions & 8 deletions

File tree

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/credential-selector/credential-selector.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import { OAuthRequiredModal } from '@/app/workspace/[workspaceId]/w/[workflowId]
1717
import { useDependsOnGate } from '@/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/hooks/use-depends-on-gate'
1818
import { useSubBlockValue } from '@/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/hooks/use-sub-block-value'
1919
import type { SubBlockConfig } from '@/blocks/types'
20-
import { CREDENTIAL_SET } from '@/executor/constants'
20+
import { CREDENTIAL, CREDENTIAL_SET } from '@/executor/constants'
2121
import { useCredentialSets } from '@/hooks/queries/credential-sets'
2222
import { useOAuthCredentialDetail, useOAuthCredentials } from '@/hooks/queries/oauth-credentials'
2323
import { useOrganizations } from '@/hooks/queries/organization'
@@ -116,12 +116,15 @@ export function CredentialSelector({
116116
[credentialSets, selectedCredentialSetId]
117117
)
118118

119+
const isForeignCredentialSet = Boolean(isCredentialSetSelected && !selectedCredentialSet)
120+
119121
const resolvedLabel = useMemo(() => {
120122
if (selectedCredentialSet) return selectedCredentialSet.name
123+
if (isForeignCredentialSet) return CREDENTIAL.FOREIGN_LABEL
121124
if (selectedCredential) return selectedCredential.name
122-
if (isForeign) return 'Saved by collaborator'
125+
if (isForeign) return CREDENTIAL.FOREIGN_LABEL
123126
return ''
124-
}, [selectedCredentialSet, selectedCredential, isForeign])
127+
}, [selectedCredentialSet, isForeignCredentialSet, selectedCredential, isForeign])
125128

126129
useEffect(() => {
127130
if (!isEditing) {
@@ -363,7 +366,7 @@ export function CredentialSelector({
363366
}
364367
disabled={effectiveDisabled}
365368
editable={true}
366-
filterOptions={true}
369+
filterOptions={!isForeign && !isForeignCredentialSet}
367370
isLoading={credentialsLoading}
368371
overlayContent={overlayContent}
369372
className={selectedId || isCredentialSetSelected ? 'pl-[28px]' : ''}

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/tool-input/components/tool-credential-selector.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
parseProvider,
1111
} from '@/lib/oauth'
1212
import { OAuthRequiredModal } from '@/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/credential-selector/components/oauth-required-modal'
13+
import { CREDENTIAL } from '@/executor/constants'
1314
import { useOAuthCredentialDetail, useOAuthCredentials } from '@/hooks/queries/oauth-credentials'
1415
import { getMissingRequiredScopes } from '@/hooks/use-oauth-scope-status'
1516
import { useWorkflowRegistry } from '@/stores/workflows/registry/store'
@@ -95,7 +96,7 @@ export function ToolCredentialSelector({
9596

9697
const resolvedLabel = useMemo(() => {
9798
if (selectedCredential) return selectedCredential.name
98-
if (isForeign) return 'Saved by collaborator'
99+
if (isForeign) return CREDENTIAL.FOREIGN_LABEL
99100
return ''
100101
}, [selectedCredential, isForeign])
101102

@@ -210,7 +211,7 @@ export function ToolCredentialSelector({
210211
placeholder={label}
211212
disabled={disabled}
212213
editable={true}
213-
filterOptions={true}
214+
filterOptions={!isForeign}
214215
isLoading={credentialsLoading}
215216
overlayContent={overlayContent}
216217
className={selectedId ? 'pl-[28px]' : ''}

apps/sim/executor/constants.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,10 @@ export const CREDENTIAL_SET = {
185185
PREFIX: 'credentialSet:',
186186
} as const
187187

188+
export const CREDENTIAL = {
189+
FOREIGN_LABEL: 'Saved by collaborator',
190+
} as const
191+
188192
export function isCredentialSetValue(value: string | null | undefined): boolean {
189193
return typeof value === 'string' && value.startsWith(CREDENTIAL_SET.PREFIX)
190194
}

apps/sim/hooks/queries/oauth-credentials.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { useQuery } from '@tanstack/react-query'
22
import type { Credential } from '@/lib/oauth'
3-
import { CREDENTIAL_SET } from '@/executor/constants'
3+
import { CREDENTIAL, CREDENTIAL_SET } from '@/executor/constants'
44
import { useCredentialSetDetail } from '@/hooks/queries/credential-sets'
55
import { fetchJson } from '@/hooks/selectors/helpers'
66

@@ -93,11 +93,13 @@ export function useCredentialName(credentialId?: string, providerId?: string, wo
9393
)
9494

9595
const hasForeignMeta = foreignCredentials.length > 0
96+
const isForeignCredentialSet = isCredentialSet && !credentialSetData && !credentialSetLoading
9697

9798
const displayName =
9899
credentialSetData?.name ??
99100
selectedCredential?.name ??
100-
(hasForeignMeta ? 'Saved by collaborator' : null)
101+
(hasForeignMeta ? CREDENTIAL.FOREIGN_LABEL : null) ??
102+
(isForeignCredentialSet ? CREDENTIAL.FOREIGN_LABEL : null)
101103

102104
return {
103105
displayName,

0 commit comments

Comments
 (0)