fix(site): delete workspace action in audit log (#8494)

This commit is contained in:
Marcin Tojek
2023-07-13 14:43:10 +02:00
committed by GitHub
parent 24ec05b5c5
commit ebdc510f12
2 changed files with 36 additions and 5 deletions

View File

@ -10,14 +10,25 @@ export const BuildAuditDescription: FC<{ auditLog: AuditLog }> = ({
const { t } = useTranslation("auditLog")
const workspaceName = auditLog.additional_fields?.workspace_name?.trim()
// workspaces can be started/stopped by a user, or kicked off automatically by Coder
// workspaces can be started/stopped/deleted by a user, or kicked off automatically by Coder
const user =
auditLog.additional_fields?.build_reason &&
auditLog.additional_fields?.build_reason !== "initiator"
? "Coder automatically"
: auditLog.user?.username.trim()
const action = auditLog.action === "start" ? "started" : "stopped"
const action: string = (() => {
switch (auditLog.action) {
case "start":
return "started"
case "stop":
return "stopped"
case "delete":
return "deleted"
default:
return auditLog.action
}
})()
if (auditLog.resource_link) {
return (

View File

@ -64,9 +64,29 @@ WithLongDiffRow.args = {
defaultIsDiffOpen: true,
}
export const WithWorkspaceBuild = Template.bind({})
WithWorkspaceBuild.args = {
auditLog: MockAuditLogWithWorkspaceBuild,
export const WithStoppedWorkspaceBuild = Template.bind({})
WithStoppedWorkspaceBuild.args = {
auditLog: {
...MockAuditLogWithWorkspaceBuild,
action: "stop",
},
}
export const WithStartedWorkspaceBuild = Template.bind({})
WithStartedWorkspaceBuild.args = {
auditLog: {
...MockAuditLogWithWorkspaceBuild,
action: "start",
},
}
export const WithDeletedWorkspaceBuild = Template.bind({})
WithDeletedWorkspaceBuild.args = {
auditLog: {
...MockAuditLogWithWorkspaceBuild,
action: "delete",
is_deleted: true,
},
}
export const DeletedResource = Template.bind({})