Skip to content

fix: Audit log human parse message and nullable diffs #3978

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 9, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Fix diff values
  • Loading branch information
BrunoQuaresma committed Sep 9, 2022
commit 9e41869c51034a8ddc11ca053fd1e4bb8248df6d
11 changes: 8 additions & 3 deletions site/src/components/AuditLogRow/AuditLogDiff.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,18 @@ import { colors } from "theme/colors"
import { MONOSPACE_FONT_FAMILY } from "theme/constants"
import { combineClasses } from "util/combineClasses"

const getDiffValue = (value: number | string | boolean | null) => {
const getDiffValue = (value: unknown): string => {
if (typeof value === "string") {
return `"${value}"`
}

if (!value) {
return `""`
if (Array.isArray(value)) {
const values = value.map((v) => getDiffValue(v))
return `[${values.join(", ")}]`
}

if (value === null || value === undefined) {
return "null"
}

return value.toString()
Expand Down
5 changes: 5 additions & 0 deletions site/src/testHelpers/entities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -799,5 +799,10 @@ export const MockAuditLog2: TypesGen.AuditLog = {
new: "53bded77-7b9d-4e82-8771-991a34d759f9",
secret: false,
},
roles: {
old: null,
new: ["admin", "auditor"],
secret: false,
},
},
}