Skip to content

feat(FR-2555): add useCurrentUserProjectRoles hook with myRoles RBAC query#6651

Merged
graphite-app[bot] merged 1 commit intomainfrom
04-13-feat_fr-2209_add_usecurrentuserprojectroles_hook_with_myroles_rbac_query
Apr 14, 2026
Merged

feat(FR-2555): add useCurrentUserProjectRoles hook with myRoles RBAC query#6651
graphite-app[bot] merged 1 commit intomainfrom
04-13-feat_fr-2209_add_usecurrentuserprojectroles_hook_with_myroles_rbac_query

Conversation

@yomybaby
Copy link
Copy Markdown
Member

@yomybaby yomybaby commented Apr 13, 2026

Resolves #6641 (FR-2555)

Part of FR-2209 Project Admin Management stack (PR-1).

Summary

  • Add useCurrentUserProjectRoles hook that inspects the myRoles RBAC query and reports project admin scope
  • Expose deriveProjectAdminIds (pure function) and useEffectiveAdminRole derived hook
  • Use @catch(to: RESULT) so older cores without the myRoles field fall back to empty admin arrays instead of throwing

Verification

  • bash scripts/verify.sh=== ALL PASS ===
  • Unit tests: react/src/hooks/__tests__/useCurrentUserProjectRoles.test.tsx

Copilot AI review requested due to automatic review settings April 13, 2026 13:52
@github-actions github-actions Bot added the size:L 100~500 LoC label Apr 13, 2026
Copy link
Copy Markdown
Member Author

yomybaby commented Apr 13, 2026


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • flow:merge-queue - adds this PR to the back of the merge queue
  • flow:hotfix - for urgent changes, fast-track this PR to the front of the merge queue

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has required the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 13, 2026

Coverage report for ./react

St.
Category Percentage Covered / Total
🔴 Statements 9.02% 1770/19627
🔴 Branches 8.14% 1115/13694
🔴 Functions 5.36% 286/5335
🔴 Lines 8.71% 1660/19058

Test suite run success

859 tests passing in 39 suites.

Report generated by 🧪jest coverage report action from 9dc530a

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new RBAC-focused hook in the React WebUI to derive the current user’s project-admin scope by querying myRoles via Relay, with a pure helper function and unit tests to validate the derivation logic.

Changes:

  • Introduces useCurrentUserProjectRoles (Relay myRoles query + legacy baiClient signals) and useEffectiveAdminRole.
  • Adds deriveProjectAdminIds + UUID normalization and role-name fallback logic.
  • Adds Jest tests covering the derivation rules (primary permission signal vs fallback, normalization, dedupe, edge cases).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
react/src/hooks/useCurrentUserProjectRoles.ts Implements the myRoles Relay query, derives project-admin IDs, and exposes hooks for effective admin role selection.
react/src/hooks/tests/useCurrentUserProjectRoles.test.tsx Unit tests for deriveProjectAdminIds covering primary/fallback behavior, normalization, deduplication, and malformed inputs.

Comment thread react/src/hooks/useCurrentUserProjectRoles.ts Outdated
Comment thread react/src/hooks/useCurrentUserProjectRoles.ts Outdated
Comment thread react/src/hooks/useCurrentUserProjectRoles.ts
@yomybaby yomybaby force-pushed the 04-13-feat_fr-2209_add_usecurrentuserprojectroles_hook_with_myroles_rbac_query branch from 32b533a to 4181d2d Compare April 13, 2026 14:01
@yomybaby yomybaby force-pushed the 04-13-feat_fr-2209_add_usecurrentuserprojectroles_hook_with_myroles_rbac_query branch from 4181d2d to e0a3057 Compare April 14, 2026 08:07
@yomybaby yomybaby changed the title feat(FR-2209): add useCurrentUserProjectRoles hook with myRoles RBAC query feat(FR-2555): add useCurrentUserProjectRoles hook with myRoles RBAC query Apr 14, 2026
@yomybaby yomybaby force-pushed the 04-13-feat_fr-2209_add_usecurrentuserprojectroles_hook_with_myroles_rbac_query branch from e0a3057 to 5ac5f01 Compare April 14, 2026 08:23
@graphite-app
Copy link
Copy Markdown

graphite-app Bot commented Apr 14, 2026

Merge activity

…query (#6651)

Resolves #6641 (FR-2555)

Part of FR-2209 Project Admin Management stack (PR-1).

## Summary
- Add `useCurrentUserProjectRoles` hook that inspects the `myRoles` RBAC query and reports project admin scope
- Expose `deriveProjectAdminIds` (pure function) and `useEffectiveAdminRole` derived hook
- Use `@catch(to: RESULT)` so older cores without the `myRoles` field fall back to empty admin arrays instead of throwing

## Verification
- `bash scripts/verify.sh` → `=== ALL PASS ===`
- Unit tests: `react/src/hooks/__tests__/useCurrentUserProjectRoles.test.tsx`
@graphite-app graphite-app Bot force-pushed the 04-13-feat_fr-2209_add_usecurrentuserprojectroles_hook_with_myroles_rbac_query branch from 5ac5f01 to 9dc530a Compare April 14, 2026 08:41
graphite-app Bot pushed a commit that referenced this pull request Apr 14, 2026
…tor (#6653)

Resolves #6644 (FR-2552)

Part of FR-2209 Project Admin Management stack (PR-1a).
Stacks on #6651.

## Summary
- `useWebUIMenuItems` now gates admin-category keys by `useEffectiveAdminRole()`; project admins see only Session/Serving/Data/Members
- `WebUISider` uses 3-tier `hasAdminCategoryRole = useEffectiveAdminRole() !== 'none'`
- `ProjectSelect` renders a "Project Admin" badge on admin-scoped projects for project-admin-only users

## Verification
- `bash scripts/verify.sh` -> `=== ALL PASS ===`
@graphite-app graphite-app Bot merged commit 9dc530a into main Apr 14, 2026
11 checks passed
@graphite-app graphite-app Bot deleted the 04-13-feat_fr-2209_add_usecurrentuserprojectroles_hook_with_myroles_rbac_query branch April 14, 2026 08:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L 100~500 LoC

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants