refactor: enhance notification handling and streamline async logic across various components

This commit is contained in:
Victor Santos
2025-11-03 11:58:44 -03:00
parent 1ed59a7304
commit 3aeee8d552
38 changed files with 653 additions and 1064 deletions
@@ -72,20 +72,12 @@ export const OAuthCallbackPage = () => {
if (!isReady) return;
(async () => {
try {
await handleMicrosoftTeams();
createNotification({
text: "Successfully created Microsoft Teams workflow integration",
type: "success"
});
} catch (err) {
console.error(err);
createNotification({
text: "Failed to create Microsoft Teams workflow integration",
type: "error"
});
}
})();
}, [isReady]);
@@ -55,7 +55,6 @@ export const GithubOrgSyncConfigModal = ({
});
const onFormSubmit = async ({ githubOrgName, githubOrgAccessToken }: FormData) => {
try {
if (isUpdate) {
await updateGithubSyncOrgConfig({
githubOrgName,
@@ -79,16 +78,9 @@ export const GithubOrgSyncConfigModal = ({
});
}
handlePopUpToggle("githubOrgSyncConfig");
} catch {
createNotification({
text: "Failed to setup GitHub Organization Sync",
type: "error"
});
}
};
const onDelete = async () => {
try {
await deleteGithubSyncOrgConfig();
handlePopUpToggle("deleteGithubOrgSyncConfig", false);
@@ -97,13 +89,6 @@ export const GithubOrgSyncConfigModal = ({
text: "Successfully deleted GitHub Organization Sync",
type: "success"
});
} catch (err) {
console.error(err);
createNotification({
text: "Failed to delete GitHub Organization Sync",
type: "error"
});
}
};
return (
@@ -35,7 +35,6 @@ export const OrgGithubSyncSection = () => {
const data = !isPending && !githubOrgSyncConfig?.isError ? githubOrgSyncConfig?.data : undefined;
const handleBulkSync = async () => {
try {
const result = await syncAllTeamsMutation.mutateAsync();
let message = "Successfully synced teams";
@@ -72,28 +71,6 @@ export const OrgGithubSyncSection = () => {
});
console.warn("Sync errors:", result.errors);
}
} catch (error) {
const errorMessage =
(error as any)?.response?.data?.message || (error as Error)?.message || "Unknown error";
if (
errorMessage.includes("token") &&
(errorMessage.includes("required") ||
errorMessage.includes("invalid") ||
errorMessage.includes("expired") ||
errorMessage.includes("set a token first"))
) {
createNotification({
text: "Please set a GitHub access token in the configuration modal to continue with the sync",
type: "error"
});
} else {
createNotification({
text: `Failed to sync GitHub teams: ${errorMessage}`,
type: "error"
});
}
}
};
return (
@@ -36,7 +36,6 @@ export const OrgScimSection = () => {
};
const handleEnableSCIMToggle = async (value: boolean) => {
try {
if (!currentOrg?.id) return;
if (!subscription?.scim) {
handlePopUpOpen("upgradePlan", {
@@ -54,12 +53,6 @@ export const OrgScimSection = () => {
text: `Successfully ${value ? "enabled" : "disabled"} SCIM provisioning`,
type: "success"
});
} catch (err) {
createNotification({
text: (err as { response: { data: { message: string } } }).response.data.message,
type: "error"
});
}
};
return (
@@ -92,7 +92,6 @@ export const ScimTokenModal = ({ popUp, handlePopUpOpen, handlePopUpToggle }: Pr
}, [isScimTokenCopied, isScimUrlCopied]);
const onFormSubmit = async ({ description, ttlDays }: FormData) => {
try {
if (!currentOrg?.id) return;
const { scimToken } = await createScimTokenMutateAsync({
@@ -107,17 +106,9 @@ export const ScimTokenModal = ({ popUp, handlePopUpOpen, handlePopUpToggle }: Pr
text: "Successfully created SCIM token",
type: "success"
});
} catch (err) {
console.error(err);
createNotification({
text: "Failed to create SCIM token",
type: "error"
});
}
};
const onDeleteScimTokenSubmit = async (scimTokenId: string) => {
try {
if (!currentOrg?.id) return;
await deleteScimTokenMutateAsync({
@@ -131,13 +122,6 @@ export const ScimTokenModal = ({ popUp, handlePopUpOpen, handlePopUpToggle }: Pr
text: "Successfully deleted SCIM token",
type: "success"
});
} catch (err) {
console.error(err);
createNotification({
text: "Failed to delete SCIM token",
type: "error"
});
}
};
const hasToken = Boolean(token);
@@ -20,7 +20,6 @@ export const OrgGenericAuthSection = () => {
const { mutateAsync } = useUpdateOrg();
const handleEnforceMfaToggle = async (value: boolean) => {
try {
if (!currentOrg?.id) return;
if (!subscription?.enforceMfa) {
handlePopUpOpen("upgradePlan");
@@ -36,17 +35,9 @@ export const OrgGenericAuthSection = () => {
text: `Successfully ${value ? "enforced" : "un-enforced"} MFA`,
type: "success"
});
} catch (err) {
console.error(err);
createNotification({
text: (err as { response: { data: { message: string } } }).response.data.message,
type: "error"
});
}
};
const handleUpdateSelectedMfa = async (selectedMfaMethod: MfaMethod) => {
try {
if (!currentOrg?.id) return;
if (!subscription?.enforceMfa) {
handlePopUpOpen("upgradePlan");
@@ -62,13 +53,6 @@ export const OrgGenericAuthSection = () => {
text: "Successfully updated selected MFA method",
type: "success"
});
} catch (err) {
console.error(err);
createNotification({
text: (err as { response: { data: { message: string } } }).response.data.message,
type: "error"
});
}
};
return (
@@ -57,7 +57,6 @@ export const OrgUserAccessTokenLimitSection = () => {
if (!currentOrg) return null;
const handleUserTokenExpirationSubmit = async (formData: TForm) => {
try {
const userTokenExpiration = formatDuration(formData.expirationValue, formData.expirationUnit);
await updateUserTokenExpiration({
@@ -69,12 +68,6 @@ export const OrgUserAccessTokenLimitSection = () => {
text: "Successfully updated user token expiration",
type: "success"
});
} catch {
createNotification({
text: "Failed updating user token expiration",
type: "error"
});
}
};
// Units for the dropdown with readable labels
@@ -79,7 +79,6 @@ export const LDAPGroupMapModal = ({ popUp, handlePopUpOpen, handlePopUpToggle }:
});
const onFormSubmit = async ({ groupSlug, ldapGroupCN }: TFormData) => {
try {
if (!ldapConfig) return;
await createLDAPGroupMapping({
@@ -94,13 +93,6 @@ export const LDAPGroupMapModal = ({ popUp, handlePopUpOpen, handlePopUpToggle }:
text: `Successfully added LDAP group mapping for ${ldapGroupCN}`,
type: "success"
});
} catch (err) {
console.error(err);
createNotification({
text: `Failed to add LDAP group mapping for ${ldapGroupCN}`,
type: "error"
});
}
};
const onDeleteGroupMapSubmit = async ({
@@ -112,7 +104,6 @@ export const LDAPGroupMapModal = ({ popUp, handlePopUpOpen, handlePopUpToggle }:
ldapGroupMapId: string;
ldapGroupCN: string;
}) => {
try {
await deleteLDAPGroupMapping({
ldapConfigId,
ldapGroupMapId
@@ -124,13 +115,6 @@ export const LDAPGroupMapModal = ({ popUp, handlePopUpOpen, handlePopUpToggle }:
text: `Successfully deleted LDAP group mapping ${ldapGroupCN}`,
type: "success"
});
} catch (err) {
console.error(err);
createNotification({
text: `Failed to delete LDAP group mapping ${ldapGroupCN}`,
type: "error"
});
}
};
useEffect(() => {
@@ -62,7 +62,6 @@ export const LDAPModal = ({ popUp, handlePopUpClose, handlePopUpToggle, hideDele
if (!currentOrg) {
return;
}
try {
await updateMutateAsync({
organizationId: currentOrg.id,
isActive: false,
@@ -81,12 +80,6 @@ export const LDAPModal = ({ popUp, handlePopUpClose, handlePopUpToggle, hideDele
text: "Successfully deleted OIDC configuration.",
type: "success"
});
} catch {
createNotification({
text: "Failed deleting OIDC configuration.",
type: "error"
});
}
};
const watchUrl = watch("url");
@@ -164,33 +157,17 @@ export const LDAPModal = ({ popUp, handlePopUpClose, handlePopUpToggle, hideDele
};
const handleTestLDAPConnection = async () => {
try {
const result = await testLDAPConnection({
await testLDAPConnection({
url: watchUrl,
bindDN: watchBindDN,
bindPass: watchBindPass,
caCert: watchCaCert ?? ""
});
if (!result) {
createNotification({
text: "Failed to test the LDAP connection: Bind operation was unsuccessful",
type: "error"
});
return;
}
createNotification({
text: "Successfully tested the LDAP connection: Bind operation was successful",
type: "success"
});
} catch (err) {
console.error(err);
createNotification({
text: "Failed to test the LDAP connection",
type: "error"
});
}
};
return (
@@ -45,7 +45,6 @@ export const OrgGeneralAuthSection = ({
const logout = useLogoutUser();
const handleEnforceOrgAuthToggle = async (value: boolean, type: EnforceAuthType) => {
try {
if (!currentOrg?.id) return;
if (type === EnforceAuthType.SAML) {
@@ -101,13 +100,6 @@ export const OrgGeneralAuthSection = ({
window.close();
}
} catch (err) {
console.error(err);
createNotification({
text: (err as { response: { data: { message: string } } }).response.data.message,
type: "error"
});
}
};
const handleEnableBypassOrgAuthToggle = async (value: boolean) => {
@@ -31,7 +31,6 @@ export const OrgLDAPSection = (): JSX.Element => {
const { mutateAsync: createMutateAsync } = useCreateLDAPConfig();
const handleLDAPToggle = async (value: boolean) => {
try {
if (!currentOrg?.id) return;
if (!subscription?.ldap) {
handlePopUpOpen("upgradePlan", {
@@ -49,13 +48,6 @@ export const OrgLDAPSection = (): JSX.Element => {
text: `Successfully ${value ? "enabled" : "disabled"} LDAP`,
type: "success"
});
} catch (err) {
console.error(err);
createNotification({
text: `Failed to ${value ? "enable" : "disable"} LDAP`,
type: "error"
});
}
};
const addLDAPBtnClick = async () => {
@@ -30,7 +30,6 @@ export const OrgOIDCSection = (): JSX.Element => {
] as const);
const handleOIDCToggle = async (value: boolean) => {
try {
if (!currentOrg?.id) return;
if (!subscription?.oidcSSO) {
@@ -47,13 +46,9 @@ export const OrgOIDCSection = (): JSX.Element => {
text: `Successfully ${value ? "enabled" : "disabled"} OIDC SSO`,
type: "success"
});
} catch (err) {
console.error(err);
}
};
const handleOIDCGroupManagement = async (value: boolean) => {
try {
if (!currentOrg?.id) return;
if (!subscription?.oidcSSO) {
@@ -70,9 +65,6 @@ export const OrgOIDCSection = (): JSX.Element => {
text: `Successfully ${value ? "enabled" : "disabled"} OIDC group membership mapping`,
type: "success"
});
} catch (err) {
console.error(err);
}
};
const addOidcButtonClick = async () => {
@@ -34,7 +34,6 @@ export const OrgSSOSection = (): JSX.Element => {
const { mutateAsync: createMutateAsync } = useCreateSSOConfig();
const handleSamlSSOToggle = async (value: boolean) => {
try {
if (!currentOrg?.id) return;
if (!subscription?.samlSSO) {
@@ -53,24 +52,15 @@ export const OrgSSOSection = (): JSX.Element => {
text: `Successfully ${value ? "enabled" : "disabled"} SAML SSO`,
type: "success"
});
} catch (err) {
console.error(err);
createNotification({
text: `Failed to ${value ? "enable" : "disable"} SAML SSO`,
type: "error"
});
}
};
const handleSamlGroupManagement = async (value: boolean) => {
try {
if (!currentOrg?.id) return;
if (!subscription?.samlSSO || !subscription?.groups) {
handlePopUpOpen("upgradePlan", {
isEnterpriseFeature: true,
description:
"You can use SAML group mapping if you switch to Infisical's Enterprise plan."
description: "You can use SAML group mapping if you switch to Infisical's Enterprise plan."
});
return;
}
@@ -84,13 +74,6 @@ export const OrgSSOSection = (): JSX.Element => {
text: `Successfully ${value ? "enabled" : "disabled"} SAML group membership mapping`,
type: "success"
});
} catch (err) {
console.error(err);
createNotification({
text: `Failed to ${value ? "enable" : "disable"} SAML group membership mapping`,
type: "error"
});
}
};
const addSSOBtnClick = async () => {
@@ -16,7 +16,6 @@ export const DeleteProjectTemplateModal = ({ isOpen, onOpenChange, template }: P
const { id: templateId, name } = template;
const handleDeleteProjectTemplate = async () => {
try {
await deleteTemplate.mutateAsync({
templateId
});
@@ -27,14 +26,6 @@ export const DeleteProjectTemplateModal = ({ isOpen, onOpenChange, template }: P
});
onOpenChange(false);
} catch (err) {
console.error(err);
createNotification({
text: "Failed remove project template",
type: "error"
});
}
};
return (
@@ -31,7 +31,6 @@ export const EditProjectTemplate = ({ isInfisicalTemplate, projectTemplate, onBa
const deleteProjectTemplate = useDeleteProjectTemplate();
const handleRemoveTemplate = async () => {
try {
await deleteProjectTemplate.mutateAsync({
templateId
});
@@ -40,13 +39,6 @@ export const EditProjectTemplate = ({ isInfisicalTemplate, projectTemplate, onBa
type: "success"
});
onBack();
} catch (error) {
console.error(error);
createNotification({
text: "Failed to remove project template",
type: "error"
});
}
handlePopUpClose("removeTemplate");
};
@@ -57,7 +57,6 @@ export const ProjectTemplateEditRoleForm = ({
const updateProjectTemplate = useUpdateProjectTemplate();
const onSubmit = async (form: TFormSchema) => {
try {
await updateProjectTemplate.mutateAsync({
templateId: projectTemplate.id,
roles: [
@@ -75,13 +74,6 @@ export const ProjectTemplateEditRoleForm = ({
text: "Template roles successfully updated",
type: "success"
});
} catch (e: any) {
console.error(e);
createNotification({
text: "Failed to update template roles",
type: "error"
});
}
};
return (
@@ -68,7 +68,6 @@ export const ProjectTemplateEnvironmentsForm = ({
const updateProjectTemplate = useUpdateProjectTemplate();
const onFormSubmit = async (form: TFormSchema) => {
try {
const { environments: updatedEnvs } = await updateProjectTemplate.mutateAsync({
environments: form.environments?.map((env, index) => ({
...env,
@@ -83,13 +82,6 @@ export const ProjectTemplateEnvironmentsForm = ({
text: "Project template updated successfully",
type: "success"
});
} catch (e: any) {
console.error(e);
createNotification({
text: e.message ?? "Failed to update project template",
type: "error"
});
}
};
const isEnvironmentLimitExceeded =
@@ -42,7 +42,6 @@ export const ProjectTemplateRolesSection = ({ projectTemplate, isInfisicalTempla
const updateProjectTemplate = useUpdateProjectTemplate();
const handleRemoveRole = async (slug: string) => {
try {
await updateProjectTemplate.mutateAsync({
templateId: projectTemplate.id,
roles: projectTemplate.roles.filter(
@@ -55,13 +54,6 @@ export const ProjectTemplateRolesSection = ({ projectTemplate, isInfisicalTempla
type: "success"
});
handlePopUpClose("removeRole");
} catch (e) {
console.error(e);
createNotification({
text: "Error removing role from template",
type: "error"
});
}
};
const editRole = popUp?.editRole?.data as TProjectRole;
@@ -93,7 +93,6 @@ const ProjectTemplateForm = ({ onComplete, projectTemplate }: FormProps) => {
? updateProjectTemplate.mutateAsync({ templateId: projectTemplate.id, ...data })
: createProjectTemplate.mutateAsync({ ...data });
try {
const template = await mutation;
createNotification({
text: `Successfully ${
@@ -103,15 +102,6 @@ const ProjectTemplateForm = ({ onComplete, projectTemplate }: FormProps) => {
});
onComplete(template);
} catch (err) {
console.error(err);
createNotification({
text: `Failed to ${
projectTemplate ? "update template details" : "create project template"
}`,
type: "error"
});
}
};
return (
@@ -87,7 +87,6 @@ export const UserOrgMembershipModal = ({ popUp, handlePopUpOpen, handlePopUpTogg
}, [popUp?.orgMembership?.data, roles]);
const onFormSubmit = async ({ role, metadata }: FormData) => {
try {
if (!orgId) return;
await updateOrgMembership({
@@ -105,16 +104,6 @@ export const UserOrgMembershipModal = ({ popUp, handlePopUpOpen, handlePopUpTogg
});
reset();
} catch (err) {
console.error(err);
const error = err as any;
const text = error?.response?.data?.message ?? "Failed to update user organization role";
createNotification({
text,
type: "error"
});
}
};
return (
@@ -67,7 +67,6 @@ const UserAddToProjectModalChild = ({ membershipId, popUp, handlePopUpToggle }:
}, [workspaces, projectMemberships]);
const onFormSubmit = async ({ projectId }: FormData) => {
try {
await addUserToWorkspaceNonE2EE({
projectId,
usernames: [popupData.username],
@@ -81,16 +80,6 @@ const UserAddToProjectModalChild = ({ membershipId, popUp, handlePopUpToggle }:
reset();
handlePopUpToggle("addUserToProject", false);
} catch (err) {
console.error(err);
const error = err as any;
const text = error?.response?.data?.message ?? "Failed to add identity to project";
createNotification({
text,
type: "error"
});
}
};
return (
@@ -20,7 +20,6 @@ export const UserGroupsSection = ({ orgMembership }: Props) => {
const { mutateAsync: removeUserFromGroup } = useRemoveUserFromGroup();
const handleRemoveUserFromGroup = useCallback(async (groupId: string, groupSlug: string) => {
try {
await removeUserFromGroup({
groupId,
slug: groupSlug,
@@ -33,12 +32,6 @@ export const UserGroupsSection = ({ orgMembership }: Props) => {
});
handlePopUpClose("removeUserFromGroup");
} catch {
createNotification({
type: "error",
text: "Failed to remove user from group"
});
}
}, []);
return (
@@ -62,7 +62,6 @@ const Content = ({ popUp, handlePopUpToggle }: Props) => {
});
const onFormSubmit = async ({ group, role }: FormData) => {
try {
await addGroupToWorkspaceMutateAsync({
projectId: currentProject?.id || "",
groupId: group.id,
@@ -76,12 +75,6 @@ const Content = ({ popUp, handlePopUpToggle }: Props) => {
text: "Successfully added group to project",
type: "success"
});
} catch {
createNotification({
text: "Failed to add group to project",
type: "error"
});
}
};
return filteredGroupMembershipOrgs.length ? (
@@ -43,7 +43,6 @@ export const GroupsSection = () => {
};
const onRemoveGroupSubmit = async (groupId: string) => {
try {
await deleteMutateAsync({
groupId,
projectId: currentProject?.id || ""
@@ -55,16 +54,6 @@ export const GroupsSection = () => {
});
handlePopUpClose("deleteGroup");
} catch (err) {
console.error(err);
const error = err as any;
const text = error?.response?.data?.message ?? "Failed to remove group from project";
createNotification({
text,
type: "error"
});
}
};
return (
@@ -119,7 +119,6 @@ export const IdentityTab = withProjectPermission(
] as const);
const onRemoveIdentitySubmit = async (identityId: string) => {
try {
await deleteMutateAsync({
identityId,
projectId
@@ -131,16 +130,6 @@ export const IdentityTab = withProjectPermission(
});
handlePopUpClose("deleteIdentity");
} catch (err) {
console.error(err);
const error = err as any;
const text = error?.response?.data?.message ?? "Failed to remove identity from project";
createNotification({
text,
type: "error"
});
}
};
const handleSort = (column: ProjectIdentityOrderBy) => {
@@ -104,7 +104,6 @@ const Content = ({ popUp, handlePopUpToggle }: Props) => {
});
const onFormSubmit = async ({ identity, role }: FormData) => {
try {
await addIdentityToWorkspaceMutateAsync({
projectId,
identityId: identity.id,
@@ -128,16 +127,6 @@ const Content = ({ popUp, handlePopUpToggle }: Props) => {
}
});
handlePopUpToggle("identity", false);
} catch (err) {
console.error(err);
const error = err as any;
const text = error?.response?.data?.message ?? "Failed to add identity to project";
createNotification({
text,
type: "error"
});
}
};
if (isMembershipsLoading || isRolesLoading)
@@ -110,7 +110,6 @@ export const AddMemberModal = ({ popUp, handlePopUpToggle }: Props) => {
if (!selectedMembers) return;
try {
if (currentProject.version === ProjectVersion.V1) {
createNotification({
type: "error",
@@ -161,14 +160,6 @@ export const AddMemberModal = ({ popUp, handlePopUpToggle }: Props) => {
text: "Successfully added user to the project",
type: "success"
});
} catch (error) {
console.error(error);
createNotification({
text: "Failed to add user to project",
type: "error"
});
return;
}
handlePopUpToggle("addMember", false);
reset();
};
@@ -182,7 +182,6 @@ export const SpecificPrivilegeSecretForm = ({
}
if (deleteUserPrivilege.isPending) return;
try {
await deleteUserPrivilege.mutateAsync({
privilegeId: privilege.id,
projectMembershipId: privilege.projectMembershipId
@@ -191,12 +190,6 @@ export const SpecificPrivilegeSecretForm = ({
type: "success",
text: "Successfully deleted privilege"
});
} catch {
createNotification({
type: "error",
text: "Failed to delete privilege"
});
}
};
// This is used for requesting access additional privileges, not directly creating a privilege!
@@ -35,7 +35,6 @@ export const MembersSection = () => {
if (!currentOrg?.id) return;
if (!currentProject?.id) return;
try {
await removeUserFromWorkspace({
projectId: currentProject.id,
usernames: [username],
@@ -45,13 +44,6 @@ export const MembersSection = () => {
text: "Successfully removed user from project",
type: "success"
});
} catch (error) {
console.error(error);
createNotification({
text: "Failed to remove user from the project",
type: "error"
});
}
handlePopUpClose("removeMember");
};
@@ -6,7 +6,6 @@ import { useTranslation } from "react-i18next";
import { faCheck, faCopy, faPlus, faTrashCan } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { zodResolver } from "@hookform/resolvers/zod";
import { AxiosError } from "axios";
import { z } from "zod";
import { createNotification } from "@app/components/notifications";
@@ -110,7 +109,6 @@ const ServiceTokenForm = () => {
};
const onFormSubmit = async ({ name, scopes, expiresIn, permissions }: FormData) => {
try {
if (!currentProject?.id) return;
const randomBytes = crypto.randomBytes(16).toString("hex");
@@ -134,21 +132,6 @@ const ServiceTokenForm = () => {
text: "Successfully created a service token",
type: "success"
});
} catch (err) {
console.error(err);
const axiosError = err as AxiosError;
if (axiosError?.response?.status === 401) {
createNotification({
text: "You do not have access to the selected environment/path",
type: "error"
});
} else {
createNotification({
text: "Failed to create a service token",
type: "error"
});
}
}
};
return !hasServiceToken ? (
@@ -28,8 +28,7 @@ export const ServiceTokenSection = withProjectPermission(
] as const);
const onDeleteApproved = async () => {
try {
deleteServiceToken.mutateAsync(
await deleteServiceToken.mutateAsync(
(popUp?.deleteAPITokenConfirmation?.data as DeleteModalData)?.id
);
createNotification({
@@ -38,13 +37,6 @@ export const ServiceTokenSection = withProjectPermission(
});
handlePopUpClose("deleteAPITokenConfirmation");
} catch (err) {
console.error(err);
createNotification({
text: "Failed to delete service token",
type: "error"
});
}
};
return (
@@ -35,7 +35,6 @@ export const GroupDetailsSection = ({ groupMembership }: Props) => {
const navigate = useNavigate();
const onRemoveGroupSubmit = async () => {
try {
await deleteMutateAsync({
groupId: groupMembership.group.id,
projectId: currentProject.id
@@ -57,16 +56,6 @@ export const GroupDetailsSection = ({ groupMembership }: Props) => {
});
handlePopUpClose("deleteGroup");
} catch (err) {
console.error(err);
const error = err as any;
const text = error?.response?.data?.message ?? "Failed to remove group from project";
createNotification({
text,
type: "error"
});
}
};
return (
@@ -76,7 +76,6 @@ const Page = () => {
};
const onRemoveIdentitySubmit = async () => {
try {
await deleteMutateAsync({
identityId,
projectId
@@ -95,16 +94,6 @@ const Page = () => {
selectedTab: "identities"
}
});
} catch (err) {
console.error(err);
const error = err as any;
const text = error?.response?.data?.message ?? "Failed to remove identity from project";
createNotification({
text,
type: "error"
});
}
};
if (isMembershipDetailsLoading) {
@@ -83,7 +83,6 @@ export const Page = () => {
const handleRemoveUser = async () => {
if (!currentOrg?.id || !currentProject?.id || !membershipDetails?.user?.username) return;
try {
await removeUserFromWorkspace({
projectId,
usernames: [membershipDetails?.user?.username],
@@ -99,13 +98,6 @@ export const Page = () => {
projectId: currentProject.id
}
});
} catch (error) {
console.error(error);
createNotification({
text: "Failed to remove user from the project",
type: "error"
});
}
handlePopUpClose("removeMember");
};
@@ -53,7 +53,6 @@ const Page = () => {
] as const);
const onDeleteRoleSubmit = async () => {
try {
if (!currentProject?.slug || !data?.id) return;
await deleteProjectRole({
@@ -75,16 +74,6 @@ const Page = () => {
selectedTab: ProjectAccessControlTabs.Roles
}
});
} catch (err) {
console.error(err);
const error = err as any;
const text = error?.response?.data?.message ?? "Failed to delete project role";
createNotification({
text,
type: "error"
});
}
};
const isCustomRole = !Object.values(ProjectMembershipRole).includes(
@@ -76,7 +76,6 @@ export const RoleModal = ({ popUp, handlePopUpToggle }: Props) => {
}, [role]);
const onFormSubmit = async ({ name, description, slug }: FormData) => {
try {
if (!projectId) return;
if (role) {
@@ -125,14 +124,6 @@ export const RoleModal = ({ popUp, handlePopUpToggle }: Props) => {
});
reset();
} catch {
const text = `Failed to ${popUp?.role?.data ? "update" : "create"} role`;
createNotification({
text,
type: "error"
});
}
};
return (
@@ -10,7 +10,6 @@ export const DeleteProjectProtection = () => {
const { mutateAsync } = useUpdateProject();
const handleToggleDeleteProjectProtection = async (state: boolean) => {
try {
await mutateAsync({
projectId,
hasDeleteProtection: state
@@ -21,13 +20,6 @@ export const DeleteProjectProtection = () => {
text,
type: "success"
});
} catch (err) {
console.error(err);
createNotification({
text: "Failed to update delete protection",
type: "error"
});
}
};
return (
@@ -68,12 +68,6 @@ export const DeleteProjectSection = () => {
to: "/organization/projects"
});
handlePopUpClose("deleteWorkspace");
} catch (err) {
console.error(err);
createNotification({
text: "Failed to delete project",
type: "error"
});
} finally {
setIsDeleting.off();
}
@@ -118,12 +112,6 @@ export const DeleteProjectSection = () => {
navigate({
to: "/organization/projects"
});
} catch (err) {
console.error(err);
createNotification({
text: "Failed to leave project",
type: "error"
});
} finally {
setIsLeaving.off();
}