@@ -7,7 +7,6 @@ import { CloseDropdown, OpenDropdown } from "components/DropdownArrows/DropdownA
77import { Pill } from "components/Pill/Pill"
88import { Stack } from "components/Stack/Stack"
99import { UserAvatar } from "components/UserAvatar/UserAvatar"
10- import { t } from "i18next"
1110import { ComponentProps , useState } from "react"
1211import { MONOSPACE_FONT_FAMILY } from "theme/constants"
1312import userAgentParser from "ua-parser-js"
@@ -26,26 +25,10 @@ const pillTypeByHttpStatus = (httpStatus: number): ComponentProps<typeof Pill>["
2625 return "success"
2726}
2827
29- const actionLabelByAction : Record < AuditLog [ "action" ] , string > = {
30- create : t ( "actions.create" , { ns : "auditLog" } ) ,
31- write : t ( "actions.write" , { ns : "auditLog" } ) ,
32- delete : t ( "actions.delete" , { ns : "auditLog" } ) ,
33- }
34-
35- const resourceLabelByResourceType : Record < AuditLog [ "resource_type" ] , string > = {
36- organization : "organization" ,
37- template : "template" ,
38- template_version : "template version" ,
39- user : "user" ,
40- workspace : "workspace" ,
41- git_ssh_key : "git ssh key" ,
42- api_key : "api key" ,
43- }
44-
4528const readableActionMessage = ( auditLog : AuditLog ) => {
46- return ` ${ actionLabelByAction [ auditLog . action ] } ${
47- resourceLabelByResourceType [ auditLog . resource_type ]
48- } `
29+ return auditLog . description
30+ . replace ( "{user}" , `<strong> ${ auditLog . user ?. username } </strong>` )
31+ . replace ( "{target}" , `<strong> ${ auditLog . resource_target } </strong>` )
4932}
5033
5134export interface AuditLogRowProps {
@@ -98,10 +81,10 @@ export const AuditLogRow: React.FC<AuditLogRowProps> = ({
9881 avatarURL = { auditLog . user ?. avatar_url }
9982 />
10083 < div >
101- < span className = { styles . auditLogResume } >
102- < strong > { auditLog . user ?. username } </ strong > { readableActionMessage ( auditLog ) } { " " }
103- < strong > { auditLog . resource_target } </ strong >
104- </ span >
84+ < span
85+ className = { styles . auditLogResume }
86+ dangerouslySetInnerHTML = { { __html : readableActionMessage ( auditLog ) } }
87+ / >
10588 < span className = { styles . auditLogTime } > { createDayString ( auditLog . time ) } </ span >
10689 </ div >
10790 </ Stack >
0 commit comments