1
1
/* eslint-disable @typescript-eslint/no-explicit-any */
2
+ import { Theme } from '@mui/material' ;
2
3
import { MUIDataTableColumn , MUIDataTableMeta } from 'mui-datatables' ;
3
4
import { useRef , useState } from 'react' ;
4
- import { Avatar , Box , Grid , Tooltip , Typography } from '../../base' ;
5
- import { EditIcon , PersonIcon } from '../../icons' ;
5
+ import { Box , Tooltip } from '../../base' ;
6
+ import { EditIcon } from '../../icons' ;
6
7
import Github from '../../icons/Github/GithubIcon' ;
7
8
import Google from '../../icons/Google/GoogleIcon' ;
8
9
import LogoutIcon from '../../icons/Logout/LogOutIcon' ;
9
- import { CHARCOAL , SistentThemeProvider } from '../../theme' ;
10
+ import { CHARCOAL , SistentThemeProviderWithoutBaseLine } from '../../theme' ;
10
11
import { useWindowDimensions } from '../Helpers/Dimension' ;
11
12
import {
12
13
ColView ,
13
14
updateVisibleColumns
14
15
} from '../Helpers/ResponsiveColumns/responsive-coulmns.tsx/responsive-column' ;
15
- import PromptComponent from '../Prompt' ;
16
+ import PromptComponent , { PROMPT_VARIANTS } from '../Prompt' ;
16
17
import ResponsiveDataTable from '../ResponsiveDataTable' ;
17
18
import { TooltipIcon } from '../TooltipIconButton' ;
18
19
import { parseDeletionTimestamp } from '../Workspaces/helper' ;
19
20
import { TableIconsContainer , TableIconsDisabledContainer } from '../Workspaces/styles' ;
20
-
21
+ import UserTableAvatarInfo from './UserTableAvatarInfo' ;
21
22
interface ActionButtonsProps {
22
23
tableMeta : MUIDataTableMeta ;
23
24
isRemoveFromTeamAllowed : boolean ;
24
25
handleRemoveFromTeam : ( data : any [ ] ) => ( ) => void ;
26
+ theme ?: Theme ;
25
27
}
26
28
27
29
const ActionButtons : React . FC < ActionButtonsProps > = ( {
28
30
tableMeta,
29
31
handleRemoveFromTeam,
30
- isRemoveFromTeamAllowed
32
+ isRemoveFromTeamAllowed,
33
+ theme
31
34
} ) => {
32
35
return (
33
36
< div >
@@ -39,12 +42,12 @@ const ActionButtons: React.FC<ActionButtonsProps> = ({
39
42
title = "Remove user membership from team"
40
43
iconType = "delete"
41
44
>
42
- < LogoutIcon fill = { CHARCOAL } secondaryFill = { CHARCOAL } />
45
+ < LogoutIcon fill = { theme ?. palette . icon . default } />
43
46
</ TooltipIcon >
44
47
</ TableIconsContainer >
45
48
) : (
46
49
< TableIconsDisabledContainer >
47
- < LogoutIcon fill = { CHARCOAL } secondaryFill = { CHARCOAL } />
50
+ < LogoutIcon fill = { theme ?. palette . icon . disabled } secondaryFill = { CHARCOAL } />
48
51
</ TableIconsDisabledContainer >
49
52
) }
50
53
</ div >
@@ -58,6 +61,7 @@ interface UsersTableProps {
58
61
useRemoveUserFromTeamMutation : any ;
59
62
useNotificationHandlers : any ;
60
63
isRemoveFromTeamAllowed : boolean ;
64
+ theme ?: Theme ;
61
65
}
62
66
63
67
const UsersTable : React . FC < UsersTableProps > = ( {
@@ -66,7 +70,8 @@ const UsersTable: React.FC<UsersTableProps> = ({
66
70
org_id,
67
71
useRemoveUserFromTeamMutation,
68
72
useNotificationHandlers,
69
- isRemoveFromTeamAllowed
73
+ isRemoveFromTeamAllowed,
74
+ theme
70
75
} ) => {
71
76
const [ page , setPage ] = useState < number > ( 0 ) ;
72
77
const [ pageSize , setPageSize ] = useState < number > ( 10 ) ;
@@ -75,7 +80,6 @@ const UsersTable: React.FC<UsersTableProps> = ({
75
80
const availableRoles : string [ ] = [ ] ;
76
81
const { handleError, handleSuccess, handleInfo } = useNotificationHandlers ( ) ;
77
82
const ref : any = useRef ( null ) ;
78
-
79
83
const { width } = useWindowDimensions ( ) ;
80
84
81
85
const { data : userData } = useGetUsersForOrgQuery ( {
@@ -98,7 +102,8 @@ const UsersTable: React.FC<UsersTableProps> = ({
98
102
const response = await ref . current ?. show ( {
99
103
title : `Remove User From Team ?` ,
100
104
subtitle : removeUserFromTeamModalContent ( data [ 3 ] , data [ 2 ] ) ,
101
- primaryOption : 'Proceed'
105
+ primaryOption : 'Proceed' ,
106
+ variant : PROMPT_VARIANTS . DANGER
102
107
} ) ;
103
108
if ( response === 'Proceed' ) {
104
109
removeUserFromTeam ( {
@@ -127,20 +132,6 @@ const UsersTable: React.FC<UsersTableProps> = ({
127
132
return rowData [ columnIndex ] ;
128
133
} ;
129
134
130
- // const fetchAvailableRoles = () => {
131
- // axios
132
- // .get(process.env.API_ENDPOINT_PREFIX + `/api/identity/orgs/${org_id}/roles?all=true`)
133
- // .then((res) => {
134
- // let roles = [];
135
- // res?.data?.roles?.forEach((role) => roles.push(role?.role_name));
136
- // setAvailableRoles(roles);
137
- // })
138
- // .catch((err) => {
139
- // let error = err.response?.data?.message || 'Failed to fetch roles';
140
- // handleError(error);
141
- // });
142
- // };
143
-
144
135
const removeUserFromTeamModalContent = ( user : string , email : string ) => (
145
136
< >
146
137
< p > Are you sure you want to remove this user? (This action is irreversible)</ p >
@@ -253,29 +244,12 @@ const UsersTable: React.FC<UsersTableProps> = ({
253
244
searchable : false ,
254
245
customBodyRender : ( value : string , tableMeta : MUIDataTableMeta ) => (
255
246
< Box sx = { { '& > img' : { mr : 2 , flexShrink : 0 } } } >
256
- < Grid container alignItems = "center" >
257
- < Grid item >
258
- < Box sx = { { color : 'text.secondary' , mr : 2 } } >
259
- < Avatar
260
- onClick = { ( ) => {
261
- window . open (
262
- `/user/${ getValidColumnValue ( tableMeta . rowData , 'user_id' , columns ) } `
263
- ) ;
264
- } }
265
- alt = { getValidColumnValue ( tableMeta . rowData , 'first_name' , columns ) }
266
- src = { value }
267
- >
268
- { value ? '' : < PersonIcon /> }
269
- </ Avatar >
270
- </ Box >
271
- </ Grid >
272
- < Grid item xs >
273
- { tableMeta . rowData [ 4 ] } { tableMeta . rowData [ 5 ] }
274
- < Typography variant = "body2" color = "text.secondary" >
275
- { tableMeta . rowData [ 2 ] }
276
- </ Typography >
277
- </ Grid >
278
- </ Grid >
247
+ < UserTableAvatarInfo
248
+ userId = { getValidColumnValue ( tableMeta . rowData , 'user_id' , columns ) }
249
+ userName = { `${ tableMeta . rowData [ 4 ] } ${ tableMeta . rowData [ 5 ] } ` }
250
+ userEmail = { tableMeta . rowData [ 2 ] }
251
+ profileUrl = { value }
252
+ />
279
253
</ Box >
280
254
)
281
255
}
@@ -440,6 +414,7 @@ const UsersTable: React.FC<UsersTableProps> = ({
440
414
tableMeta = { tableMeta }
441
415
handleRemoveFromTeam = { handleRemoveFromTeam }
442
416
isRemoveFromTeamAllowed = { isRemoveFromTeamAllowed }
417
+ theme = { theme }
443
418
/>
444
419
)
445
420
}
@@ -457,9 +432,8 @@ const UsersTable: React.FC<UsersTableProps> = ({
457
432
} ) ;
458
433
return initialVisibility ;
459
434
} ) ;
460
-
461
435
return (
462
- < SistentThemeProvider >
436
+ < SistentThemeProviderWithoutBaseLine initialMode = { theme ?. palette . mode } >
463
437
< div style = { { margin : 'auto' , width : '100%' } } >
464
438
< ResponsiveDataTable
465
439
columns = { columns }
@@ -469,10 +443,11 @@ const UsersTable: React.FC<UsersTableProps> = ({
469
443
tableCols = { tableCols }
470
444
updateCols = { updateCols }
471
445
columnVisibility = { columnVisibility }
446
+ backgroundColor = { theme ?. palette . background . tabs }
472
447
/>
473
448
</ div >
474
449
< PromptComponent ref = { ref } />
475
- </ SistentThemeProvider >
450
+ </ SistentThemeProviderWithoutBaseLine >
476
451
) ;
477
452
} ;
478
453
0 commit comments