1
- import Skeleton from "@mui/material/Skeleton" ;
2
1
import Table from "@mui/material/Table" ;
3
2
import TableBody from "@mui/material/TableBody" ;
4
3
import TableCell from "@mui/material/TableCell" ;
@@ -12,6 +11,14 @@ import type {
12
11
import { ErrorAlert } from "components/Alert/ErrorAlert" ;
13
12
import { Button } from "components/Button/Button" ;
14
13
import { ChooseOne , Cond } from "components/Conditionals/ChooseOne" ;
14
+ import {
15
+ Dialog ,
16
+ DialogContent ,
17
+ DialogDescription ,
18
+ DialogFooter ,
19
+ DialogHeader ,
20
+ DialogTitle ,
21
+ } from "components/Dialog/Dialog" ;
15
22
import { EmptyState } from "components/EmptyState/EmptyState" ;
16
23
import {
17
24
HelpTooltip ,
@@ -26,10 +33,6 @@ import {
26
33
type Option ,
27
34
} from "components/MultiSelectCombobox/MultiSelectCombobox" ;
28
35
import { Switch } from "components/Switch/Switch" ;
29
- import {
30
- TableLoaderSkeleton ,
31
- TableRowSkeleton ,
32
- } from "components/TableLoader/TableLoader" ;
33
36
import { useFormik } from "formik" ;
34
37
import { Plus , SquareArrowOutUpRight , Trash } from "lucide-react" ;
35
38
import { type FC , useState } from "react" ;
@@ -74,6 +77,7 @@ export const IdpOrgSyncPageView: FC<IdpSyncPageViewProps> = ({
74
77
const organizationMappingCount = form . values . mapping
75
78
? Object . entries ( form . values . mapping ) . length
76
79
: 0 ;
80
+ const [ isDialogOpen , setIsDialogOpen ] = useState ( false ) ;
77
81
78
82
const getOrgNames = ( orgIds : readonly string [ ] ) => {
79
83
return orgIds . map (
@@ -136,11 +140,15 @@ export const IdpOrgSyncPageView: FC<IdpSyncPageViewProps> = ({
136
140
id = { ORGANIZATION_ASSIGN_DEFAULT_ID }
137
141
checked = { form . values . organization_assign_default }
138
142
onCheckedChange = { async ( checked ) => {
139
- void form . setFieldValue (
140
- "organization_assign_default" ,
141
- checked ,
142
- ) ;
143
- form . handleSubmit ( ) ;
143
+ if ( ! checked ) {
144
+ setIsDialogOpen ( true ) ;
145
+ } else {
146
+ void form . setFieldValue (
147
+ "organization_assign_default" ,
148
+ checked ,
149
+ ) ;
150
+ form . handleSubmit ( ) ;
151
+ }
144
152
} }
145
153
/>
146
154
< span className = "flex flex-row items-center gap-1" >
@@ -234,6 +242,36 @@ export const IdpOrgSyncPageView: FC<IdpSyncPageViewProps> = ({
234
242
</ div >
235
243
</ fieldset >
236
244
</ form >
245
+
246
+ < Dialog open = { isDialogOpen } onOpenChange = { setIsDialogOpen } >
247
+ < DialogContent className = "flex flex-col gap-12 max-w-lg" >
248
+ < DialogHeader className = "flex flex-col gap-4" >
249
+ < DialogTitle >
250
+ Switch off default organization assignment
251
+ </ DialogTitle >
252
+ < DialogDescription >
253
+ Warning: This will remove all users from the default organization
254
+ unless otherwise specified in an organization mapping defined
255
+ below.
256
+ </ DialogDescription >
257
+ </ DialogHeader >
258
+ < DialogFooter className = "flex flex-row" >
259
+ < Button variant = "outline" onClick = { ( ) => setIsDialogOpen ( false ) } >
260
+ Cancel
261
+ </ Button >
262
+ < Button
263
+ onClick = { ( ) => {
264
+ void form . setFieldValue ( "organization_assign_default" , false ) ;
265
+ setIsDialogOpen ( false ) ;
266
+ form . handleSubmit ( ) ;
267
+ } }
268
+ type = "submit"
269
+ >
270
+ Confirm
271
+ </ Button >
272
+ </ DialogFooter >
273
+ </ DialogContent >
274
+ </ Dialog >
237
275
</ div >
238
276
) ;
239
277
} ;
@@ -318,31 +356,14 @@ const OrganizationRow: FC<OrganizationRowProps> = ({
318
356
) ;
319
357
} ;
320
358
321
- const TableLoader = ( ) => {
322
- return (
323
- < TableLoaderSkeleton >
324
- < TableRowSkeleton >
325
- < TableCell >
326
- < Skeleton variant = "text" width = "25%" />
327
- </ TableCell >
328
- < TableCell >
329
- < Skeleton variant = "text" width = "25%" />
330
- </ TableCell >
331
- < TableCell >
332
- < Skeleton variant = "text" width = "10%" />
333
- </ TableCell >
334
- </ TableRowSkeleton >
335
- </ TableLoaderSkeleton >
336
- ) ;
337
- } ;
338
-
339
359
export const AssignDefaultOrgHelpTooltip : FC = ( ) => {
340
360
return (
341
361
< HelpTooltip >
342
362
< HelpTooltipTrigger />
343
363
< HelpTooltipContent >
344
364
< HelpTooltipText >
345
- Disabling will remove all users from the default organization.
365
+ Disabling will remove all users from the default organization if a
366
+ mapping for the default organization is not defined.
346
367
</ HelpTooltipText >
347
368
</ HelpTooltipContent >
348
369
</ HelpTooltip >
0 commit comments