@@ -3,55 +3,19 @@ import { AuditLog } from "api/typesGenerated"
33import { Link as RouterLink } from "react-router-dom"
44import Link from "@material-ui/core/Link"
55import { 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"
448
459export const AuditLogDescription : FC < { auditLog : AuditLog } > = ( {
4610 auditLog,
4711} ) : JSX . Element => {
4812 const classes = useStyles ( )
49- const { t } = i18next
13+ const { t } = useTranslation ( "auditLog" )
5014
5115 const target = auditLog . resource_target . trim ( )
5216 const user = auditLog . user
5317 ? auditLog . user . username . trim ( )
54- : t ( "auditLog: table.logRow.unknownUser" )
18+ : t ( "table.logRow.unknownUser" )
5519
5620 if ( auditLog . resource_type === "workspace_build" ) {
5721 return < BuildAuditDescription auditLog = { auditLog } />
@@ -72,6 +36,21 @@ export const AuditLogDescription: FC<{ auditLog: AuditLog }> = ({
7236 . replace ( "{user}" , `${ user } ` )
7337 . replace ( "{target}" , "" )
7438
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+
7554 return (
7655 < span >
7756 { truncatedDescription }
@@ -84,7 +63,7 @@ export const AuditLogDescription: FC<{ auditLog: AuditLog }> = ({
8463 ) }
8564 { auditLog . is_deleted && (
8665 < span className = { classes . deletedLabel } >
87- < > { t ( "auditLog: table.logRow.deletedLabel" ) } </ >
66+ < > { t ( "table.logRow.deletedLabel" ) } </ >
8867 </ span >
8968 ) }
9069 { /* logs for workspaces created on behalf of other users indicate ownership in the description */ }
@@ -94,7 +73,7 @@ export const AuditLogDescription: FC<{ auditLog: AuditLog }> = ({
9473 auditLog . user ?. username && (
9574 < span >
9675 < >
97- { t ( "auditLog: table.logRow.onBehalfOf" , {
76+ { t ( "table.logRow.onBehalfOf" , {
9877 owner : auditLog . additional_fields . workspace_owner ,
9978 } ) }
10079 </ >
0 commit comments