Skip to content

Commit ebdc510

Browse files
authored
fix(site): delete workspace action in audit log (#8494)
1 parent 24ec05b commit ebdc510

File tree

2 files changed

+36
-5
lines changed

2 files changed

+36
-5
lines changed

site/src/components/AuditLogRow/AuditLogDescription/BuildAuditDescription.tsx

+13-2
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,25 @@ export const BuildAuditDescription: FC<{ auditLog: AuditLog }> = ({
1010
const { t } = useTranslation("auditLog")
1111

1212
const workspaceName = auditLog.additional_fields?.workspace_name?.trim()
13-
// workspaces can be started/stopped by a user, or kicked off automatically by Coder
13+
// workspaces can be started/stopped/deleted by a user, or kicked off automatically by Coder
1414
const user =
1515
auditLog.additional_fields?.build_reason &&
1616
auditLog.additional_fields?.build_reason !== "initiator"
1717
? "Coder automatically"
1818
: auditLog.user?.username.trim()
1919

20-
const action = auditLog.action === "start" ? "started" : "stopped"
20+
const action: string = (() => {
21+
switch (auditLog.action) {
22+
case "start":
23+
return "started"
24+
case "stop":
25+
return "stopped"
26+
case "delete":
27+
return "deleted"
28+
default:
29+
return auditLog.action
30+
}
31+
})()
2132

2233
if (auditLog.resource_link) {
2334
return (

site/src/components/AuditLogRow/AuditLogRow.stories.tsx

+23-3
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,29 @@ WithLongDiffRow.args = {
6464
defaultIsDiffOpen: true,
6565
}
6666

67-
export const WithWorkspaceBuild = Template.bind({})
68-
WithWorkspaceBuild.args = {
69-
auditLog: MockAuditLogWithWorkspaceBuild,
67+
export const WithStoppedWorkspaceBuild = Template.bind({})
68+
WithStoppedWorkspaceBuild.args = {
69+
auditLog: {
70+
...MockAuditLogWithWorkspaceBuild,
71+
action: "stop",
72+
},
73+
}
74+
75+
export const WithStartedWorkspaceBuild = Template.bind({})
76+
WithStartedWorkspaceBuild.args = {
77+
auditLog: {
78+
...MockAuditLogWithWorkspaceBuild,
79+
action: "start",
80+
},
81+
}
82+
83+
export const WithDeletedWorkspaceBuild = Template.bind({})
84+
WithDeletedWorkspaceBuild.args = {
85+
auditLog: {
86+
...MockAuditLogWithWorkspaceBuild,
87+
action: "delete",
88+
is_deleted: true,
89+
},
7090
}
7191

7292
export const DeletedResource = Template.bind({})

0 commit comments

Comments
 (0)