Skip to content

Restrict showing edit options for users without sufficient permissions - #109

Open
kurtnordstrom wants to merge 1 commit into
mainfrom
disable-edit-without-permissions
Open

kurtnordstrom wants to merge 1 commit into
mainfrom
disable-edit-without-permissions

Conversation

@kurtnordstrom

Copy link
Copy Markdown
Contributor

No description provided.

@kurtnordstrom
kurtnordstrom marked this pull request as ready for review November 13, 2026 20:40
Copilot AI balanced review requested due to automatic review settings November 13, 2026 20:40

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Tests do not cover the new component-level read-only behavior or route permission restrictions, leaving control visibility, redirects, tenant-field disabling, and prevention of unauthorized mutations unverified.

2 open issues
What changed in this PR

This PR makes directory editing controls reflect user permissions: consortium admins retain full editing access, institution admins can edit their own entries, and other users receive read-only views.

Changes:

  • Adds a shared permission hook and guards entry creation and editing routes.
  • Hides restricted actions, makes configuration editors read-only, and disables tenant changes for institution admins.
  • Adds permission-hook tests and updates existing test mocks.
File Description
ui-rsdir/​src/​routes/​ViewEntryRoute.js Hides the edit action without permission.
ui-rsdir/​src/​routes/​LMSConfigRoute.js Passes permission-based read-only state.
ui-rsdir/​src/​routes/​ILLConfigRoute.js Passes permission-based read-only state.
ui-rsdir/​src/​routes/​HostProfilesConfigRoutes.test.js Adds an authorized-user permission mock.
ui-rsdir/​src/​routes/​HoldingsPolicyRoute.js Passes permission-based read-only state.
ui-rsdir/​src/​routes/​EditEntryRoute.js Redirects unauthorized users and restricts tenant editing.
ui-rsdir/​src/​routes/​ConfigOverrideSource.test.js Adds an authorized-user permission mock.
ui-rsdir/​src/​routes/​CatalogConfigRoute.js Passes permission-based read-only state.
ui-rsdir/​src/​hooks/​useDirectoryPermissions.test.js Tests permission and tenant-ownership rules.
ui-rsdir/​src/​hooks/​useDirectoryPermissions.js Centralizes directory editing permission checks.
ui-rsdir/​src/​components/​SettingsConfigEditor.js Adds component-level read-only rendering.
ui-rsdir/​src/​components/​EntryTiersEditor.js Limits tier membership controls to consortium admins.
ui-rsdir/​src/​components/​EntryOwnedTiersEditor.js Limits owned-tier controls to consortium admins.
ui-rsdir/​src/​components/​EntryOwnedNetworksEditor.js Limits owned-network controls to consortium admins.
ui-rsdir/​src/​components/​EntryNetworksEditor.js Restricts membership and priority editing controls.
ui-rsdir/​src/​components/​EntryForm.js Supports disabling the tenant field.
ui-rsdir/​src/​components/​EntryClosuresEditor.js Limits closure controls to consortium admins.
ui-rsdir/​src/​components/​Entries.js Restricts the new-entry button to consortium admins.
ui-rsdir/​src/​components/​DirectoryEntryRatio.test.js Adds an authorized-user permission mock.

Review effort: Balanced


if (field.readOnly && !field.disabled) {
// Inherited-only setting: show the resolved value without editing controls.
if ((readOnly || field.readOnly) && !field.disabled) {
Comment on lines +113 to +117
if (op === CREATE && !isConsortiumAdmin) {
return <Redirect to={`/directory/entries${location.search}`} />;
}
if (op === EDIT && !canEditEntry) {
return <Redirect to={`/directory/entries/${id}${location.search}`} />;

This branch has not been deployed

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

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants