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 { t } = useTranslation("auditLog")
|
||||||
|
|
||||||
const workspaceName = auditLog.additional_fields?.workspace_name?.trim()
|
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 =
|
const user =
|
||||||
auditLog.additional_fields?.build_reason &&
|
auditLog.additional_fields?.build_reason &&
|
||||||
auditLog.additional_fields?.build_reason !== "initiator"
|
auditLog.additional_fields?.build_reason !== "initiator"
|
||||||
? "Coder automatically"
|
? "Coder automatically"
|
||||||
: auditLog.user?.username.trim()
|
: 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) {
|
if (auditLog.resource_link) {
|
||||||
return (
|
return (
|
||||||
|
@ -64,9 +64,29 @@ WithLongDiffRow.args = {
|
|||||||
defaultIsDiffOpen: true,
|
defaultIsDiffOpen: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
export const WithWorkspaceBuild = Template.bind({})
|
export const WithStoppedWorkspaceBuild = Template.bind({})
|
||||||
WithWorkspaceBuild.args = {
|
WithStoppedWorkspaceBuild.args = {
|
||||||
auditLog: MockAuditLogWithWorkspaceBuild,
|
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({})
|
export const DeletedResource = Template.bind({})
|
||||||
|
Reference in New Issue
Block a user