Show the user's TRE and workspace roles in the UI user menu - #5052
Draft
Jay W (JayDoubleu) wants to merge 1 commit into
Draft
Show the user's TRE and workspace roles in the UI user menu#5052Jay W (JayDoubleu) wants to merge 1 commit into
Jay W (JayDoubleu) wants to merge 1 commit into
Conversation
The UI already holds the signed-in user's roles in AppRolesContext and WorkspaceContext, but only uses them to decide which elements to render. When SecuredByRole removes an element, the user cannot tell whether that is expected for their role or whether a role assignment has not taken effect yet. Show the roles in the user menu instead: - The button summarises the roles for the scope being viewed, so the indicator is visible without opening the menu. - The menu lists TRE roles, and workspace roles on a workspace route. - An empty scope reads "None assigned" rather than rendering nothing, which is the state that is hardest to diagnose today. - Role values are mapped to display names, falling back to the raw value so a newly added app role is still shown. TopNav takes the workspace roles as a prop because it sits outside the WorkspaceContext provider. The roles come from the same token claims that SecuredByRole gates on, so the menu cannot disagree with what the UI allows.
9 tasks
Unit Test Results250 tests 250 ✅ 16s ⏱️ Results for commit f630a1c. |
Member
|
Jay W (@JayDoubleu) thanks. I think below the name looks cluttered. Thoughts on these options:
I quite like number 2. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Resolves #5051
What is being addressed
The UI knows the roles of the user, but it does not show them. The core roles are
in
AppRolesContextand the workspace roles are inWorkspaceContext. Thecomponents that read them use them only to select which elements to show.
Thus two different conditions look the same.
SecuredByRoleremoves an elementfully when the user does not have the role and the caller gives no error message.
A Researcher who does not see the "Create new" button cannot find the cause. The
cause can be the Researcher role, which is correct. The cause can also be a role
assignment that is not yet in effect.
This also makes tests more difficult. Each role sees a different page, so you must
test a change to a controlled function with each role. Today you change the app
role assignment in Entra ID, open the UI again, and then look at the buttons to
decide if the new role is in effect.
How is this addressed
The user menu now shows the roles that the user has.
open the menu to see it.
TRE roles. On a workspace route it also listsWorkspace roles.None assigned. The UI does not show an emptyarea. This condition is the most difficult one to find today.
TREAdminbecomesTRE Administrator. An unknown value keeps its raw text, so a new app role isstill shown.
The button has room for one line. Thus the summary gives the name of one role and
counts the others:
Workspace Owner +2 more. A token lists the roles in noguaranteed order, so the roles are sorted first and the summary names the most
privileged one. The same order applies to the menu.
Inside a workspace the summary gives the workspace roles. A TRE Admin has no
workspace role there, so the summary falls back to the core roles instead of
No roles assigned.TopNavtakes the workspace roles as a property, because it is outside theWorkspaceContextprovider and cannot read them. The state is already inApp, andWorkspaceProviderclears it when it unmounts.The menu reads the same token claims that
SecuredByRoleuses. It does not readEntra ID. Thus the menu and the available functions always agree. A difference
would show that the browser has an old token, which is useful data.
Screenshots
One role, and more than one role:
A TRE Admin in a workspace with no workspace role, and a user with no roles:
The menu open, for a user with all three workspace roles:
The screenshots come from a preview harness that renders the component with a
stub in place of MSAL. The harness is not part of this change.
Checks
npx vitest run: 27 files and 250 tests pass.UserMenu.tsxandroleNames.tsare at 100% for statements, branches, functions and lines.npx eslint .is clean.npx prettier --check srcis clean.npm run buildpasses.ui/app/package.jsonmoves to 0.8.32. There is a CHANGELOG entry, and theAuthN + AuthZ section of
docs/tre-developers/ui.mdis updated.Open points
contextual menu is not a usual use of the control. I can move the roles to a
callout or a panel if that is better.
size40, because Fluent does not show the secondary textbelow that size. The bar is 50px high, so the bar itself does not change.
shows
None assigneduntil the roles arrive.Contacticon. No icon shows at present, because theapp does not call
initializeIcons(). TheSignOuticon on the Logout itemhas the same condition. This is not new, and it is not part of this change.