mirror of
https://github.com/coder/coder.git
synced 2025-07-09 11:45:56 +00:00
fix(site): delete workspace action in audit log (#8494)
This commit is contained in:
@ -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 (
|
||||
|
@ -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({})
|
||||
|
Reference in New Issue
Block a user