Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite23db57

Browse files
fix(site): allow template admins to see template notification settings
Template admins have been unable to change their notificationpreferences via the website as we have historically hidden the settingsfor them. This PR ensures the frontend shows template events settingswhen a user has the `createTemplates` permission.
1 parentbf78966 commite23db57

File tree

3 files changed

+45
-6
lines changed

3 files changed

+45
-6
lines changed

‎site/src/pages/UserSettingsPage/NotificationsPage/NotificationsPage.stories.tsx‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,12 @@ export const NonAdmin: Story = {
7878
},
7979
};
8080

81+
exportconstTemplateCreator:Story={
82+
parameters:{
83+
permissions:{viewDeploymentConfig:false,createTemplates:true},
84+
},
85+
};
86+
8187
// Ensure the selected notification template is enabled before attempting to
8288
// disable it.
8389
constenabledPreference=MockNotificationPreferences.find(

‎site/src/pages/UserSettingsPage/NotificationsPage/NotificationsPage.tsx‎

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,19 @@ const NotificationsPage: FC = () => {
4848
...systemNotificationTemplates(),
4949
select:(data:NotificationTemplate[])=>{
5050
constgroups=selectTemplatesByGroup(data);
51-
returnpermissions.viewDeploymentConfig
52-
?groups
53-
:{
54-
// Members only have access to the "Workspace Notifications" group
55-
"Workspace Events":groups["Workspace Events"],
56-
};
51+
52+
letdisplayedGroups:Record<string,NotificationTemplate[]>={
53+
// Members only have access to the "Workspace Notifications" group.
54+
"Workspace Events":groups["Workspace Events"],
55+
};
56+
57+
if(permissions.viewDeploymentConfig){
58+
displayedGroups=groups;
59+
}elseif(permissions.createTemplates){
60+
displayedGroups["Template Events"]=groups["Template Events"];
61+
}
62+
63+
returndisplayedGroups;
5764
},
5865
},
5966
notificationDispatchMethods(),

‎site/src/testHelpers/entities.ts‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4402,6 +4402,32 @@ export const MockNotificationTemplates: TypesGen.NotificationTemplate[] = [
44024402
kind:"system",
44034403
enabled_by_default:true,
44044404
},
4405+
{
4406+
id:"template-event-1",
4407+
name:"Template Version Created",
4408+
title_template:'Template version "{{.Labels.version_name}}" created',
4409+
body_template:
4410+
'Hi {{.UserName}}\nA new version of template "{{.Labels.template_name}}" has been created.',
4411+
actions:
4412+
'[{"url": "{{ base_url }}/templates/{{.Labels.template_name}}", "label": "View template"}]',
4413+
group:"Template Events",
4414+
method:"smtp",
4415+
kind:"system",
4416+
enabled_by_default:true,
4417+
},
4418+
{
4419+
id:"template-event-2",
4420+
name:"Template Updated",
4421+
title_template:'Template "{{.Labels.template_name}}" updated',
4422+
body_template:
4423+
'Hi {{.UserName}}\nTemplate "{{.Labels.template_name}}" has been updated.',
4424+
actions:
4425+
'[{"url": "{{ base_url }}/templates/{{.Labels.template_name}}", "label": "View template"}]',
4426+
group:"Template Events",
4427+
method:"webhook",
4428+
kind:"system",
4429+
enabled_by_default:true,
4430+
},
44054431
];
44064432

44074433
exportconstMockNotificationMethodsResponse:TypesGen.NotificationMethodsResponse=

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp