mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
feat: amending audit string to show workspace owner (#5364)
* resolves #5269 * clean up * fixed audit link
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import {
|
||||
MockAuditLog,
|
||||
MockAuditLogWithWorkspaceBuild,
|
||||
MockWorkspaceCreateAuditLogForDifferentOwner,
|
||||
} from "testHelpers/entities"
|
||||
import { AuditLogDescription } from "./AuditLogDescription"
|
||||
import { render } from "../../testHelpers/renderHelpers"
|
||||
@@ -46,4 +47,16 @@ describe("AuditLogDescription", () => {
|
||||
getByTextContent("TestUser stopped build for workspace workspace"),
|
||||
).toBeDefined()
|
||||
})
|
||||
it("renders the correct string for a workspace created for a different owner", async () => {
|
||||
render(
|
||||
<AuditLogDescription
|
||||
auditLog={MockWorkspaceCreateAuditLogForDifferentOwner}
|
||||
/>,
|
||||
)
|
||||
expect(
|
||||
getByTextContent(
|
||||
`TestUser created workspace bruno-dev on behalf of ${MockWorkspaceCreateAuditLogForDifferentOwner.additional_fields.workspaceOwner}`,
|
||||
),
|
||||
).toBeDefined()
|
||||
})
|
||||
})
|
||||
|
||||
@@ -45,9 +45,20 @@ export const AuditLogDescription: FC<{ auditLog: AuditLog }> = ({
|
||||
)}
|
||||
{auditLog.is_deleted && (
|
||||
<span className={classes.deletedLabel}>
|
||||
<> {t("auditLog:table.logRow.deletedLabel")}</>
|
||||
<>{t("auditLog:table.logRow.deletedLabel")}</>
|
||||
</span>
|
||||
)}
|
||||
{/* logs for workspaces created on behalf of other users indicate ownership in the description */}
|
||||
{auditLog.additional_fields.workspaceOwner &&
|
||||
auditLog.additional_fields.workspaceOwner !== "unknown" && (
|
||||
<span>
|
||||
<>
|
||||
{t("auditLog:table.logRow.onBehalfOf", {
|
||||
owner: auditLog.additional_fields.workspaceOwner,
|
||||
})}
|
||||
</>
|
||||
</span>
|
||||
)}
|
||||
</span>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -8,11 +8,12 @@
|
||||
"emptyPage": "No audit logs available on this page",
|
||||
"noLogs": "No audit logs available",
|
||||
"logRow": {
|
||||
"deletedLabel": "(deleted)",
|
||||
"deletedLabel": " (deleted)",
|
||||
"ip": "IP: ",
|
||||
"os": "OS: ",
|
||||
"browser": "Browser: ",
|
||||
"notAvailable": "Not available"
|
||||
"notAvailable": "Not available",
|
||||
"onBehalfOf": " on behalf of {{owner}}"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1020,6 +1020,13 @@ export const MockAuditLog2: TypesGen.AuditLog = {
|
||||
},
|
||||
}
|
||||
|
||||
export const MockWorkspaceCreateAuditLogForDifferentOwner = {
|
||||
...MockAuditLog,
|
||||
additional_fields: {
|
||||
workspaceOwner: "Member",
|
||||
},
|
||||
}
|
||||
|
||||
export const MockAuditLogWithWorkspaceBuild: TypesGen.AuditLog = {
|
||||
...MockAuditLog,
|
||||
id: "f90995bf-4a2b-4089-b597-e66e025e523e",
|
||||
|
||||
Reference in New Issue
Block a user