1
+ import { type CSSObject , type Interpolation , type Theme } from "@emotion/react" ;
1
2
import Collapse from "@mui/material/Collapse" ;
2
- import { makeStyles } from "@mui/styles" ;
3
3
import TableCell from "@mui/material/TableCell" ;
4
- import { AuditLog } from "api/typesGenerated" ;
4
+ import type { AuditLog } from "api/typesGenerated" ;
5
5
import { DropdownArrow } from "components/DropdownArrow/DropdownArrow" ;
6
6
import { Pill , type PillType } from "components/Pill/Pill" ;
7
7
import { Stack } from "components/Stack/Stack" ;
@@ -40,7 +40,6 @@ export const AuditLogRow: React.FC<AuditLogRowProps> = ({
40
40
auditLog,
41
41
defaultIsDiffOpen = false ,
42
42
} ) => {
43
- const styles = useStyles ( ) ;
44
43
const [ isDiffOpen , setIsDiffOpen ] = useState ( defaultIsDiffOpen ) ;
45
44
const diffs = Object . entries ( auditLog . diff ) ;
46
45
const shouldDisplayDiff = diffs . length > 0 ;
@@ -65,11 +64,11 @@ export const AuditLogRow: React.FC<AuditLogRowProps> = ({
65
64
data-testid = { `audit-log-row-${ auditLog . id } ` }
66
65
clickable = { shouldDisplayDiff }
67
66
>
68
- < TableCell className = { styles . auditLogCell } >
67
+ < TableCell css = { styles . auditLogCell } >
69
68
< Stack
70
69
direction = "row"
71
70
alignItems = "center"
72
- className = { styles . auditLogHeader }
71
+ css = { styles . auditLogHeader }
73
72
tabIndex = { 0 }
74
73
onClick = { toggle }
75
74
onKeyDown = { ( event ) => {
@@ -81,57 +80,53 @@ export const AuditLogRow: React.FC<AuditLogRowProps> = ({
81
80
< Stack
82
81
direction = "row"
83
82
alignItems = "center"
84
- className = { styles . auditLogHeaderInfo }
83
+ css = { styles . auditLogHeaderInfo }
85
84
>
86
- < Stack
87
- direction = "row"
88
- alignItems = "center"
89
- className = { styles . fullWidth }
90
- >
85
+ < Stack direction = "row" alignItems = "center" css = { styles . fullWidth } >
91
86
< UserAvatar
92
87
username = { auditLog . user ?. username ?? "?" }
93
88
avatarURL = { auditLog . user ?. avatar_url }
94
89
/>
95
90
96
91
< Stack
97
92
alignItems = "baseline"
98
- className = { styles . fullWidth }
93
+ css = { styles . fullWidth }
99
94
justifyContent = "space-between"
100
95
direction = "row"
101
96
>
102
97
< Stack
103
- className = { styles . auditLogSummary }
98
+ css = { styles . auditLogSummary }
104
99
direction = "row"
105
100
alignItems = "baseline"
106
101
spacing = { 1 }
107
102
>
108
103
< AuditLogDescription auditLog = { auditLog } />
109
104
{ auditLog . is_deleted && (
110
- < span className = { styles . deletedLabel } >
105
+ < span css = { styles . deletedLabel } >
111
106
< > (deleted)</ >
112
107
</ span >
113
108
) }
114
- < span className = { styles . auditLogTime } >
109
+ < span css = { styles . auditLogTime } >
115
110
{ new Date ( auditLog . time ) . toLocaleTimeString ( ) }
116
111
</ span >
117
112
</ Stack >
118
113
119
114
< Stack direction = "row" alignItems = "center" >
120
115
< Stack direction = "row" spacing = { 1 } alignItems = "baseline" >
121
116
{ auditLog . ip && (
122
- < span className = { styles . auditLogInfo } >
117
+ < span css = { styles . auditLogInfo } >
123
118
< > IP: </ >
124
119
< strong > { auditLog . ip } </ strong >
125
120
</ span >
126
121
) }
127
122
{ os . name && (
128
- < span className = { styles . auditLogInfo } >
123
+ < span css = { styles . auditLogInfo } >
129
124
< > OS: </ >
130
125
< strong > { os . name } </ strong >
131
126
</ span >
132
127
) }
133
128
{ browser . name && (
134
- < span className = { styles . auditLogInfo } >
129
+ < span css = { styles . auditLogInfo } >
135
130
< > Browser: </ >
136
131
< strong >
137
132
{ browser . name } { browser . version }
@@ -141,7 +136,7 @@ export const AuditLogRow: React.FC<AuditLogRowProps> = ({
141
136
</ Stack >
142
137
143
138
< Pill
144
- className = { styles . httpStatusPill }
139
+ css = { styles . httpStatusPill }
145
140
type = { httpStatusColor ( auditLog . status_code ) }
146
141
text = { auditLog . status_code . toString ( ) }
147
142
/>
@@ -153,7 +148,7 @@ export const AuditLogRow: React.FC<AuditLogRowProps> = ({
153
148
{ shouldDisplayDiff ? (
154
149
< div > { < DropdownArrow close = { isDiffOpen } /> } </ div >
155
150
) : (
156
- < div className = { styles . columnWithoutDiff } > </ div >
151
+ < div css = { styles . columnWithoutDiff } > </ div >
157
152
) }
158
153
</ Stack >
159
154
@@ -167,37 +162,37 @@ export const AuditLogRow: React.FC<AuditLogRowProps> = ({
167
162
) ;
168
163
} ;
169
164
170
- const useStyles = makeStyles ( ( theme ) => ( {
165
+ const styles = {
171
166
auditLogCell : {
172
167
padding : "0 !important" ,
173
168
border : 0 ,
174
169
} ,
175
170
176
- auditLogHeader : {
171
+ auditLogHeader : ( theme ) => ( {
177
172
padding : theme . spacing ( 2 , 4 ) ,
178
- } ,
173
+ } ) ,
179
174
180
175
auditLogHeaderInfo : {
181
176
flex : 1 ,
182
177
} ,
183
178
184
- auditLogSummary : {
185
- ...theme . typography . body1 ,
179
+ auditLogSummary : ( theme ) => ( {
180
+ ...( theme . typography . body1 as CSSObject ) ,
186
181
fontFamily : "inherit" ,
187
- } ,
182
+ } ) ,
188
183
189
- auditLogTime : {
184
+ auditLogTime : ( theme ) => ( {
190
185
color : theme . palette . text . secondary ,
191
186
fontSize : 12 ,
192
- } ,
187
+ } ) ,
193
188
194
- auditLogInfo : {
195
- ...theme . typography . body2 ,
189
+ auditLogInfo : ( theme ) => ( {
190
+ ...( theme . typography . body2 as CSSObject ) ,
196
191
fontSize : 12 ,
197
192
fontFamily : "inherit" ,
198
193
color : theme . palette . text . secondary ,
199
194
display : "block" ,
200
- } ,
195
+ } ) ,
201
196
202
197
// offset the absence of the arrow icon on diff-less logs
203
198
columnWithoutDiff : {
@@ -216,8 +211,8 @@ const useStyles = makeStyles((theme) => ({
216
211
fontWeight : 600 ,
217
212
} ,
218
213
219
- deletedLabel : {
220
- ...theme . typography . caption ,
214
+ deletedLabel : ( theme ) => ( {
215
+ ...( theme . typography . caption as CSSObject ) ,
221
216
color : theme . palette . text . secondary ,
222
- } ,
223
- } ) ) ;
217
+ } ) ,
218
+ } satisfies Record < string , Interpolation < Theme > > ;
0 commit comments