diff --git a/frontend/src/hooks/api/ldapConfig/queries.tsx b/frontend/src/hooks/api/ldapConfig/queries.tsx index c84f90aacf..e92a7a1c76 100644 --- a/frontend/src/hooks/api/ldapConfig/queries.tsx +++ b/frontend/src/hooks/api/ldapConfig/queries.tsx @@ -13,9 +13,15 @@ export const useGetLDAPConfig = (organizationId: string) => { return useQuery({ queryKey: ldapConfigKeys.getLDAPConfig(organizationId), queryFn: async () => { - const { data } = await apiRequest.get(`/api/v1/ldap/config?organizationId=${organizationId}`); + try { + const { data } = await apiRequest.get( + `/api/v1/ldap/config?organizationId=${organizationId}` + ); - return data; + return data; + } catch (err) { + return null; + } }, enabled: true }); diff --git a/frontend/src/hooks/api/oidcConfig/queries.tsx b/frontend/src/hooks/api/oidcConfig/queries.tsx index 08b38cbb88..49db7c5d46 100644 --- a/frontend/src/hooks/api/oidcConfig/queries.tsx +++ b/frontend/src/hooks/api/oidcConfig/queries.tsx @@ -12,11 +12,15 @@ export const useGetOIDCConfig = (orgSlug: string) => { return useQuery({ queryKey: oidcConfigKeys.getOIDCConfig(orgSlug), queryFn: async () => { - const { data } = await apiRequest.get( - `/api/v1/sso/oidc/config?orgSlug=${orgSlug}` - ); + try { + const { data } = await apiRequest.get( + `/api/v1/sso/oidc/config?orgSlug=${orgSlug}` + ); - return data; + return data; + } catch (err) { + return null; + } }, enabled: true }); diff --git a/frontend/src/hooks/api/ssoConfig/queries.tsx b/frontend/src/hooks/api/ssoConfig/queries.tsx index 3074c5edaa..cbb8e0abe1 100644 --- a/frontend/src/hooks/api/ssoConfig/queries.tsx +++ b/frontend/src/hooks/api/ssoConfig/queries.tsx @@ -11,9 +11,15 @@ export const useGetSSOConfig = (organizationId: string) => { return useQuery({ queryKey: ssoConfigKeys.getSSOConfig(organizationId), queryFn: async () => { - const { data } = await apiRequest.get(`/api/v1/sso/config?organizationId=${organizationId}`); + try { + const { data } = await apiRequest.get( + `/api/v1/sso/config?organizationId=${organizationId}` + ); - return data; + return data; + } catch (err) { + return null; + } }, enabled: true }); 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(); - }} - > - -
- ( - - - - )} - /> - ( - - - - )} - /> - ( - - - - )} - /> - ( - - - - )} - /> - ( - - - - )} - /> - ( - - - - )} - /> - ( - - - - )} - /> - ( - - - - )} - /> - ( - -