@@ -7,7 +7,6 @@ import { CloseDropdown, OpenDropdown } from "components/DropdownArrows/DropdownA
7
7
import { Pill } from "components/Pill/Pill"
8
8
import { Stack } from "components/Stack/Stack"
9
9
import { UserAvatar } from "components/UserAvatar/UserAvatar"
10
- import { t } from "i18next"
11
10
import { ComponentProps , useState } from "react"
12
11
import { MONOSPACE_FONT_FAMILY } from "theme/constants"
13
12
import userAgentParser from "ua-parser-js"
@@ -26,26 +25,10 @@ const pillTypeByHttpStatus = (httpStatus: number): ComponentProps<typeof Pill>["
26
25
return "success"
27
26
}
28
27
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
-
45
28
const 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>` )
49
32
}
50
33
51
34
export interface AuditLogRowProps {
@@ -98,10 +81,10 @@ export const AuditLogRow: React.FC<AuditLogRowProps> = ({
98
81
avatarURL = { auditLog . user ?. avatar_url }
99
82
/>
100
83
< 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
+ / >
105
88
< span className = { styles . auditLogTime } > { createDayString ( auditLog . time ) } </ span >
106
89
</ div >
107
90
</ Stack >
0 commit comments