Skip to content

Add competition admin role support and edit button for props#133

Merged
eswan18 merged 1 commit into
mainfrom
claude/add-prop-editing-private-iQkX2
Apr 25, 2026
Merged

Add competition admin role support and edit button for props#133
eswan18 merged 1 commit into
mainfrom
claude/add-prop-editing-private-iQkX2

Conversation

@eswan18
Copy link
Copy Markdown
Owner

@eswan18 eswan18 commented Apr 25, 2026

Summary

This PR extends admin access control to include competition-level admins (in addition to global admins) and adds an edit button to the prop view for admins.

Key Changes

  • Refactored access control logic: Moved getCurrentUserRole() call outside the private competition check so the user's role is always retrieved and available for authorization decisions
  • Extended admin privileges: Updated the isAdmin prop to recognize both global admins (user.is_admin) and competition admins (userRole === "admin")
  • Added edit functionality: Added an "Edit" button to the prop view that appears only for admins, with a pencil icon from lucide-react
  • Simplified private competition check: Consolidated the role verification logic to be more concise while maintaining the same behavior

Implementation Details

  • The role is now fetched unconditionally and stored in userRole variable for reuse
  • Private competition access check now explicitly verifies competition.is_private && userRole === null
  • The edit button uses the existing setIsEditDialogOpen state to trigger the edit dialog
  • Button styling uses outline variant with small size to maintain visual consistency

https://claude.ai/code/session_013LjY2hYrqzHmZi4fmYxyTz

The prop update server action already permits competition admins via
RLS, but the competition prop view only rendered the edit dialog for
system admins and never exposed a button to open it. Add a visible
Edit button in the prop header and broaden the isAdmin check to
include users with the "admin" role in the competition.
@eswan18 eswan18 merged commit 156fbba into main Apr 25, 2026
1 check passed
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.

2 participants