Skip to content

Commit 677332c

Browse files
committed
fix cred set name not showing up for owner
1 parent dbdd56d commit 677332c

File tree

2 files changed

+22
-6
lines changed

2 files changed

+22
-6
lines changed

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/workflow-block/workflow-block.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,8 @@ const SubBlockRow = ({
371371
const { displayName: credentialName } = useCredentialName(
372372
credentialSourceId,
373373
credentialProviderId,
374-
workflowId
374+
workflowId,
375+
workspaceId
375376
)
376377

377378
const credentialId = dependencyValues.credential

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

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { useQuery } from '@tanstack/react-query'
22
import type { Credential } from '@/lib/oauth'
33
import { CREDENTIAL_SET } from '@/executor/constants'
4-
import { useCredentialSetMemberships } from '@/hooks/queries/credential-sets'
4+
import { useCredentialSetMemberships, useCredentialSets } from '@/hooks/queries/credential-sets'
55
import { fetchJson } from '@/hooks/selectors/helpers'
66

77
interface CredentialListResponse {
@@ -62,7 +62,12 @@ export function useOAuthCredentialDetail(
6262
})
6363
}
6464

65-
export function useCredentialName(credentialId?: string, providerId?: string, workflowId?: string) {
65+
export function useCredentialName(
66+
credentialId?: string,
67+
providerId?: string,
68+
workflowId?: string,
69+
workspaceId?: string
70+
) {
6671
// Check if this is a credential set value
6772
const isCredentialSet = credentialId?.startsWith(CREDENTIAL_SET.PREFIX) ?? false
6873
const credentialSetId = isCredentialSet
@@ -72,6 +77,12 @@ export function useCredentialName(credentialId?: string, providerId?: string, wo
7277
// Fetch credential set memberships if this is a credential set
7378
const { data: memberships = [], isFetching: membershipsLoading } = useCredentialSetMemberships()
7479

80+
// Also fetch owned credential sets to check there
81+
const { data: ownedSets = [], isFetching: ownedSetsLoading } = useCredentialSets(
82+
workspaceId,
83+
isCredentialSet && Boolean(workspaceId)
84+
)
85+
7586
const { data: credentials = [], isFetching: credentialsLoading } = useOAuthCredentials(
7687
providerId,
7788
Boolean(providerId) && !isCredentialSet
@@ -91,9 +102,10 @@ export function useCredentialName(credentialId?: string, providerId?: string, wo
91102

92103
const hasForeignMeta = foreignCredentials.length > 0
93104

94-
// For credential sets, find the matching membership and use its name
105+
// For credential sets, find the matching membership or owned set and use its name
95106
const credentialSetName = credentialSetId
96-
? memberships.find((m) => m.credentialSetId === credentialSetId)?.credentialSetName
107+
? (memberships.find((m) => m.credentialSetId === credentialSetId)?.credentialSetName ??
108+
ownedSets.find((s) => s.id === credentialSetId)?.name)
97109
: undefined
98110

99111
const displayName =
@@ -103,7 +115,10 @@ export function useCredentialName(credentialId?: string, providerId?: string, wo
103115

104116
return {
105117
displayName,
106-
isLoading: credentialsLoading || foreignLoading || (isCredentialSet && membershipsLoading),
118+
isLoading:
119+
credentialsLoading ||
120+
foreignLoading ||
121+
(isCredentialSet && (membershipsLoading || ownedSetsLoading)),
107122
hasForeignMeta,
108123
}
109124
}

0 commit comments

Comments
 (0)