Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
canifa_note
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Vũ Hoàng Anh
canifa_note
Commits
6d1485d1
Commit
6d1485d1
authored
Sep 17, 2025
by
Steven
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: reset state on dialog close and improve dialog open handling
parent
5ad2038b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
54 additions
and
6 deletions
+54
-6
CreateIdentityProviderDialog.tsx
web/src/components/CreateIdentityProviderDialog.tsx
+33
-4
SSOSection.tsx
web/src/components/Settings/SSOSection.tsx
+9
-1
dialog.tsx
web/src/components/ui/dialog.tsx
+12
-1
No files found.
web/src/components/CreateIdentityProviderDialog.tsx
View file @
6d1485d1
...
@@ -129,8 +129,36 @@ function CreateIdentityProviderDialog({ open, onOpenChange, identityProvider, on
...
@@ -129,8 +129,36 @@ function CreateIdentityProviderDialog({ open, onOpenChange, identityProvider, on
const
[
selectedTemplate
,
setSelectedTemplate
]
=
useState
<
string
>
(
"GitHub"
);
const
[
selectedTemplate
,
setSelectedTemplate
]
=
useState
<
string
>
(
"GitHub"
);
const
isCreating
=
identityProvider
===
undefined
;
const
isCreating
=
identityProvider
===
undefined
;
// Reset state when dialog is closed
useEffect
(()
=>
{
useEffect
(()
=>
{
if
(
identityProvider
)
{
if
(
!
open
)
{
// Reset to default state when dialog is closed
setBasicInfo
({
title
:
""
,
identifierFilter
:
""
,
});
setType
(
IdentityProvider_Type
.
OAUTH2
);
setOAuth2Config
({
clientId
:
""
,
clientSecret
:
""
,
authUrl
:
""
,
tokenUrl
:
""
,
userInfoUrl
:
""
,
scopes
:
[],
fieldMapping
:
FieldMapping
.
fromPartial
({
identifier
:
""
,
displayName
:
""
,
email
:
""
,
}),
});
setOAuth2Scopes
(
""
);
setSelectedTemplate
(
"GitHub"
);
}
},
[
open
]);
// Load existing identity provider data when editing
useEffect
(()
=>
{
if
(
open
&&
identityProvider
)
{
setBasicInfo
({
setBasicInfo
({
title
:
identityProvider
.
title
,
title
:
identityProvider
.
title
,
identifierFilter
:
identityProvider
.
identifierFilter
,
identifierFilter
:
identityProvider
.
identifierFilter
,
...
@@ -142,10 +170,11 @@ function CreateIdentityProviderDialog({ open, onOpenChange, identityProvider, on
...
@@ -142,10 +170,11 @@ function CreateIdentityProviderDialog({ open, onOpenChange, identityProvider, on
setOAuth2Scopes
(
oauth2Config
.
scopes
.
join
(
" "
));
setOAuth2Scopes
(
oauth2Config
.
scopes
.
join
(
" "
));
}
}
}
}
},
[
identityProvider
]);
},
[
open
,
identityProvider
]);
// Load template data when creating new IDP
useEffect
(()
=>
{
useEffect
(()
=>
{
if
(
!
isCreating
)
{
if
(
!
isCreating
||
!
open
)
{
return
;
return
;
}
}
...
@@ -162,7 +191,7 @@ function CreateIdentityProviderDialog({ open, onOpenChange, identityProvider, on
...
@@ -162,7 +191,7 @@ function CreateIdentityProviderDialog({ open, onOpenChange, identityProvider, on
setOAuth2Scopes
(
oauth2Config
.
scopes
.
join
(
" "
));
setOAuth2Scopes
(
oauth2Config
.
scopes
.
join
(
" "
));
}
}
}
}
},
[
selectedTemplate
]);
},
[
selectedTemplate
,
isCreating
,
open
]);
const
handleCloseBtnClick
=
()
=>
{
const
handleCloseBtnClick
=
()
=>
{
onOpenChange
(
false
);
onOpenChange
(
false
);
...
...
web/src/components/Settings/SSOSection.tsx
View file @
6d1485d1
...
@@ -54,6 +54,14 @@ const SSOSection = () => {
...
@@ -54,6 +54,14 @@ const SSOSection = () => {
setEditingIdentityProvider
(
undefined
);
setEditingIdentityProvider
(
undefined
);
};
};
const
handleDialogOpenChange
=
(
open
:
boolean
)
=>
{
setIsCreateDialogOpen
(
open
);
// Clear editing state when dialog is closed
if
(
!
open
)
{
setEditingIdentityProvider
(
undefined
);
}
};
return
(
return
(
<
div
className=
"w-full flex flex-col gap-2 pt-2 pb-4"
>
<
div
className=
"w-full flex flex-col gap-2 pt-2 pb-4"
>
<
div
className=
"w-full flex flex-row justify-between items-center gap-1"
>
<
div
className=
"w-full flex flex-row justify-between items-center gap-1"
>
...
@@ -100,7 +108,7 @@ const SSOSection = () => {
...
@@ -100,7 +108,7 @@ const SSOSection = () => {
<
CreateIdentityProviderDialog
<
CreateIdentityProviderDialog
open=
{
isCreateDialogOpen
}
open=
{
isCreateDialogOpen
}
onOpenChange=
{
setIsCreateDialogOpen
}
onOpenChange=
{
handleDialogOpenChange
}
identityProvider=
{
editingIdentityProvider
}
identityProvider=
{
editingIdentityProvider
}
onSuccess=
{
handleDialogSuccess
}
onSuccess=
{
handleDialogSuccess
}
/>
/>
...
...
web/src/components/ui/dialog.tsx
View file @
6d1485d1
...
@@ -74,7 +74,18 @@ const DialogContent = React.forwardRef<
...
@@ -74,7 +74,18 @@ const DialogContent = React.forwardRef<
>
(({
className
,
children
,
showCloseButton
=
true
,
size
,
...
props
},
ref
)
=>
(
>
(({
className
,
children
,
showCloseButton
=
true
,
size
,
...
props
},
ref
)
=>
(
<
DialogPortal
>
<
DialogPortal
>
<
DialogOverlay
/>
<
DialogOverlay
/>
<
DialogPrimitive
.
Content
ref=
{
ref
}
className=
{
cn
(
dialogContentVariants
({
size
}),
className
)
}
{
...
props
}
>
<
DialogPrimitive
.
Content
ref=
{
ref
}
className=
{
cn
(
dialogContentVariants
({
size
}),
className
)
}
onOpenAutoFocus=
{
(
e
)
=>
{
e
.
preventDefault
();
}
}
onCloseAutoFocus=
{
(
e
)
=>
{
e
.
preventDefault
();
document
.
body
.
style
.
pointerEvents
=
"auto"
;
}
}
{
...
props
}
>
<
div
className=
"overflow-y-auto overflow-x-hidden flex-1 flex flex-col gap-4"
>
{
children
}
</
div
>
<
div
className=
"overflow-y-auto overflow-x-hidden flex-1 flex flex-col gap-4"
>
{
children
}
</
div
>
{
showCloseButton
&&
(
{
showCloseButton
&&
(
<
DialogPrimitive
.
Close
className=
"ring-offset-background data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4"
>
<
DialogPrimitive
.
Close
className=
"ring-offset-background data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4"
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment