Skip to content

fix(sidebar): pass showDelete to hide delete menu for non-admin members#4696

Closed
minijeong-log wants to merge 1 commit into
simstudioai:mainfrom
minijeong-log:fix/show-delete-permission
Closed

fix(sidebar): pass showDelete to hide delete menu for non-admin members#4696
minijeong-log wants to merge 1 commit into
simstudioai:mainfrom
minijeong-log:fix/show-delete-permission

Conversation

@minijeong-log
Copy link
Copy Markdown
Contributor

Summary

Fixes #4695

Write/Read workspace members see the Delete option in the workflow/folder context menu, but the DELETE API enforces action: 'admin', so it always fails with 403. The ContextMenu component already has a showDelete prop with conditional rendering, but workflow-item and folder-item never pass it, leaving it at the default true.

This PR passes showDelete={userPermissions.canAdmin} from both components so non-admin users no longer see the Delete menu. disableDelete is simplified to only check canDeleteSelection and effectiveLocked, since permission gating is now handled by showDelete.

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation

Testing

  • Verified with admin, write, and read permission levels by directly modifying the permissions table
    • Admin: Delete menu visible, deletion works
    • Write: Delete menu hidden
    • Read: Delete menu hidden
    • Admin (last workflow): Delete menu visible but disabled

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • Existing tests pass locally
  • I agree to the terms of the contributor license agreement

The ContextMenu component already has a showDelete prop with conditional
rendering, but workflow-item and folder-item never pass it, leaving it
at the default value of true. This causes write members to see an active
Delete option that always fails with 403, since the DELETE API requires
admin permission.

Pass showDelete={userPermissions.canAdmin} from both workflow-item and
folder-item so that non-admin users no longer see the Delete menu.
Simplify disableDelete to only check canDeleteSelection and
effectiveLocked, since permission gating is now handled by showDelete.
@vercel
Copy link
Copy Markdown

vercel Bot commented May 21, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped May 21, 2026 10:03am

Request Review

@cursor
Copy link
Copy Markdown

cursor Bot commented May 21, 2026

PR Summary

Low Risk
Low risk UI permission-gating change that only affects whether the Delete action is shown/enabled in the sidebar context menu; no backend or data model changes.

Overview
Fixes the sidebar workflow/folder context menu so Delete is only shown to admins by passing showDelete={userPermissions.canAdmin} from workflow-item and folder-item into ContextMenu.

Simplifies disableDelete in both callers to only consider selection/lock state (since permission gating is now handled via showDelete), preventing non-admin users from seeing a Delete option that would 403.

Reviewed by Cursor Bugbot for commit a0bd149. Bugbot is set up for automated code reviews on this repo. Configure here.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 21, 2026

Greptile Summary

This PR fixes a UX/permission mismatch where Write and Read workspace members could see a Delete option in the workflow/folder context menus, even though the DELETE API enforces admin-only access and returns 403 for non-admins. The fix passes showDelete={userPermissions.canAdmin} to the ContextMenu component from both workflow-item and folder-item, hiding the option entirely for non-admin roles.

  • workflow-item.tsx and folder-item.tsx: Add showDelete={userPermissions.canAdmin} and simplify disableDelete to only check operational constraints (canDeleteSelection, effectiveLocked), since permission gating is now delegated to showDelete.
  • The ContextMenu component already supported showDelete with a default of true; these two call sites simply weren't passing it.

Confidence Score: 5/5

Safe to merge — the change correctly hides a destructive action from users who cannot perform it, and the existing API-level enforcement remains intact as a backstop.

Both changed call sites are symmetric and consistent with how other show* props are already used in the same component. The disableDelete simplification is correct because admins (the only users who now see the button) always have edit permission, so removing !userPermissions.canEdit from that check has no practical effect. The canDeleteSelection and effectiveLocked guards remain, preserving the last-workflow and lock protections.

No files require special attention.

Important Files Changed

Filename Overview
apps/sim/app/workspace/[workspaceId]/w/components/sidebar/components/workflow-list/components/workflow-item/workflow-item.tsx Adds showDelete={userPermissions.canAdmin} and removes the !userPermissions.canEdit guard from disableDelete; straightforward and correct since non-admins no longer see the button at all.
apps/sim/app/workspace/[workspaceId]/w/components/sidebar/components/workflow-list/components/folder-item/folder-item.tsx Same pattern as workflow-item: adds showDelete={userPermissions.canAdmin} and simplifies disableDelete to operational checks only; change is consistent and correct.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[User right-clicks workflow/folder] --> B{userPermissions.canAdmin?}
    B -- No --> C[showDelete = false\nDelete option hidden]
    B -- Yes --> D[showDelete = true\nDelete option visible]
    D --> E{disableDelete?\neffectiveLocked OR !canDeleteSelection}
    E -- Yes --> F[Delete option shown but disabled]
    E -- No --> G[Delete option shown and enabled]
    G --> H[User clicks Delete]
    H --> I[DELETE API called\naction: 'admin' enforced]
    I --> J[200 OK — item deleted]
Loading

Reviews (1): Last reviewed commit: "fix(sidebar): pass showDelete to hide de..." | Re-trigger Greptile

@minijeong-log
Copy link
Copy Markdown
Contributor Author

Closing - will reopen against staging branch per contribution guidelines.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(sidebar): Write members see active Delete menu but get 403 from API

1 participant