mirror of
https://github.com/coder/coder.git
synced 2026-09-22 05:05:20 +08:00
feat(site): add task notifications to user settings (#20006)
## Description Add UI support for the new `Task Events` notification templates (`Task Working` and `Task Idle`) added in backend PR https://github.com/coder/coder/pull/19965. The `/api/v2/notifications/templates/system` endpoint now returns these templates, therefore this PR keeps the UI in sync. ## Changes * Added `Task Working` and `Task Idle` to notification template mocks so Storybook reflects backend data. * Deployment Settings already lists all templates from the API, so no code change was needed (stories updated automatically). * Updated the User Settings filter to include `Task Events` so they appear for end users. <img width="2930" height="1666" alt="Screenshot 2025-09-29 at 17 06 22" src="https://github.com/user-attachments/assets/045d5dd7-13a4-4378-9bf3-9fd86a86e64b" /> Depends on: https://github.com/coder/coder/pull/19965
This commit is contained in:
@@ -69,6 +69,7 @@ export const Events: Story = {
|
||||
await canvas.findByText("Template Events");
|
||||
await canvas.findByText("User Events");
|
||||
await canvas.findByText("Workspace Events");
|
||||
await canvas.findByText("Task Events");
|
||||
|
||||
// Custom notification template
|
||||
await canvas.findByText("Custom Events");
|
||||
|
||||
@@ -54,7 +54,22 @@ const meta = {
|
||||
export default meta;
|
||||
type Story = StoryObj<typeof NotificationsPage>;
|
||||
|
||||
export const Default: Story = {};
|
||||
export const Default: Story = {
|
||||
play: async ({ canvasElement }) => {
|
||||
const canvas = within(canvasElement);
|
||||
|
||||
await Promise.all([
|
||||
// System notification templates
|
||||
canvas.findByRole("checkbox", { name: "Task Events" }),
|
||||
canvas.findByRole("checkbox", { name: "Template Events" }),
|
||||
canvas.findByRole("checkbox", { name: "User Events" }),
|
||||
canvas.findByRole("checkbox", { name: "Workspace Events" }),
|
||||
|
||||
// Custom notification template
|
||||
canvas.findByRole("checkbox", { name: "Custom Events" }),
|
||||
]);
|
||||
},
|
||||
};
|
||||
|
||||
export const ToggleGroup: Story = {
|
||||
play: async ({ canvasElement }) => {
|
||||
|
||||
@@ -228,12 +228,12 @@ function canSeeNotificationGroup(
|
||||
permissions: Permissions,
|
||||
): boolean {
|
||||
switch (group) {
|
||||
case "Workspace Events":
|
||||
return true;
|
||||
case "Template Events":
|
||||
return permissions.createTemplates;
|
||||
case "User Events":
|
||||
return permissions.createUser;
|
||||
case "Workspace Events":
|
||||
case "Task Events":
|
||||
case "Custom Events":
|
||||
return true;
|
||||
default:
|
||||
|
||||
@@ -4702,6 +4702,31 @@ export const MockSystemNotificationTemplates: TypesGen.NotificationTemplate[] =
|
||||
kind: "system",
|
||||
enabled_by_default: true,
|
||||
},
|
||||
{
|
||||
id: "d4a6271c-cced-4ed0-84ad-afd02a9c7799",
|
||||
name: "Task Idle",
|
||||
title_template: "Task '{{.Labels.workspace}}' is idle",
|
||||
body_template: "The task '{{.Labels.task}}' is idle and ready for input.",
|
||||
actions:
|
||||
'[{"url": "{{base_url}}/tasks/{{.UserUsername}}/{{.Labels.workspace}}", "label": "View task"}, {"url": "{{base_url}}/@{{.UserUsername}}/{{.Labels.workspace}}", "label": "View workspace"}]',
|
||||
group: "Task Events",
|
||||
method: "",
|
||||
kind: "system",
|
||||
enabled_by_default: true,
|
||||
},
|
||||
{
|
||||
id: "bd4b7168-d05e-4e19-ad0f-3593b77aa90f",
|
||||
name: "Task Working",
|
||||
title_template: "Task '{{.Labels.workspace}}' is working",
|
||||
body_template:
|
||||
"The task '{{.Labels.task}}' transitioned to a working state.",
|
||||
actions:
|
||||
'[{"url": "{{base_url}}/tasks/{{.UserUsername}}/{{.Labels.workspace}}", "label": "View task"}, {"url": "{{base_url}}/@{{.UserUsername}}/{{.Labels.workspace}}", "label": "View workspace"}]',
|
||||
group: "Task Events",
|
||||
method: "",
|
||||
kind: "system",
|
||||
enabled_by_default: true,
|
||||
},
|
||||
];
|
||||
|
||||
export const MockCustomNotificationTemplates: TypesGen.NotificationTemplate[] =
|
||||
|
||||
Reference in New Issue
Block a user