From d4a2f4590bbfa719cdf29678dac8aabf17e46bd1 Mon Sep 17 00:00:00 2001 From: Sheen Capadngan Date: Sat, 6 Jul 2024 00:25:27 +0800 Subject: [PATCH 1/2] misc: redesigned org security settings page --- .../components/OrgAuthTab/LDAPModal.tsx | 329 +++++++------ .../components/OrgAuthTab/OIDCModal.tsx | 442 ++++++++++-------- .../components/OrgAuthTab/OrgAuthTab.tsx | 171 ++++++- .../OrgAuthTab/OrgGeneralAuthSection.tsx | 1 - .../components/OrgAuthTab/OrgLDAPSection.tsx | 5 +- .../components/OrgAuthTab/OrgOIDCSection.tsx | 5 +- .../components/OrgAuthTab/OrgSCIMSection.tsx | 7 +- .../components/OrgAuthTab/OrgSSOSection.tsx | 1 - .../components/OrgAuthTab/SSOModal.tsx | 264 ++++++----- 9 files changed, 770 insertions(+), 455 deletions(-) diff --git a/frontend/src/views/Settings/OrgSettingsPage/components/OrgAuthTab/LDAPModal.tsx b/frontend/src/views/Settings/OrgSettingsPage/components/OrgAuthTab/LDAPModal.tsx index e8afe9822f..865be26e92 100644 --- a/frontend/src/views/Settings/OrgSettingsPage/components/OrgAuthTab/LDAPModal.tsx +++ b/frontend/src/views/Settings/OrgSettingsPage/components/OrgAuthTab/LDAPModal.tsx @@ -4,8 +4,17 @@ import { zodResolver } from "@hookform/resolvers/zod"; import { z } from "zod"; import { createNotification } from "@app/components/notifications"; -import { Button, FormControl, Input, Modal, ModalContent, TextArea } from "@app/components/v2"; +import { + Button, + DeleteActionModal, + FormControl, + Input, + Modal, + ModalContent, + TextArea +} from "@app/components/v2"; import { useOrganization } from "@app/context"; +import { useToggle } from "@app/hooks"; import { useCreateLDAPConfig, useGetLDAPConfig, @@ -32,9 +41,10 @@ type Props = { popUp: UsePopUpState<["addLDAP"]>; handlePopUpClose: (popUpName: keyof UsePopUpState<["addLDAP"]>) => void; handlePopUpToggle: (popUpName: keyof UsePopUpState<["addLDAP"]>, state?: boolean) => void; + hideDelete?: boolean; }; -export const LDAPModal = ({ popUp, handlePopUpClose, handlePopUpToggle }: Props) => { +export const LDAPModal = ({ popUp, handlePopUpClose, handlePopUpToggle, hideDelete }: Props) => { const { currentOrg } = useOrganization(); const { mutateAsync: createMutateAsync, isLoading: createIsLoading } = useCreateLDAPConfig(); @@ -46,6 +56,39 @@ export const LDAPModal = ({ popUp, handlePopUpClose, handlePopUpToggle }: Props) resolver: zodResolver(LDAPFormSchema) }); + const [isDeletePopupOpen, setIsDeletePopupOpen] = useToggle(); + + const handleLdapSoftDelete = async () => { + if (!currentOrg) { + return; + } + try { + await updateMutateAsync({ + organizationId: currentOrg.id, + isActive: false, + url: "", + bindDN: "", + bindPass: "", + searchBase: "", + searchFilter: "", + uniqueUserAttribute: "", + groupSearchBase: "", + groupSearchFilter: "", + caCert: "" + }); + + createNotification({ + text: "Successfully deleted OIDC configuration.", + type: "success" + }); + } catch (err) { + createNotification({ + text: "Failed deleting OIDC configuration.", + type: "error" + }); + } + }; + const watchUrl = watch("url"); const watchBindDN = watch("bindDN"); const watchBindPass = watch("bindPass"); @@ -175,138 +218,154 @@ export const LDAPModal = ({ popUp, handlePopUpClose, handlePopUpToggle }: Props) }; return ( - { - handlePopUpToggle("addLDAP", isOpen); - reset(); - }} - > - -
- ( - - - - )} - /> - ( - - - - )} - /> - ( - - - - )} - /> - ( - - - - )} - /> - ( - - - - )} - /> - ( - - - - )} - /> - ( - - - - )} - /> - ( - - - - )} - /> - ( - -