Skip to content

fix: change notifications actions url #17083

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 5 commits into from
Mar 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
UPDATE notification_templates
SET
actions = '[
{
"label": "View workspace",
"url": "{{base_url}}/@{{.UserUsername}}/{{.Labels.workspace}}"
}
]'::jsonb
WHERE id = '281fdf73-c6d6-4cbb-8ff5-888baf8a2fff';

UPDATE notification_templates
SET
actions = '[
{
"label": "View workspace",
"url": "{{base_url}}/@{{.UserUsername}}/{{.Labels.workspace}}"
},
{
"label": "View template version",
"url": "{{base_url}}/templates/{{.Labels.organization}}/{{.Labels.template}}/versions/{{.Labels.version}}"
}
]'::jsonb
WHERE id = 'd089fe7b-d5c5-4c0c-aaf5-689859f7d392';
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
UPDATE notification_templates
SET
actions = '[
{
"label": "View workspace",
"url": "{{base_url}}/@{{.Labels.workspace_owner_username}}/{{.Labels.workspace}}"
}
]'::jsonb
WHERE id = '281fdf73-c6d6-4cbb-8ff5-888baf8a2fff';

UPDATE notification_templates
SET
actions = '[
{
"label": "View workspace",
"url": "{{base_url}}/@{{.Labels.workspace_owner_username}}/{{.Labels.workspace}}"
},
{
"label": "View template version",
"url": "{{base_url}}/templates/{{.Labels.organization}}/{{.Labels.template}}/versions/{{.Labels.version}}"
}
]'::jsonb
WHERE id = 'd089fe7b-d5c5-4c0c-aaf5-689859f7d392';
18 changes: 10 additions & 8 deletions coderd/notifications/notifications_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1074,9 +1074,10 @@ func TestNotificationTemplates_Golden(t *testing.T) {
UserEmail: "bobby@coder.com",
UserUsername: "bobby",
Labels: map[string]string{
"workspace": "bobby-workspace",
"template": "bobby-template",
"version": "alpha",
"workspace": "bobby-workspace",
"template": "bobby-template",
"version": "alpha",
"workspace_owner_username": "mrbobby",
},
},
},
Expand All @@ -1088,11 +1089,12 @@ func TestNotificationTemplates_Golden(t *testing.T) {
UserEmail: "bobby@coder.com",
UserUsername: "bobby",
Labels: map[string]string{
"organization": "bobby-organization",
"initiator": "bobby",
"workspace": "bobby-workspace",
"template": "bobby-template",
"version": "alpha",
"organization": "bobby-organization",
"initiator": "bobby",
"workspace": "bobby-workspace",
"template": "bobby-template",
"version": "alpha",
"workspace_owner_username": "mrbobby",
},
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ The workspace bobby-workspace has been created from the template bobby-temp=
late using version alpha.


View workspace: http://test.com/@bobby/bobby-workspace
View workspace: http://test.com/@mrbobby/bobby-workspace

--bbe61b741255b6098bb6b3c1f41b885773df633cb18d2a3002b68e4bc9c4
Content-Transfer-Encoding: quoted-printable
Expand Down Expand Up @@ -53,9 +53,9 @@ ha</strong>.</p>
</div>
<div style=3D"text-align: center; margin-top: 32px;">
=20
<a href=3D"http://test.com/@bobby/bobby-workspace" style=3D"display=
: inline-block; padding: 13px 24px; background-color: #020617; color: #f8fa=
fc; text-decoration: none; border-radius: 8px; margin: 0 4px;">
<a href=3D"http://test.com/@mrbobby/bobby-workspace" style=3D"displ=
ay: inline-block; padding: 13px 24px; background-color: #020617; color: #f8=
fafc; text-decoration: none; border-radius: 8px; margin: 0 4px;">
View workspace
</a>
=20
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ A new workspace build has been manually created for your workspace bobby-wo=
rkspace by bobby to update it to version alpha of template bobby-template.


View workspace: http://test.com/@bobby/bobby-workspace
View workspace: http://test.com/@mrbobby/bobby-workspace

View template version: http://test.com/templates/bobby-organization/bobby-t=
emplate/versions/alpha
Expand Down Expand Up @@ -57,9 +57,9 @@ g>.</p>
</div>
<div style=3D"text-align: center; margin-top: 32px;">
=20
<a href=3D"http://test.com/@bobby/bobby-workspace" style=3D"display=
: inline-block; padding: 13px 24px; background-color: #020617; color: #f8fa=
fc; text-decoration: none; border-radius: 8px; margin: 0 4px;">
<a href=3D"http://test.com/@mrbobby/bobby-workspace" style=3D"displ=
ay: inline-block; padding: 13px 24px; background-color: #020617; color: #f8=
fafc; text-decoration: none; border-radius: 8px; margin: 0 4px;">
View workspace
</a>
=20
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@
"actions": [
{
"label": "View workspace",
"url": "http://test.com/@bobby/bobby-workspace"
"url": "http://test.com/@mrbobby/bobby-workspace"
}
],
"labels": {
"template": "bobby-template",
"version": "alpha",
"workspace": "bobby-workspace"
"workspace": "bobby-workspace",
"workspace_owner_username": "mrbobby"
},
"data": null,
"targets": null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"actions": [
{
"label": "View workspace",
"url": "http://test.com/@bobby/bobby-workspace"
"url": "http://test.com/@mrbobby/bobby-workspace"
},
{
"label": "View template version",
Expand All @@ -24,7 +24,8 @@
"organization": "bobby-organization",
"template": "bobby-template",
"version": "alpha",
"workspace": "bobby-workspace"
"workspace": "bobby-workspace",
"workspace_owner_username": "mrbobby"
},
"data": null,
"targets": null
Expand Down
11 changes: 6 additions & 5 deletions coderd/workspacebuilds.go
Original file line number Diff line number Diff line change
Expand Up @@ -517,11 +517,12 @@ func (api *API) notifyWorkspaceUpdated(
receiverID,
notifications.TemplateWorkspaceManuallyUpdated,
map[string]string{
"organization": template.OrganizationName,
"initiator": initiator.Name,
"workspace": workspace.Name,
"template": template.Name,
"version": version.Name,
"organization": template.OrganizationName,
"initiator": initiator.Name,
"workspace": workspace.Name,
"template": template.Name,
"version": version.Name,
"workspace_owner_username": owner.Username,
},
map[string]any{
"workspace": map[string]any{"id": workspace.ID, "name": workspace.Name},
Expand Down
7 changes: 4 additions & 3 deletions coderd/workspaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -801,9 +801,10 @@ func (api *API) notifyWorkspaceCreated(
receiverID,
notifications.TemplateWorkspaceCreated,
map[string]string{
"workspace": workspace.Name,
"template": template.Name,
"version": version.Name,
"workspace": workspace.Name,
"template": template.Name,
"version": version.Name,
"workspace_owner_username": owner.Username,
},
map[string]any{
"workspace": map[string]any{"id": workspace.ID, "name": workspace.Name},
Expand Down
Loading