@@ -3,55 +3,19 @@ import { AuditLog } from "api/typesGenerated"
3
3
import { Link as RouterLink } from "react-router-dom"
4
4
import Link from "@material-ui/core/Link"
5
5
import { makeStyles } from "@material-ui/core/styles"
6
- import i18next from "i18next"
7
-
8
- const BuildAuditDescription : FC < { auditLog : AuditLog } > = ( {
9
- auditLog,
10
- } ) : JSX . Element => {
11
- const { t } = i18next
12
-
13
- // audit logs with a resource_type of workspace build use workspace name as a target
14
- const target = auditLog . additional_fields ?. workspace_name ?. trim ( )
15
- // workspaces can be started/stopped by a user, or kicked off automatically by Coder
16
- const user =
17
- auditLog . additional_fields ?. build_reason &&
18
- auditLog . additional_fields ?. build_reason !== "initiator"
19
- ? t ( "auditLog:table.logRow.buildReason" )
20
- : auditLog . user ?. username . trim ( )
21
-
22
- const actionVerb =
23
- auditLog . action === "start"
24
- ? t ( "auditLog:table.logRow.started" )
25
- : t ( "auditLog:table.logRow.stopped" )
26
-
27
- return (
28
- < span >
29
- < >
30
- { user } { " " }
31
- { auditLog . resource_link ? (
32
- < Link component = { RouterLink } to = { auditLog . resource_link } >
33
- < strong > { actionVerb } </ strong >
34
- </ Link >
35
- ) : (
36
- { actionVerb }
37
- ) } { " " }
38
- { t ( "auditLog:table.logRow.workspace" ) }
39
- < strong > { target } </ strong >
40
- </ >
41
- </ span >
42
- )
43
- }
6
+ import { useTranslation } from "react-i18next"
7
+ import { BuildAuditDescription } from "./BuildAuditDescription"
44
8
45
9
export const AuditLogDescription : FC < { auditLog : AuditLog } > = ( {
46
10
auditLog,
47
11
} ) : JSX . Element => {
48
12
const classes = useStyles ( )
49
- const { t } = i18next
13
+ const { t } = useTranslation ( "auditLog" )
50
14
51
15
const target = auditLog . resource_target . trim ( )
52
16
const user = auditLog . user
53
17
? auditLog . user . username . trim ( )
54
- : t ( "auditLog: table.logRow.unknownUser" )
18
+ : t ( "table.logRow.unknownUser" )
55
19
56
20
if ( auditLog . resource_type === "workspace_build" ) {
57
21
return < BuildAuditDescription auditLog = { auditLog } />
@@ -72,6 +36,21 @@ export const AuditLogDescription: FC<{ auditLog: AuditLog }> = ({
72
36
. replace ( "{user}" , `${ user } ` )
73
37
. replace ( "{target}" , "" )
74
38
39
+ // return (
40
+ // <span>
41
+ // <Trans
42
+ // t={t}
43
+ // i18nKey="table.logRow.auditDescription"
44
+ // values={{ truncatedDescription, target }}
45
+ // >
46
+ // {"{{truncatedDescription}}" }
47
+ // <Link component={RouterLink} to={auditLog.resource_link}>
48
+ // <strong>{"{{target}}" }</strong>
49
+ // </Link>
50
+ // </Trans>
51
+ // </span>
52
+ // )
53
+
75
54
return (
76
55
< span >
77
56
{ truncatedDescription }
@@ -84,7 +63,7 @@ export const AuditLogDescription: FC<{ auditLog: AuditLog }> = ({
84
63
) }
85
64
{ auditLog . is_deleted && (
86
65
< span className = { classes . deletedLabel } >
87
- < > { t ( "auditLog: table.logRow.deletedLabel" ) } </ >
66
+ < > { t ( "table.logRow.deletedLabel" ) } </ >
88
67
</ span >
89
68
) }
90
69
{ /* logs for workspaces created on behalf of other users indicate ownership in the description */ }
@@ -94,7 +73,7 @@ export const AuditLogDescription: FC<{ auditLog: AuditLog }> = ({
94
73
auditLog . user ?. username && (
95
74
< span >
96
75
< >
97
- { t ( "auditLog: table.logRow.onBehalfOf" , {
76
+ { t ( "table.logRow.onBehalfOf" , {
98
77
owner : auditLog . additional_fields . workspace_owner ,
99
78
} ) }
100
79
</ >
0 commit comments