Skip to content

fix(site): ensure notification settings page follows RBAC correctly #19097

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 31, 2025

Conversation

DanielleMaywood
Copy link
Contributor

@DanielleMaywood DanielleMaywood commented Jul 30, 2025

Ensure template admin and user admins are able to see the correct notification groups on the notification settings page.

Template admins have been unable to change their notification
preferences via the website as we have historically hidden the settings
for them. This PR ensures the frontend shows template events settings
when a user has the `createTemplates` permission.
@DanielleMaywood DanielleMaywood marked this pull request as ready for review July 30, 2025 10:50
@DanielleMaywood DanielleMaywood requested a review from aslilac as a code owner July 30, 2025 10:51
@DanielleMaywood DanielleMaywood requested a review from Copilot July 30, 2025 10:51
Copy link
Contributor

@Copilot 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

This PR enables template administrators to access and modify their notification preferences for template events through the frontend. Previously, these settings were hidden from users without full deployment configuration access.

  • Updated notification filtering logic to show "Template Events" group to users with createTemplates permission
  • Added mock template event notification templates for testing
  • Created a new story for template creators in the notifications page

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
site/src/testHelpers/entities.ts Added mock template event notification templates for testing scenarios
site/src/pages/UserSettingsPage/NotificationsPage/NotificationsPage.tsx Modified permission logic to display template events for users with createTemplates permission
site/src/pages/UserSettingsPage/NotificationsPage/NotificationsPage.stories.tsx Added TemplateCreator story to test the new permission scenario

"Workspace Events": groups["Workspace Events"],
};

let displayedGroups: Record<string, NotificationTemplate[]> = {
Copy link
Preview

Copilot AI Jul 30, 2025

Choose a reason for hiding this comment

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

[nitpick] The variable displayedGroups is initialized with only 'Workspace Events' and then potentially reassigned completely. Consider initializing it with the base case and then conditionally adding to it to make the logic clearer.

Copilot uses AI. Check for mistakes.

Copy link
Member

@aslilac aslilac left a comment

Choose a reason for hiding this comment

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

I would like to suggest a different approach:

#19115

Looking at the backend, it seems like user admins also have this exact same issue: by hiding the notifications based on the viewDeploymentConfig we're making it impossible for user admins to disable notifications they are opted into by default. That was always the wrong permission to check here, for both cases. For template notifications it's better to check createTemplates like you've done here, but we should fix users too by checking createUser.

I also don't think that a select is actually the right place to filter this, because the object wrangling we're doing is very awkward. I think it's easier to just check if a group should be rendered or not by returning early in the map later on. We can just have a little utility function that picks the right permission based on the group name, and if the permission is false then we return null.

I ended up just doing exactly all of that while looking at the code and pushed it to a branch of my own. If you want to bring that code into this branch you can just go click merge on that PR. I set this PR as the target.

Copy link
Member

@aslilac aslilac left a comment

Choose a reason for hiding this comment

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

cool, this is much better now 😄 thanks!

@DanielleMaywood DanielleMaywood changed the title fix(site): allow template admins to see template notification settings fix(site): ensure notification settings page follows RBAC correctly Jul 31, 2025
@DanielleMaywood DanielleMaywood merged commit a185d3a into main Jul 31, 2025
34 of 36 checks passed
@DanielleMaywood DanielleMaywood deleted the danielle/template-admin-see-template-events branch July 31, 2025 20:20
@github-actions github-actions bot locked and limited conversation to collaborators Jul 31, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants