Skip to content

Sai Teja - Fix pause/resume permission flow in profile and user management#5122

Open
saitejakaasoju wants to merge 6 commits intodevelopmentfrom
sai/pause-user-permission
Open

Sai Teja - Fix pause/resume permission flow in profile and user management#5122
saitejakaasoju wants to merge 6 commits intodevelopmentfrom
sai/pause-user-permission

Conversation

@saitejakaasoju
Copy link
Copy Markdown
Contributor

@saitejakaasoju saitejakaasoju commented Apr 9, 2026

Description

image

Implements the frontend side of the dedicated pause/resume permission flow and fixes pause/resume behavior across the profile page and User Management table.

This PR updates the app to use the new interactWithPauseUserButton permission consistently, routes pause/resume actions through the dedicated pause endpoint, and removes stale permission/bypass logic that caused visibility and behavior mismatches.

Fixes priority high bug(s):

  • Pause button visible in some places but backend rejected the action
  • Resume/pause behavior inconsistent between profile page and User Management table
  • Removing pause permission from Owner/Admin did not hide the button on the profile page
  • Old permission key pauseUserActivity still affected frontend behavior

Related PRs (if any):

This frontend PR is related to the backend PR:

  • HGNRest PR: sai/pause-user-permission-backend

To fully test this frontend PR, you need to run the matching backend PR as well.

Main changes explained:

  • Update src/actions/userManagement.js to:
    • send requestor in pause/resume requests
    • use the dedicated pause endpoint
    • keep lifecycle updates using the corrected user profile endpoint
  • Update src/utils/URL.js to include the dedicated USER_PAUSE endpoint
  • Update src/components/UserManagement/PauseAndResumeButton.jsx to use the new pause/resume action path
  • Update src/components/UserManagement/UserManagement.jsx so table resume/reactivate flows use the dedicated pause endpoint instead of the old lifecycle action
  • Update src/components/UserManagement/UserTableData.jsx to keep pause/resume table behavior aligned and clean up syntax issues
  • Update src/components/UserProfile/BasicInformationTab/BasicInformationTab.jsx to remove the hardcoded Owner/Admin visibility bypass and rely on the real permission
  • Update src/components/UserProfile/UserProfile.jsx to pass hasPermission into BasicInformationTab
  • Update src/components/PermissionsManagement/Permissions.json to remove the old pauseUserActivity entry
  • Update src/utils/routePermissions.js and src/components/Header/Header.jsx to recognize interactWithPauseUserButton
  • Update related tests for the new pause/resume action flow

How to test:

  1. Check out this branch in HighestGoodNetworkApp
  2. Run the app locally with the matching backend PR checked out in HGNRest
  3. Start frontend and backend
  4. Clear site data/cache if needed
  5. Log in as an Owner or Administrator who has interactWithPauseUserButton
  6. Open a user profile and verify:
    • the Pause button is visible when the permission is present
    • clicking Pause successfully pauses the user
    • clicking Resume successfully reactivates the user
  7. Go to User Management and verify:
    • pause/resume from the table works
    • resume works for a paused user
  8. Remove interactWithPauseUserButton from an Owner/Admin account and verify:
    • the Pause button no longer appears on the profile page
    • the table flow no longer allows pause/resume for that user
  9. Grant interactWithPauseUserButton to a non-admin user and verify they can use pause/resume appropriately
  10. Verify the old pauseUserActivity permission is no longer shown/used
  11. Verify this behavior in dark mode as well

Screenshots or videos of changes:

Screen.Recording.2026-04-08.at.9.32.54.PM.mov

Note:

This PR should be tested together with the matching backend PR because the dedicated pause route and permission checks are implemented there.

@netlify
Copy link
Copy Markdown

netlify Bot commented Apr 9, 2026

Deploy Preview for highestgoodnetwork-dev ready!

Name Link
🔨 Latest commit bd586d9
🔍 Latest deploy log https://app.netlify.com/projects/highestgoodnetwork-dev/deploys/69e30c17dd2aea00084f14e4
😎 Deploy Preview https://deploy-preview-5122--highestgoodnetwork-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Comment thread src/components/UserProfile/UserProfile.jsx Outdated
Comment thread src/components/UserProfile/UserProfile.jsx Outdated
Comment thread src/components/UserProfile/BasicInformationTab/BasicInformationTab.jsx Outdated
Comment thread src/components/UserProfile/BasicInformationTab/BasicInformationTab.jsx Outdated
const rolesAllowedToEditStatusFinalDay = ['Administrator', 'Owner'];
const canEditStatus =
rolesAllowedToEditStatusFinalDay.includes(role) || dispatch(hasPermission('pauseUserActivity'));
const canEditStatus = props.hasPermission?.('interactWithPauseUserButton');
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.

Suggested change
const canEditStatus = props.hasPermission?.('interactWithPauseUserButton');
const canEditStatus = dispatch(hasPermission('interactWithPauseUserButton');

Can use the original way of calling hasPermission() with dispatch().

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Addressed Nathan’s feedback by removing the hasPermission prop drilling from UserProfile/BasicInformationTab and switching the permission check back to the dispatch-based hasPermission('interactWithPauseUserButton') pattern inside BasicInformationTab. I also repaired the failing UserTableData test file and reran the related pause/user-management test slice locally. This is ready for re-review.

@one-community one-community changed the title Fix pause/resume permission flow in profile and user management Sai Teja - Fix pause/resume permission flow in profile and user management Apr 12, 2026
Copy link
Copy Markdown
Contributor

@nathanah nathanah left a comment

Choose a reason for hiding this comment

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

Double-check that requestor is needed, and fix the slight redundancy. Everything else looks good. Good job

const rolesAllowedToEditStatusFinalDay = ['Administrator', 'Owner'];
const canEditStatus =
rolesAllowedToEditStatusFinalDay.includes(role) || dispatch(hasPermission('pauseUserActivity'));
rolesAllowedToEditStatusFinalDay.includes(role) ||
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.

Suggested change
rolesAllowedToEditStatusFinalDay.includes(role) ||

Redundant since hasPermission() also checks role permissions.

Copy link
Copy Markdown
Contributor Author

@saitejakaasoju saitejakaasoju Apr 18, 2026

Choose a reason for hiding this comment

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

I double-checked the current backend implementation before changing this. requestor is still required in the request body for the user status / pause-resume authorization path, so I kept it to avoid breaking the working flow and addressed this by removing the redundant explicit role check and relying on the existing hasPermission('interactWithPauseUserButton') path.

Comment thread src/actions/userManagement.js
Comment thread src/actions/userManagement.js
@sonarqubecloud
Copy link
Copy Markdown

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants