1
1
import Collapse from "@material-ui/core/Collapse"
2
- import Link from "@material-ui/core/Link"
3
2
import { makeStyles } from "@material-ui/core/styles"
4
3
import TableCell from "@material-ui/core/TableCell"
5
4
import TableRow from "@material-ui/core/TableRow"
6
- import { AuditLog , Template , Workspace } from "api/typesGenerated"
5
+ import { AuditLog } from "api/typesGenerated"
7
6
import { CloseDropdown , OpenDropdown } from "components/DropdownArrows/DropdownArrows"
8
7
import { Pill } from "components/Pill/Pill"
9
8
import { Stack } from "components/Stack/Stack"
10
9
import { UserAvatar } from "components/UserAvatar/UserAvatar"
11
10
import { t } from "i18next"
12
11
import { ComponentProps , useState } from "react"
13
- import { Link as RouterLink } from "react-router-dom"
14
12
import { createDayString } from "util/createDayString"
15
13
import { AuditLogDiff } from "./AuditLogDiff"
16
14
@@ -26,48 +24,6 @@ const pillTypeByHttpStatus = (httpStatus: number): ComponentProps<typeof Pill>["
26
24
return "success"
27
25
}
28
26
29
- const getResourceLabel = ( resource : AuditLog [ "resource" ] ) : string => {
30
- if ( "name" in resource ) {
31
- return resource . name
32
- }
33
-
34
- return resource . username
35
- }
36
-
37
- const getResourceHref = (
38
- resource : AuditLog [ "resource" ] ,
39
- resourceType : AuditLog [ "resource_type" ] ,
40
- ) : string | undefined => {
41
- switch ( resourceType ) {
42
- case "user" :
43
- return `/users`
44
- case "template" :
45
- return `/templates/${ ( resource as Template ) . name } `
46
- case "workspace" :
47
- return `/workspaces/@${ ( resource as Workspace ) . owner_name } /${ ( resource as Workspace ) . name } `
48
- case "organization" :
49
- return
50
- }
51
- }
52
-
53
- const ResourceLink : React . FC < {
54
- resource : AuditLog [ "resource" ]
55
- resourceType : AuditLog [ "resource_type" ]
56
- } > = ( { resource, resourceType } ) => {
57
- const href = getResourceHref ( resource , resourceType )
58
- const label = < strong > { getResourceLabel ( resource ) } </ strong >
59
-
60
- if ( ! href ) {
61
- return label
62
- }
63
-
64
- return (
65
- < Link component = { RouterLink } to = { href } >
66
- { label }
67
- </ Link >
68
- )
69
- }
70
-
71
27
const actionLabelByAction : Record < AuditLog [ "action" ] , string > = {
72
28
create : t ( "actions.create" , { ns : "auditLog" } ) ,
73
29
write : t ( "actions.write" , { ns : "auditLog" } ) ,
@@ -140,10 +96,7 @@ export const AuditLogRow: React.FC<AuditLogRowProps> = ({
140
96
< div >
141
97
< span className = { styles . auditLogResume } >
142
98
< strong > { auditLog . user ?. username } </ strong > { readableActionMessage ( auditLog ) } { " " }
143
- < ResourceLink
144
- resource = { auditLog . resource }
145
- resourceType = { auditLog . resource_type }
146
- />
99
+ < strong > { auditLog . resource_target } </ strong >
147
100
</ span >
148
101
< span className = { styles . auditLogTime } > { createDayString ( auditLog . time ) } </ span >
149
102
</ div >
0 commit comments