1
- import type { Interpolation , Theme } from "@emotion/react" ;
2
1
import UserIcon from "@mui/icons-material/PersonOutline" ;
3
2
import Checkbox from "@mui/material/Checkbox" ;
4
- import IconButton from "@mui/material/IconButton" ;
5
3
import Tooltip from "@mui/material/Tooltip" ;
6
4
import type { SlimRole } from "api/typesGenerated" ;
5
+ import { Button } from "components/Button/Button" ;
7
6
import {
8
7
HelpTooltip ,
9
8
HelpTooltipContent ,
@@ -12,13 +11,11 @@ import {
12
11
HelpTooltipTrigger ,
13
12
} from "components/HelpTooltip/HelpTooltip" ;
14
13
import { EditSquare } from "components/Icons/EditSquare" ;
15
- import { Stack } from "components/Stack/Stack" ;
16
14
import {
17
15
Popover ,
18
16
PopoverContent ,
19
17
PopoverTrigger ,
20
18
} from "components/deprecated/Popover/Popover" ;
21
- import { type ClassName , useClassName } from "hooks/useClassName" ;
22
19
import type { FC } from "react" ;
23
20
24
21
const roleDescriptions : Record < string , string > = {
@@ -47,23 +44,23 @@ const Option: FC<OptionProps> = ({
47
44
onChange,
48
45
} ) => {
49
46
return (
50
- < label htmlFor = { name } css = { styles . option } >
51
- < Stack direction = "row" alignItems = " flex-start">
47
+ < label htmlFor = { name } className = "cursor-pointer" >
48
+ < div className = " flex items -start gap-4 ">
52
49
< Checkbox
53
50
id = { name }
54
51
size = "small"
55
- css = { styles . checkbox }
52
+ className = "p-0 relative top-px"
56
53
value = { value }
57
54
checked = { isChecked }
58
55
onChange = { ( e ) => {
59
56
onChange ( e . currentTarget . value ) ;
60
57
} }
61
58
/>
62
- < Stack spacing = { 0 } >
59
+ < div className = "flex flex-col" >
63
60
< strong > { name } </ strong >
64
- < span css = { styles . optionDescription } > { description } </ span >
65
- </ Stack >
66
- </ Stack >
61
+ < span className = "text-xs text-content-secondary" > { description } </ span >
62
+ </ div >
63
+ </ div >
67
64
</ label >
68
65
) ;
69
66
} ;
@@ -85,8 +82,6 @@ export const EditRolesButton: FC<EditRolesButtonProps> = ({
85
82
userLoginType,
86
83
oidcRoleSync,
87
84
} ) => {
88
- const paper = useClassName ( classNames . paper , [ ] ) ;
89
-
90
85
const handleChange = ( roleName : string ) => {
91
86
if ( selectedRoleNames . has ( roleName ) ) {
92
87
const serialized = [ ...selectedRoleNames ] ;
@@ -118,23 +113,24 @@ export const EditRolesButton: FC<EditRolesButtonProps> = ({
118
113
< Popover >
119
114
< PopoverTrigger >
120
115
< Tooltip title = "Edit user roles" >
121
- < IconButton
116
+ < Button
117
+ variant = "subtle"
122
118
aria-label = "Edit user roles"
123
- size = "small "
124
- css = { styles . editButton }
119
+ size = "icon "
120
+ className = "text-content-secondary hover:text-content-primary"
125
121
>
126
122
< EditSquare />
127
- </ IconButton >
123
+ </ Button >
128
124
</ Tooltip >
129
125
</ PopoverTrigger >
130
126
131
- < PopoverContent classes = { { paper } } disablePortal = { false } >
127
+ < PopoverContent className = "w-80" disablePortal = { false } >
132
128
< fieldset
133
- css = { styles . fieldset }
129
+ className = "border-0 m-0 p-0 disabled:opacity-50"
134
130
disabled = { isLoading }
135
131
title = "Available roles"
136
132
>
137
- < Stack css = { styles . options } spacing = { 3 } >
133
+ < div className = "flex flex-col gap-4 p-6" >
138
134
{ roles . map ( ( role ) => (
139
135
< Option
140
136
key = { role . name }
@@ -145,88 +141,20 @@ export const EditRolesButton: FC<EditRolesButtonProps> = ({
145
141
description = { roleDescriptions [ role . name ] ?? "" }
146
142
/>
147
143
) ) }
148
- </ Stack >
144
+ </ div >
149
145
</ fieldset >
150
- < div css = { styles . footer } >
151
- < Stack direction = "row" alignItems = " flex-start ">
152
- < UserIcon css = { styles . userIcon } />
153
- < Stack spacing = { 0 } >
146
+ < div className = "p-6 border-t-1 border-solid border-border text-sm" >
147
+ < div className = " flex gap-4 ">
148
+ < UserIcon className = "size-icon-sm" />
149
+ < div className = "flex flex-col" >
154
150
< strong > Member</ strong >
155
- < span css = { styles . optionDescription } >
151
+ < span className = "text-xs text-content-secondary" >
156
152
{ roleDescriptions . member }
157
153
</ span >
158
- </ Stack >
159
- </ Stack >
154
+ </ div >
155
+ </ div >
160
156
</ div >
161
157
</ PopoverContent >
162
158
</ Popover >
163
159
) ;
164
160
} ;
165
-
166
- const classNames = {
167
- paper : ( css , theme ) => css `
168
- width : 360px ;
169
- margin-top : 8px ;
170
- background : ${ theme . palette . background . paper } ;
171
- ` ,
172
- } satisfies Record < string , ClassName > ;
173
-
174
- const styles = {
175
- editButton : ( theme ) => ( {
176
- color : theme . palette . text . secondary ,
177
-
178
- "& .MuiSvgIcon-root" : {
179
- width : 16 ,
180
- height : 16 ,
181
- position : "relative" ,
182
- top : - 2 , // Align the pencil square
183
- } ,
184
-
185
- "&:hover" : {
186
- color : theme . palette . text . primary ,
187
- backgroundColor : "transparent" ,
188
- } ,
189
- } ) ,
190
- fieldset : {
191
- border : 0 ,
192
- margin : 0 ,
193
- padding : 0 ,
194
-
195
- "&:disabled" : {
196
- opacity : 0.5 ,
197
- } ,
198
- } ,
199
- options : {
200
- padding : 24 ,
201
- } ,
202
- option : {
203
- cursor : "pointer" ,
204
- fontSize : 14 ,
205
- } ,
206
- checkbox : {
207
- padding : 0 ,
208
- position : "relative" ,
209
- top : 1 , // Alignment
210
-
211
- "& svg" : {
212
- width : 20 ,
213
- height : 20 ,
214
- } ,
215
- } ,
216
- optionDescription : ( theme ) => ( {
217
- fontSize : 13 ,
218
- color : theme . palette . text . secondary ,
219
- lineHeight : "160%" ,
220
- } ) ,
221
- footer : ( theme ) => ( {
222
- padding : 24 ,
223
- backgroundColor : theme . palette . background . paper ,
224
- borderTop : `1px solid ${ theme . palette . divider } ` ,
225
- fontSize : 14 ,
226
- } ) ,
227
- userIcon : ( theme ) => ( {
228
- width : 20 , // Same as the checkbox
229
- height : 20 ,
230
- color : theme . palette . primary . main ,
231
- } ) ,
232
- } satisfies Record < string , Interpolation < Theme > > ;
0 commit comments