Skip to content

Commit 97d94b9

Browse files
committed
fix(workflow): track resolved isAdmin in prevIsAdminRef to prevent stale lock notification
When workspacePermissions loads asynchronously, prevCanAdminRef (which only tracked effectivePermissions.canAdmin) would not detect the change, causing the early-return guard to skip rebuilding the notification with the correct unlock-button visibility. Track the same resolved value (workspacePermissions ?.viewer?.isAdmin ?? effectivePermissions.canAdmin) that is actually used to build the notification.
1 parent cc6c8c5 commit 97d94b9

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

  • apps/sim/app/workspace/[workspaceId]/w/[workflowId]

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1251,13 +1251,16 @@ const WorkflowContent = React.memo(
12511251
return findLockedAncestorFolder(workflowMetadata?.folderId, folders)?.name ?? null
12521252
}, [workflowFolderLocked, workflowMetadata?.folderId, folders])
12531253

1254-
const prevCanAdminRef = useRef(effectivePermissions.canAdmin)
1254+
const prevIsAdminRef = useRef(
1255+
workspacePermissions?.viewer?.isAdmin ?? effectivePermissions.canAdmin
1256+
)
12551257
const prevLockSignatureRef = useRef<string | null>(null)
12561258
useEffect(() => {
12571259
if (!isWorkflowReady) return
12581260

1259-
const canAdminChanged = prevCanAdminRef.current !== effectivePermissions.canAdmin
1260-
prevCanAdminRef.current = effectivePermissions.canAdmin
1261+
const isAdmin = workspacePermissions?.viewer?.isAdmin ?? effectivePermissions.canAdmin
1262+
const canAdminChanged = prevIsAdminRef.current !== isAdmin
1263+
prevIsAdminRef.current = isAdmin
12611264

12621265
const lockSignature = workflowReadOnly
12631266
? workflowRowLocked
@@ -1273,8 +1276,6 @@ const WorkflowContent = React.memo(
12731276

12741277
if (workflowReadOnly) {
12751278
if (lockNotificationIdRef.current) return
1276-
1277-
const isAdmin = workspacePermissions?.viewer?.isAdmin ?? effectivePermissions.canAdmin
12781279
const isFolderInherited = workflowFolderLocked && !workflowRowLocked
12791280
const message = isFolderInherited
12801281
? inheritedLockFolderName

0 commit comments

Comments
 (0)