diff --git a/frontend/src/views/Settings/OrgSettingsPage/components/OrgAuthTab/LDAPModal.tsx b/frontend/src/views/Settings/OrgSettingsPage/components/OrgAuthTab/LDAPModal.tsx index e8afe9822..865be26e9 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(); - }} - > - -
- ( - - - - )} - /> - ( - - - - )} - /> - ( - - - - )} - /> - ( - - - - )} - /> - ( - - - - )} - /> - ( - - - - )} - /> - ( - - - - )} - /> - ( - - - - )} - /> - ( - -