Merge pull request #4790 from Infisical/fix/remove-duplicate-error-notifications

Fix: remove duplicate error notifications
This commit is contained in:
Victor Hugo dos Santos
2025-11-04 07:33:52 -03:00
committed by GitHub
347 changed files with 6111 additions and 9376 deletions
@@ -35,7 +35,6 @@ export const WishForm = () => {
const [isOpen, setIsOpen] = useToggle(false);
const createWish = async (data: TFormData) => {
try {
await mutateAsync({
text: data.text
});
@@ -46,12 +45,6 @@ export const WishForm = () => {
});
setIsOpen.off();
} catch {
createNotification({
text: "An error occured while sending your wish to the Infisical team.",
type: "error"
});
}
};
return (
@@ -25,7 +25,6 @@ const TotpRegistration = ({ onComplete, shouldCenterQr }: Props) => {
const handleTotpVerify = async (event: React.FormEvent<HTMLFormElement>) => {
event.preventDefault();
try {
const result = await verifyUserTotp({
totp
});
@@ -41,12 +40,6 @@ const TotpRegistration = ({ onComplete, shouldCenterQr }: Props) => {
} else if (onComplete) {
onComplete();
}
} catch {
createNotification({
text: "Failed to verify TOTP code",
type: "error"
});
}
};
const handleRecoveryDownloadComplete = async () => {
@@ -43,7 +43,6 @@ export const CreateOrgModal: FC<CreateOrgModalProps> = ({ isOpen, onClose }) =>
const { mutateAsync: selectOrg } = useSelectOrganization();
const onFormSubmit = async ({ name }: FormData) => {
try {
const organization = await createOrg({
name
});
@@ -65,13 +64,6 @@ export const CreateOrgModal: FC<CreateOrgModalProps> = ({ isOpen, onClose }) =>
reset();
onClose();
} catch (err) {
console.error(err);
createNotification({
text: "Failed to created organization",
type: "error"
});
}
};
return (
@@ -20,7 +20,6 @@ export const DeletePkiSyncModal = ({ isOpen, onOpenChange, pkiSync, onComplete }
const handleDeletePkiSync = async () => {
const destinationName = PKI_SYNC_MAP[destination].name;
try {
await deleteSync.mutateAsync({
syncId,
projectId,
@@ -34,14 +33,6 @@ export const DeletePkiSyncModal = ({ isOpen, onOpenChange, pkiSync, onComplete }
if (onComplete) onComplete();
onOpenChange(false);
} catch (err) {
console.error(err);
createNotification({
text: `Failed to delete ${destinationName} PKI Sync`,
type: "error"
});
}
};
return (
@@ -21,7 +21,6 @@ const Content = ({ pkiSync, onComplete }: ContentProps) => {
const triggerImportCertificates = useTriggerPkiSyncImportCertificates();
const handleTriggerImportCertificates = async () => {
try {
await triggerImportCertificates.mutateAsync({
syncId,
destination,
@@ -34,14 +33,6 @@ const Content = ({ pkiSync, onComplete }: ContentProps) => {
});
onComplete();
} catch (err) {
console.error(err);
createNotification({
text: `Failed to trigger certificate import for ${destinationName} Sync`,
type: "error"
});
}
};
return (
@@ -21,7 +21,6 @@ const Content = ({ pkiSync, onComplete }: ContentProps) => {
const triggerRemoveCertificates = useTriggerPkiSyncRemoveCertificates();
const handleTriggerRemoveCertificates = async () => {
try {
await triggerRemoveCertificates.mutateAsync({
syncId,
destination,
@@ -34,14 +33,6 @@ const Content = ({ pkiSync, onComplete }: ContentProps) => {
});
onComplete();
} catch (err) {
console.error(err);
createNotification({
text: `Failed to trigger certificate removal for ${destinationName} Sync`,
type: "error"
});
}
};
return (
@@ -86,14 +86,8 @@ export const CreatePkiSyncForm = ({ destination, onComplete, onCancel, initialDa
type: "success"
});
onComplete(pkiSync);
} catch (err: Error | unknown) {
console.error("PKI sync creation failed:", err);
} catch {
setShowConfirmation(false);
createNotification({
title: `Failed to create ${destinationName} Certificate Sync`,
text: err instanceof Error ? err.message : "An unknown error occurred",
type: "error"
});
}
};
@@ -42,7 +42,6 @@ export const EditPkiSyncForm = ({ pkiSync, fields, onComplete }: Props) => {
});
const onSubmit = async ({ connection, ...formData }: TUpdatePkiSyncForm) => {
try {
const updatedPkiSync = await updatePkiSync.mutateAsync({
syncId: pkiSync.id,
...formData,
@@ -56,14 +55,6 @@ export const EditPkiSyncForm = ({ pkiSync, fields, onComplete }: Props) => {
type: "success"
});
onComplete(updatedPkiSync);
} catch (err: any) {
console.error(err);
createNotification({
title: `Failed to update ${destinationName} PKI Sync`,
text: err.message,
type: "error"
});
}
};
let Component: ReactNode;
@@ -56,7 +56,6 @@ export const ProjectOverviewChangeSection = ({ showSlugField = false }: Props) =
}, [currentProject, showSlugField]);
const onFormSubmit = async (data: BaseFormData | FormDataWithSlug) => {
try {
if (!currentProject?.id) return;
await mutateAsync({
@@ -73,13 +72,6 @@ export const ProjectOverviewChangeSection = ({ showSlugField = false }: Props) =
text: "Successfully updated project overview",
type: "success"
});
} catch (err) {
console.error(err);
createNotification({
text: "Failed to update project overview",
type: "error"
});
}
};
return (
@@ -141,7 +141,6 @@ const NewProjectForm = ({ onOpenChange }: NewProjectFormProps) => {
// type check
if (!currentOrg) return;
if (!user) return;
try {
const {
data: { project }
} = await createWs.mutateAsync({
@@ -160,10 +159,6 @@ const NewProjectForm = ({ onOpenChange }: NewProjectFormProps) => {
to: getProjectHomePage(project.type, project.environments),
params: { projectId: project.id }
});
} catch (err) {
console.error(err);
createNotification({ text: "Failed to create project", type: "error" });
}
};
const onSubmit = handleSubmit((data) => {
return onCreateProject(data);
@@ -37,7 +37,6 @@ export const DeleteSecretRotationV2Modal = ({
const handleDeleteSecretRotation = async () => {
const rotationType = SECRET_ROTATION_MAP[type].name;
try {
await deleteSecretRotation.mutateAsync({
rotationId,
type,
@@ -54,12 +53,6 @@ export const DeleteSecretRotationV2Modal = ({
if (onComplete) onComplete();
onOpenChange(false);
} catch {
createNotification({
text: `Failed to delete ${rotationType} Rotation`,
type: "error"
});
}
};
return (
@@ -22,7 +22,6 @@ const Content = ({ secretRotation, onComplete }: ContentProps) => {
const rotationType = SECRET_ROTATION_MAP[type].name;
const handleRotateSecrets = async () => {
try {
await rotateSecrets.mutateAsync({
rotationId,
type,
@@ -36,14 +35,6 @@ const Content = ({ secretRotation, onComplete }: ContentProps) => {
});
onComplete();
} catch (err) {
console.error(err);
createNotification({
text: `Failed to rotate ${rotationType} secrets`,
type: "error"
});
}
};
return (
@@ -120,7 +120,6 @@ export const SecretRotationV2Form = ({
environment: environment.slug,
projectId: currentProject.id
});
try {
const rotation = await mutation;
createNotification({
@@ -128,13 +127,6 @@ export const SecretRotationV2Form = ({
type: "success"
});
onComplete(rotation);
} catch (err: any) {
createNotification({
title: `Failed to ${secretRotation ? "update" : "create"} ${rotationType} Rotation`,
text: err.message,
type: "error"
});
}
};
const handlePrev = () => {
@@ -28,7 +28,6 @@ export const DeleteSecretScanningDataSourceModal = ({
const handleDeleteDataSource = async () => {
const dataSourceType = SECRET_SCANNING_DATA_SOURCE_MAP[type].name;
try {
await deleteDataSource.mutateAsync({
dataSourceId,
type,
@@ -42,12 +41,6 @@ export const DeleteSecretScanningDataSourceModal = ({
if (onComplete) onComplete();
onOpenChange(false);
} catch {
createNotification({
text: `Failed to delete ${dataSourceType} Data Source`,
type: "error"
});
}
};
return (
@@ -73,7 +73,6 @@ export const SecretScanningDataSourceForm = ({
connectionId: connection?.id,
projectId: currentProject.id
});
try {
const source = await mutation;
createNotification({
@@ -81,13 +80,6 @@ export const SecretScanningDataSourceForm = ({
type: "success"
});
onComplete(source);
} catch (err: any) {
createNotification({
title: `Failed to ${dataSource ? "update" : "create"} ${sourceType} Data Source`,
text: err.message,
type: "error"
});
}
};
const handlePrev = () => {
@@ -23,7 +23,6 @@ export const DeleteSecretSyncModal = ({ isOpen, onOpenChange, secretSync, onComp
const handleDeleteSecretSync = async () => {
const destinationName = SECRET_SYNC_MAP[destination].name;
try {
await deleteSync.mutateAsync({
syncId,
destination,
@@ -38,14 +37,6 @@ export const DeleteSecretSyncModal = ({ isOpen, onOpenChange, secretSync, onComp
if (onComplete) onComplete();
onOpenChange(false);
} catch (err) {
console.error(err);
createNotification({
text: `Failed to remove ${destinationName} Sync`,
type: "error"
});
}
};
return (
@@ -51,7 +51,6 @@ const Content = ({ secretSync, onComplete }: ContentProps) => {
const triggerImportSecrets = useTriggerSecretSyncImportSecrets();
const handleTriggerImportSecrets = async ({ importBehavior }: TFormData) => {
try {
await triggerImportSecrets.mutateAsync({
syncId,
destination,
@@ -65,14 +64,6 @@ const Content = ({ secretSync, onComplete }: ContentProps) => {
});
onComplete();
} catch (err) {
console.error(err);
createNotification({
text: `Failed to trigger secret import for ${destinationName} Sync`,
type: "error"
});
}
};
return (
@@ -21,7 +21,6 @@ const Content = ({ secretSync, onComplete }: ContentProps) => {
const triggerSyncImport = useTriggerSecretSyncRemoveSecrets();
const handleTriggerRemoveSecrets = async () => {
try {
await triggerSyncImport.mutateAsync({
syncId,
destination,
@@ -34,14 +33,6 @@ const Content = ({ secretSync, onComplete }: ContentProps) => {
});
onComplete();
} catch (err) {
console.error(err);
createNotification({
text: `Failed to trigger secret removal for ${destinationName} Sync`,
type: "error"
});
}
};
return (
@@ -88,14 +88,8 @@ export const CreateSecretSyncForm = ({
type: "success"
});
onComplete(secretSync);
} catch (err: any) {
console.error(err);
} catch {
setShowConfirmation(false);
createNotification({
title: `Failed to add ${destinationName} Sync`,
text: err.message,
type: "error"
});
}
};
@@ -58,7 +58,6 @@ export const EditSecretSyncForm = ({ secretSync, fields, onComplete }: Props) =>
const performUpdate = useCallback(
async (formData: TSecretSyncForm) => {
try {
const { environment, connection, ...updateData } = formData;
const updatedSecretSync = await updateSecretSync.mutateAsync({
syncId: secretSync.id,
@@ -73,14 +72,6 @@ export const EditSecretSyncForm = ({ secretSync, fields, onComplete }: Props) =>
type: "success"
});
onComplete(updatedSecretSync);
} catch (err: any) {
console.error(err);
createNotification({
title: `Failed to update ${destinationName} Sync`,
text: err.message,
type: "error"
});
}
},
[updateSecretSync, secretSync.id, secretSync.projectId, destinationName, onComplete]
);
@@ -130,7 +130,6 @@ export const CreateTagModal = ({ isOpen, onToggle, append, currentSecret }: Prop
}, [isOpen]);
const onFormSubmit = async ({ slug, color }: FormData) => {
try {
const data = await createWsTag({
projectId,
tagColor: color,
@@ -143,13 +142,6 @@ export const CreateTagModal = ({ isOpen, onToggle, append, currentSecret }: Prop
text: "Successfully created a tag",
type: "success"
});
} catch (error) {
console.error(error);
createNotification({
text: "Failed to create a tag",
type: "error"
});
}
};
return (
@@ -36,7 +36,6 @@ export const NewSubOrganizationForm = ({ onClose }: ContentProps) => {
const router = useRouter();
const onSubmit = async ({ name }: FormData) => {
try {
const { organization } = await createSubOrg.mutateAsync({
name
});
@@ -52,12 +51,6 @@ export const NewSubOrganizationForm = ({ onClose }: ContentProps) => {
search: (prev) => ({ ...prev, subOrganization: organization.name })
});
await router.invalidate({ sync: true }).catch(() => null);
} catch {
createNotification({
text: "Failed to create sub organization",
type: "error"
});
}
};
return (
@@ -11,7 +11,6 @@ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { Link, linkOptions } from "@tanstack/react-router";
import { UpgradePlanModal } from "@app/components/license/UpgradePlanModal";
import { createNotification } from "@app/components/notifications";
import { OrgPermissionCan } from "@app/components/permissions";
import { NewProjectModal } from "@app/components/projects";
import {
@@ -59,31 +58,17 @@ export const ProjectSelect = () => {
const { mutateAsync: updateUserProjectFavorites } = useUpdateUserProjectFavorites();
const addProjectToFavorites = async (projectId: string) => {
try {
await updateUserProjectFavorites({
orgId: currentOrg!.id,
projectFavorites: [...(projectFavorites || []), projectId]
});
} catch {
createNotification({
text: "Failed to add project to favorites.",
type: "error"
});
}
};
const removeProjectFromFavorites = async (projectId: string) => {
try {
await updateUserProjectFavorites({
orgId: currentOrg!.id,
projectFavorites: [...(projectFavorites || []).filter((entry) => entry !== projectId)]
});
} catch {
createNotification({
text: "Failed to remove project from favorites.",
type: "error"
});
}
};
const isAddingProjectsAllowed = subscription?.workspaceLimit
@@ -65,7 +65,6 @@ const Content = ({ onClose }: ContentProps) => {
const users = usersData.filter((user) => !user.superAdmin);
const onSubmit = async ({ user }: FormData) => {
try {
await grantAdmin.mutateAsync(user.id);
createNotification({
@@ -73,12 +72,6 @@ const Content = ({ onClose }: ContentProps) => {
text: "Successfully granted server admin status"
});
onClose();
} catch {
createNotification({
text: "Failed to grant server admin status",
type: "error"
});
}
};
return (
@@ -303,18 +303,11 @@ export const ServerAdminsTable = () => {
const handleRemoveUser = async () => {
const { id } = popUp?.removeUser?.data as { id: string; username: string };
try {
await deleteUser(id);
createNotification({
type: "success",
text: "Successfully deleted user"
});
} catch {
createNotification({
type: "error",
text: "Error deleting user"
});
}
handlePopUpClose("removeUser");
};
@@ -322,24 +315,16 @@ export const ServerAdminsTable = () => {
const handleRemoveServerAdminAccess = async () => {
const { id } = popUp?.removeServerAdmin?.data as { id: string; username: string };
try {
await removeAdminAccess(id);
createNotification({
type: "success",
text: "Successfully removed server admin access from user"
});
} catch {
createNotification({
type: "error",
text: "Error removing server admin access from user"
});
}
handlePopUpClose("removeServerAdmin");
};
const handleRemoveUsers = async () => {
try {
await deleteUsers(selectedUsers.map((user) => user.id));
createNotification({
@@ -349,12 +334,6 @@ export const ServerAdminsTable = () => {
setSelectedUsers([]);
handlePopUpClose("removeUsers");
} catch {
createNotification({
text: "Failed to remove users",
type: "error"
});
}
};
return (
@@ -54,7 +54,6 @@ export const AuthenticationPageForm = () => {
});
const onAuthFormSubmit = async (formData: TAuthForm) => {
try {
const enabledMethods: LoginMethod[] = [];
if (formData.isEmailEnabled) {
enabledMethods.push(LoginMethod.EMAIL);
@@ -100,13 +99,6 @@ export const AuthenticationPageForm = () => {
text: "Login methods have been successfully updated.",
type: "success"
});
} catch (e) {
console.error(e);
createNotification({
type: "error",
text: "Failed to update login methods."
});
}
};
return (
@@ -31,15 +31,10 @@ export const CachingPageForm = () => {
const handleInvalidateCacheSubmit = async () => {
if (!type || isInvalidating) return;
try {
await invalidateCache({ type });
createNotification({ text: `Began invalidating ${type} cache`, type: "success" });
setShouldPoll(true);
handlePopUpClose("invalidateCache");
} catch (err) {
console.error(err);
createNotification({ text: `Failed to invalidate ${type} cache`, type: "error" });
}
};
useEffect(() => {
@@ -60,19 +60,12 @@ export const EncryptionPageForm = () => {
return;
}
try {
await updateEncryptionStrategy(formData.encryptionStrategy);
createNotification({
type: "success",
text: "Encryption strategy updated successfully"
});
} catch {
createNotification({
type: "error",
text: "Failed to update encryption strategy"
});
}
}, []);
return (
@@ -176,7 +176,6 @@ export const EnvironmentPageForm = () => {
const onSubmit = useCallback(
async (formData: TForm) => {
try {
const filteredFormData = Object.fromEntries(
Object.entries(formData).filter(([, value]) => value !== "")
);
@@ -190,17 +189,6 @@ export const EnvironmentPageForm = () => {
});
reset(formData);
} catch (error) {
const errorMessage =
(error as any)?.response?.data?.message ||
(error as any)?.message ||
"An unknown error occurred";
createNotification({
type: "error",
title: "Failed to update environment overrides",
text: errorMessage
});
}
},
[reset, updateServerConfig]
);
@@ -68,7 +68,6 @@ export const GeneralPageForm = () => {
const organizations = useGetOrganizations();
const onFormSubmit = async (formData: TDashboardForm) => {
try {
const {
allowedSignUpDomain,
trustSamlEmails,
@@ -92,13 +91,6 @@ export const GeneralPageForm = () => {
text: "Successfully changed sign up setting.",
type: "success"
});
} catch (e) {
console.error(e);
createNotification({
type: "error",
text: "Failed to update sign up setting."
});
}
};
return (
@@ -10,7 +10,6 @@ export const UsageReportSection = () => {
const generateUsageReport = useGenerateUsageReport();
const handleGenerateReport = async () => {
try {
const response = await generateUsageReport.mutateAsync();
const { csvContent, filename } = response;
@@ -20,13 +19,6 @@ export const UsageReportSection = () => {
text: `Usage report downloaded: "${filename}"`,
type: "success"
});
} catch (error) {
console.error("Failed to generate usage report:", error);
createNotification({
text: "Failed to generate usage report. Please try again.",
type: "error"
});
}
};
return (
@@ -81,7 +81,6 @@ const Content = ({ onClose }: ContentProps) => {
const { users = [] } = data ?? {};
const onSubmit = async ({ name, invitees }: FormData) => {
try {
await createOrg.mutateAsync({
name,
inviteAdminEmails: invitees
@@ -94,12 +93,6 @@ const Content = ({ onClose }: ContentProps) => {
text: "Successfully created organization"
});
onClose();
} catch {
createNotification({
text: "Failed to create organization",
type: "error"
});
}
};
const { append } = useFieldArray<FormData>({ control, name: "invitees" });
@@ -185,18 +185,11 @@ export const MachineIdentitiesTable = () => {
const handleRemoveServerAdmin = async () => {
const { id } = popUp?.removeServerAdmin?.data as { id: string; name: string };
try {
await deleteIdentitySuperAdminAccess(id);
createNotification({
type: "success",
text: "Successfully removed server admin permissions"
});
} catch {
createNotification({
type: "error",
text: "Error removing server admin permissions"
});
}
handlePopUpClose("removeServerAdmin");
};
@@ -179,12 +179,6 @@ const ViewMembersModalContent = ({
text: "Successfully resent org invitation",
type: "success"
});
} catch (err) {
console.error(err);
createNotification({
text: "Failed to resend org invitation",
type: "error"
});
} finally {
setResendInviteId(null);
}
@@ -479,7 +473,6 @@ const OrganizationsPanelTable = ({
const { mutateAsync: accessOrganization } = useServerAdminAccessOrg();
const handleAccessOrg = async (orgId: string) => {
try {
await accessOrganization(orgId);
navigate({
@@ -493,12 +486,6 @@ const OrganizationsPanelTable = ({
text: "Successfully joined organization",
type: "success"
});
} catch {
createNotification({
text: "Failed to join organization",
type: "error"
});
}
};
return (
@@ -364,18 +364,11 @@ export const UserIdentitiesTable = () => {
const handleRemoveUser = async () => {
const { id } = popUp?.removeUser?.data as { id: string; username: string };
try {
await deleteUser(id);
createNotification({
type: "success",
text: "Successfully deleted user"
});
} catch {
createNotification({
type: "error",
text: "Error deleting user"
});
}
handlePopUpClose("removeUser");
};
@@ -383,18 +376,11 @@ export const UserIdentitiesTable = () => {
const handleGrantServerAdminAccess = async () => {
const { id } = popUp?.upgradeToServerAdmin?.data as { id: string; username: string };
try {
await grantAdminAccess(id);
createNotification({
type: "success",
text: "Successfully granted server admin access to user"
});
} catch {
createNotification({
type: "error",
text: "Error granting server admin access to user"
});
}
handlePopUpClose("upgradeToServerAdmin");
};
@@ -402,24 +388,16 @@ export const UserIdentitiesTable = () => {
const handleRemoveServerAdminAccess = async () => {
const { id } = popUp?.removeServerAdmin?.data as { id: string; username: string };
try {
await removeAdminAccess(id);
createNotification({
type: "success",
text: "Successfully removed server admin access from user"
});
} catch {
createNotification({
type: "error",
text: "Error removing server admin access from user"
});
}
handlePopUpClose("removeServerAdmin");
};
const handleRemoveUsers = async () => {
try {
await deleteUsers(selectedUsers.map((user) => user.id));
createNotification({
@@ -429,12 +407,6 @@ export const UserIdentitiesTable = () => {
setSelectedUsers([]);
handlePopUpClose("removeUsers");
} catch {
createNotification({
text: "Failed to remove users",
type: "error"
});
}
};
return (
@@ -6,7 +6,6 @@ import { useNavigate } from "@tanstack/react-router";
import { AnimatePresence, motion } from "framer-motion";
import { z } from "zod";
import { createNotification } from "@app/components/notifications";
// TODO(akhilmhdh): rewrite this into module functions in lib
import SecurityClient from "@app/components/utilities/SecurityClient";
import { Button, ContentLoader, FormControl, Input } from "@app/components/v2";
@@ -46,7 +45,6 @@ export const SignUpPage = () => {
const handleFormSubmit = async ({ email, password, firstName, lastName }: TFormSchema) => {
// avoid multi submission
if (isSubmitting) return;
try {
const res = await createAdminUser({
email,
password,
@@ -62,13 +60,6 @@ export const SignUpPage = () => {
// Part of migration to nextjs 14
localStorage.setItem("orgData.id", res.organization.id);
navigate({ to: "/admin" });
} catch (err) {
console.log(err);
createNotification({
type: "error",
text: "Failed to create admin"
});
}
};
if (config?.initialized) return <ContentLoader text="Redirecting to admin page..." />;
@@ -75,11 +75,7 @@ export const PasswordSetupPage = () => {
setTimeout(() => {
window.location.href = "/login";
}, 3000);
} catch (error) {
createNotification({
type: "error",
text: (error as Error).message ?? "Error setting password"
});
} catch {
navigate({ to: "/personal-settings" });
}
}
@@ -73,7 +73,6 @@ export const EmailConfirmationStep = ({
const { mutateAsync: verifyEmailVerificationCode } = useVerifyEmailVerificationCode();
const checkCode = async () => {
try {
await verifyEmailVerificationCode({ username, code });
setCodeError(false);
@@ -102,18 +101,11 @@ export const EmailConfirmationStep = ({
break;
}
}
} catch {
createNotification({
text: "Failed to verify code",
type: "error"
});
}
setCode("");
};
const resendCode = async () => {
try {
const queryParams = new URLSearchParams(window.location.search);
const token = queryParams.get("token");
if (!token) {
@@ -128,12 +120,6 @@ export const EmailConfirmationStep = ({
text: "Successfully resent code",
type: "success"
});
} catch {
createNotification({
text: "Failed to resend code",
type: "error"
});
}
};
return (
@@ -113,7 +113,6 @@ export const PkiAlertModal = ({ popUp, handlePopUpToggle }: Props) => {
alertUnit,
emails
}: FormData) => {
try {
if (!projectId) return;
const emailArray = emails
@@ -152,13 +151,6 @@ export const PkiAlertModal = ({ popUp, handlePopUpToggle }: Props) => {
text: `Successfully ${alert ? "updated" : "created"} alert`,
type: "success"
});
} catch (err) {
console.error(err);
createNotification({
text: `Failed to ${alert ? "updated" : "created"} alert`,
type: "error"
});
}
};
return (
@@ -22,7 +22,6 @@ export const PkiAlertsSection = () => {
] as const);
const onRemoveAlertSubmit = async (alertId: string) => {
try {
if (!projectId) return;
await deletePkiAlert({
@@ -36,13 +35,6 @@ export const PkiAlertsSection = () => {
});
handlePopUpClose("deletePkiAlert");
} catch (err) {
console.error(err);
createNotification({
text: "Failed to delete alert",
type: "error"
});
}
};
return (
@@ -62,7 +62,6 @@ export const PkiCollectionModal = ({ popUp, handlePopUpToggle }: Props) => {
}, [pkiCollection]);
const onFormSubmit = async ({ name, description }: FormData) => {
try {
if (!projectId) return;
if (pkiCollection) {
@@ -98,13 +97,6 @@ export const PkiCollectionModal = ({ popUp, handlePopUpToggle }: Props) => {
text: `Successfully ${pkiCollection ? "updated" : "created"} PKI collection`,
type: "success"
});
} catch (err) {
console.error(err);
createNotification({
text: `Failed to ${pkiCollection ? "updated" : "created"} PKI collection`,
type: "error"
});
}
};
return (
@@ -22,7 +22,6 @@ export const PkiCollectionSection = () => {
] as const);
const onRemovePkiCollectionSubmit = async (collectionId: string) => {
try {
if (!projectId) return;
await deletePkiCollection({
@@ -36,13 +35,6 @@ export const PkiCollectionSection = () => {
});
handlePopUpClose("deletePkiCollection");
} catch (err) {
console.error(err);
createNotification({
text: "Failed to delete PKI collection",
type: "error"
});
}
};
return (
@@ -57,7 +57,6 @@ const Page = () => {
] as const);
const onRemoveCaSubmit = async () => {
try {
if (!currentProject?.slug) return;
await deleteCa({
@@ -78,12 +77,6 @@ const Page = () => {
projectId
}
});
} catch {
createNotification({
text: "Failed to delete CA",
type: "error"
});
}
};
return (
@@ -84,7 +84,6 @@ export const CaRenewalModal = ({ popUp, handlePopUpToggle }: Props) => {
// }, [ca, parentCa]);
const onFormSubmit = async ({ type, notAfter }: FormData) => {
try {
if (!projectSlug || !popUpData.caId) return;
await renewCa({
@@ -102,9 +101,6 @@ export const CaRenewalModal = ({ popUp, handlePopUpToggle }: Props) => {
});
reset();
} catch (err) {
console.error(err);
}
};
return (
@@ -48,7 +48,6 @@ export const ExternalCaInstallForm = ({ caId, handlePopUpToggle }: Props) => {
}, []);
const onFormSubmit = async ({ certificate, certificateChain }: FormData) => {
try {
if (!csr || !caId || !currentProject?.slug) return;
await importCaCertificate({
@@ -65,12 +64,6 @@ export const ExternalCaInstallForm = ({ caId, handlePopUpToggle }: Props) => {
type: "success"
});
handlePopUpToggle("installCaCert", false);
} catch {
createNotification({
text: "Failed to install certificate for CA",
type: "error"
});
}
};
const downloadTxtFile = (filename: string, content: string) => {
@@ -101,7 +101,6 @@ export const InternalCaInstallForm = ({ caId, handlePopUpToggle }: Props) => {
}, [parentCa]);
const onFormSubmit = async ({ notAfter, maxPathLength }: FormData) => {
try {
if (!csr || !caId || !currentProject?.slug) return;
const { certificate, certificateChain } = await signIntermediate({
@@ -126,12 +125,6 @@ export const InternalCaInstallForm = ({ caId, handlePopUpToggle }: Props) => {
type: "success"
});
handlePopUpToggle("installCaCert", false);
} catch {
createNotification({
text: "Failed to install certificate for CA",
type: "error"
});
}
};
function generatePathLengthOpts(parentCaMaxPathLength: number): number[] {
@@ -175,7 +175,6 @@ export const CaModal = ({ popUp, handlePopUpToggle }: Props) => {
status,
configuration
}: FormData) => {
try {
if (!currentProject?.slug) return;
if (ca) {
@@ -210,13 +209,6 @@ export const CaModal = ({ popUp, handlePopUpToggle }: Props) => {
text: `Successfully ${ca ? "updated" : "created"} CA`,
type: "success"
});
} catch (err) {
console.error(err);
createNotification({
text: "Failed to create CA",
type: "error"
});
}
};
return (
@@ -27,7 +27,6 @@ export const CaSection = () => {
] as const);
const onRemoveCaSubmit = async (caName: string) => {
try {
if (!currentProject?.slug) return;
await deleteCa({ caName, projectId: currentProject.id, type: CaType.INTERNAL });
@@ -38,16 +37,9 @@ export const CaSection = () => {
});
handlePopUpClose("deleteCa");
} catch {
createNotification({
text: "Failed to delete CA",
type: "error"
});
}
};
const onUpdateCaStatus = async ({ caName, status }: { caName: string; status: CaStatus }) => {
try {
if (!currentProject?.slug) return;
await updateCa({ caName, projectId: currentProject.id, type: CaType.INTERNAL, status });
@@ -58,13 +50,6 @@ export const CaSection = () => {
});
handlePopUpClose("caStatus");
} catch (err) {
console.error(err);
createNotification({
text: `Failed to ${status === CaStatus.ACTIVE ? "enabled" : "disabled"} CA`,
type: "error"
});
}
};
return (
@@ -297,7 +297,6 @@ export const ExternalCaModal = ({ popUp, handlePopUpToggle }: Props) => {
status,
configuration: formConfiguration
}: FormData) => {
try {
if (!currentProject?.slug) return;
let configPayload: any;
@@ -347,13 +346,6 @@ export const ExternalCaModal = ({ popUp, handlePopUpToggle }: Props) => {
text: `Successfully ${ca ? "updated" : "created"} CA`,
type: "success"
});
} catch (err) {
console.error(err);
createNotification({
text: "Failed to create CA",
type: "error"
});
}
};
return (
@@ -23,7 +23,6 @@ export const ExternalCaSection = () => {
] as const);
const onRemoveCaSubmit = async (caName: string, type: CaType) => {
try {
if (!currentProject?.id) return;
await deleteCa({ caName, type, projectId: currentProject.id });
@@ -34,12 +33,6 @@ export const ExternalCaSection = () => {
});
handlePopUpClose("deleteCa");
} catch {
createNotification({
text: "Failed to delete CA",
type: "error"
});
}
};
const onUpdateCaStatus = async ({
@@ -51,7 +44,6 @@ export const ExternalCaSection = () => {
type: CaType;
status: CaStatus;
}) => {
try {
if (!currentProject?.slug) return;
await updateCa({ caName: name, type, status, projectId: currentProject.id });
@@ -62,13 +54,6 @@ export const ExternalCaSection = () => {
});
handlePopUpClose("caStatus");
} catch (err) {
console.error(err);
createNotification({
text: `Failed to ${status === CaStatus.ACTIVE ? "enable" : "disable"} CA`,
type: "error"
});
}
};
return (
@@ -71,7 +71,6 @@ export const CertificateImportModal = ({ popUp, handlePopUpToggle }: Props) => {
chainPem,
collectionId
}: FormData) => {
try {
if (!currentProject?.slug) return;
const { serialNumber, certificate, certificateChain, privateKey } = await importCertificate({
@@ -96,13 +95,6 @@ export const CertificateImportModal = ({ popUp, handlePopUpToggle }: Props) => {
text: "Successfully imported certificate",
type: "success"
});
} catch (err) {
console.error(err);
createNotification({
text: "Failed to import certificate",
type: "error"
});
}
};
return (
@@ -243,7 +243,6 @@ export const CertificateIssuanceModal = ({ popUp, handlePopUpToggle, profileId }
keyUsages,
extendedKeyUsages
}: FormData) => {
try {
if (!currentProject?.slug) {
createNotification({
text: "Project not found. Please refresh and try again.",
@@ -310,17 +309,6 @@ export const CertificateIssuanceModal = ({ popUp, handlePopUpToggle, profileId }
text: "Successfully created certificate",
type: "success"
});
} catch (err) {
console.error("Certificate creation failed:", err);
const errorMessage =
err instanceof Error
? err.message
: "An unexpected error occurred while creating the certificate";
createNotification({
text: `Failed to create certificate: ${errorMessage}`,
type: "error"
});
}
},
[
currentProject?.slug,
@@ -163,7 +163,6 @@ export const CertificateManageRenewalModal = ({ popUp, handlePopUpToggle }: Prop
}, [popUp.manageRenewal.isOpen, defaultRenewalDays, reset]);
const onUpdateRenewal = async (data: FormData) => {
try {
if (!currentProject?.slug) {
createNotification({
text: "Unable to update auto-renewal: Project not found. Please refresh the page and try again.",
@@ -186,15 +185,6 @@ export const CertificateManageRenewalModal = ({ popUp, handlePopUpToggle }: Prop
});
handlePopUpToggle("manageRenewal", false);
} catch (err) {
console.error(err);
createNotification({
text: isAutoRenewalEnabled
? "Failed to update auto-renewal configuration. Please check your inputs and try again."
: "Failed to enable auto-renewal. Please check your inputs and try again.",
type: "error"
});
}
};
const getModalTitle = () => {
@@ -186,7 +186,6 @@ export const CertificateModal = ({ popUp, handlePopUpToggle }: Props) => {
keyUsages,
extendedKeyUsages
}: FormData) => {
try {
if (!currentProject?.slug) return;
const { serialNumber, certificate, certificateChain, privateKey } = await createCertificate({
@@ -218,13 +217,6 @@ export const CertificateModal = ({ popUp, handlePopUpToggle }: Props) => {
text: "Successfully created certificate",
type: "success"
});
} catch (err) {
console.error(err);
createNotification({
text: "Failed to create certificate",
type: "error"
});
}
};
useEffect(() => {
@@ -61,7 +61,6 @@ export const CertificateRenewalConfigModal = ({ popUp, handlePopUpToggle }: Prop
const renewBeforeDays = watch("renewBeforeDays");
const onSubmit = async (data: FormData) => {
try {
if (!currentProject?.slug) {
createNotification({
text: "Project not found",
@@ -82,13 +81,6 @@ export const CertificateRenewalConfigModal = ({ popUp, handlePopUpToggle }: Prop
});
handlePopUpToggle("configureRenewal", false);
} catch (err) {
console.error(err);
createNotification({
text: "Failed to update auto-renewal configuration",
type: "error"
});
}
};
return (
@@ -19,7 +19,6 @@ export const CertificateRenewalDisableModal = ({ popUp, handlePopUpToggle }: Pro
};
const onDisableConfirm = async () => {
try {
if (!currentProject?.slug) {
createNotification({
text: "Project not found",
@@ -40,13 +39,6 @@ export const CertificateRenewalDisableModal = ({ popUp, handlePopUpToggle }: Pro
});
handlePopUpToggle("disableRenewal", false);
} catch (err) {
console.error(err);
createNotification({
text: "Failed to disable auto-renewal",
type: "error"
});
}
};
return (
@@ -18,7 +18,6 @@ export const CertificateRenewalModal = ({ popUp, handlePopUpToggle }: Props) =>
const { mutateAsync: renewCertificate, isPending: isRenewing } = useRenewCertificate();
const onRenewConfirm = async () => {
try {
const { certificateId } = popUp.renewCertificate.data as { certificateId: string };
await renewCertificate({
@@ -31,9 +30,6 @@ export const CertificateRenewalModal = ({ popUp, handlePopUpToggle }: Props) =>
});
handlePopUpToggle("renewCertificate", false);
} catch (err) {
console.error(err);
}
};
const certificateData = popUp.renewCertificate.data as {
@@ -48,7 +48,6 @@ export const CertificateRevocationModal = ({ popUp, handlePopUpToggle }: Props)
});
const onFormSubmit = async ({ revocationReason }: FormData) => {
try {
if (!currentProject?.slug) return;
const { serialNumber } = popUp.revokeCertificate.data as { serialNumber: string };
@@ -66,13 +65,6 @@ export const CertificateRevocationModal = ({ popUp, handlePopUpToggle }: Props)
text: "Successfully revoked certificate",
type: "success"
});
} catch (err) {
console.error(err);
createNotification({
text: "Failed to revoke certificate",
type: "error"
});
}
};
return (
@@ -159,7 +159,6 @@ export const CertificateTemplateModal = ({ popUp, handlePopUpToggle, caId }: Pro
return;
}
try {
if (certTemplate) {
await updateCertTemplate({
id: certTemplate.id,
@@ -215,13 +214,6 @@ export const CertificateTemplateModal = ({ popUp, handlePopUpToggle, caId }: Pro
reset();
handlePopUpToggle("certificateTemplate", false);
} catch (err) {
console.error(err);
createNotification({
text: "Failed to save changes",
type: "error"
});
}
};
return (
@@ -41,7 +41,6 @@ export const CertificateTemplatesSection = ({ caId }: Props) => {
return;
}
try {
await deleteCertTemplate({
id,
projectId: currentProject.id
@@ -53,13 +52,6 @@ export const CertificateTemplatesSection = ({ caId }: Props) => {
});
handlePopUpClose("deleteCertificateTemplate");
} catch (err) {
console.error(err);
createNotification({
text: "Failed to delete certificate template",
type: "error"
});
}
};
return (
@@ -42,7 +42,6 @@ export const CertificatesSection = () => {
] as const);
const onRemoveCertificateSubmit = async (serialNumber: string) => {
try {
if (!currentProject?.slug) return;
await deleteCert({ serialNumber, projectSlug: currentProject.slug });
@@ -53,13 +52,6 @@ export const CertificatesSection = () => {
});
handlePopUpClose("deleteCertificate");
} catch (err) {
console.error(err);
createNotification({
text: "Failed to delete certificate",
type: "error"
});
}
};
return (
@@ -118,7 +118,6 @@ export const CertificatesTable = ({ handlePopUpOpen }: Props) => {
}, [caData]);
const handleDisableAutoRenewal = async (certificateId: string, commonName: string) => {
try {
if (!currentProject?.slug) {
createNotification({
text: "Unable to disable auto-renewal: Project not found. Please refresh the page and try again.",
@@ -137,13 +136,6 @@ export const CertificatesTable = ({ handlePopUpOpen }: Props) => {
text: `Auto-renewal disabled for ${commonName}`,
type: "success"
});
} catch (err) {
console.error(err);
createNotification({
text: "Failed to disable auto-renewal. Please try again or contact support if the issue persists.",
type: "error"
});
}
};
return (
@@ -217,7 +217,6 @@ export const PkiSyncsTable = ({ pkiSyncs }: Props) => {
const isAutoSyncEnabled = !pkiSync.isAutoSyncEnabled;
try {
await updateSync.mutateAsync({
syncId: pkiSync.id,
projectId: pkiSync.projectId,
@@ -229,18 +228,11 @@ export const PkiSyncsTable = ({ pkiSyncs }: Props) => {
text: `Successfully ${isAutoSyncEnabled ? "enabled" : "disabled"} auto-sync for ${destinationName} Sync`,
type: "success"
});
} catch {
createNotification({
text: `Failed to ${isAutoSyncEnabled ? "enable" : "disable"} auto-sync for ${destinationName} Sync`,
type: "error"
});
}
};
const handleTriggerSync = async (pkiSync: TPkiSync) => {
const destinationName = PKI_SYNC_MAP[pkiSync.destination].name;
try {
await triggerSync.mutateAsync({
syncId: pkiSync.id,
destination: pkiSync.destination,
@@ -251,12 +243,6 @@ export const PkiSyncsTable = ({ pkiSyncs }: Props) => {
text: `Successfully triggered ${destinationName} Sync`,
type: "success"
});
} catch {
createNotification({
text: `Failed to trigger ${destinationName} Sync`,
type: "error"
});
}
};
return (
@@ -45,7 +45,6 @@ export const PkiCollectionPage = () => {
] as const);
const onDeletePkiCollectionSubmit = async (collectionIdToDelete: string) => {
try {
if (!projectId) return;
await deletePkiCollection({
@@ -64,12 +63,6 @@ export const PkiCollectionPage = () => {
projectId: params.projectId
}
});
} catch {
createNotification({
text: "Failed to delete PKI collection",
type: "error"
});
}
};
return (
@@ -51,7 +51,6 @@ const Page = () => {
] as const);
const onRemoveSubscriberSubmit = async (subscriberNameToDelete: string) => {
try {
if (!projectId) return;
await deletePkiSubscriber({ subscriberName: subscriberNameToDelete, projectId });
@@ -68,13 +67,6 @@ const Page = () => {
projectId
}
});
} catch (err) {
console.error(err);
createNotification({
text: "Failed to delete subscriber",
type: "error"
});
}
};
return (
@@ -70,7 +70,6 @@ export const PkiSubscriberDetailsSection = ({ subscriberName, handlePopUpOpen }:
useOrderPkiSubscriberCert();
const onIssuePkiSubscriberCert = async () => {
try {
if (pkiSubscriber?.supportsImmediateCertIssuance) {
const response = await issuePkiSubscriberCert({ subscriberName, projectId });
@@ -95,13 +94,6 @@ export const PkiSubscriberDetailsSection = ({ subscriberName, handlePopUpOpen }:
type: "info"
});
}
} catch (err) {
console.error(err);
createNotification({
text: "Failed to issue certificate",
type: "error"
});
}
};
const canIssuePkiSubscriberCert = permission.can(
@@ -276,7 +276,6 @@ export const PkiSubscriberModal = ({ popUp, handlePopUpToggle }: Props) => {
locality,
emailAddress
}: FormData) => {
try {
if (!projectId) return;
if (!caId) {
@@ -392,13 +391,6 @@ export const PkiSubscriberModal = ({ popUp, handlePopUpToggle }: Props) => {
text: `Successfully ${pkiSubscriber ? "updated" : "added"} PKI subscriber`,
type: "success"
});
} catch (err) {
console.error(err);
createNotification({
text: `Failed to ${pkiSubscriber ? "update" : "add"} PKI subscriber`,
type: "error"
});
}
};
return (
@@ -32,7 +32,6 @@ export const PkiSubscriberSection = () => {
] as const);
const onRemovePkiSubscriberSubmit = async (subscriberName: string) => {
try {
const subscriber = await deletePkiSubscriber({ subscriberName, projectId });
createNotification({
@@ -41,13 +40,6 @@ export const PkiSubscriberSection = () => {
});
handlePopUpClose("deletePkiSubscriber");
} catch (err) {
console.error(err);
createNotification({
text: "Failed to delete PKI subscriber",
type: "error"
});
}
};
const onUpdatePkiSubscriberStatus = async ({
@@ -57,7 +49,6 @@ export const PkiSubscriberSection = () => {
subscriberName: string;
status: PkiSubscriberStatus;
}) => {
try {
if (!currentProject?.slug) return;
await updatePkiSubscriber({ subscriberName, projectId, status });
@@ -68,13 +59,6 @@ export const PkiSubscriberSection = () => {
});
handlePopUpClose("pkiSubscriberStatus");
} catch (err) {
console.error(err);
createNotification({
text: `Failed to ${status === PkiSubscriberStatus.ACTIVE ? "enable" : "disable"} subscriber`,
type: "error"
});
}
};
const subscriberStatusData = popUp?.pkiSubscriberStatus?.data as {
@@ -86,7 +86,6 @@ export const PkiSyncActionTriggers = ({ pkiSync }: Props) => {
}, [pkiSync.id, setIsIdCopied]);
const handleTriggerSync = useCallback(async () => {
try {
await triggerSyncMutation.mutateAsync({
syncId: id,
destination,
@@ -96,17 +95,9 @@ export const PkiSyncActionTriggers = ({ pkiSync }: Props) => {
text: "PKI sync job queued successfully",
type: "success"
});
} catch (error) {
console.error("Failed to trigger sync:", error);
createNotification({
text: "Failed to trigger PKI sync",
type: "error"
});
}
}, [triggerSyncMutation, id, destination, projectId]);
const handleToggleAutoSync = useCallback(async () => {
try {
await updatePkiSyncMutation.mutateAsync({
syncId: id,
projectId,
@@ -117,13 +108,6 @@ export const PkiSyncActionTriggers = ({ pkiSync }: Props) => {
text: `Auto-sync ${pkiSync.isAutoSyncEnabled ? "disabled" : "enabled"} successfully`,
type: "success"
});
} catch (error) {
console.error("Failed to toggle auto-sync:", error);
createNotification({
text: "Failed to toggle auto-sync",
type: "error"
});
}
}, [updatePkiSyncMutation, id, projectId, pkiSync.isAutoSyncEnabled]);
const permissionSubject = subject(ProjectPermissionSub.PkiSyncs, {
@@ -78,7 +78,6 @@ export const PkiTemplateListPage = () => {
const deleteCertTemplate = useDeleteCertTemplateV2();
const onRemovePkiSubscriberSubmit = async () => {
try {
const pkiTemplate = await deleteCertTemplate.mutateAsync({
projectId: currentProject.id,
templateName: popUp?.deleteTemplate?.data?.name
@@ -90,13 +89,6 @@ export const PkiTemplateListPage = () => {
});
handlePopUpClose("deleteTemplate");
} catch (err) {
console.error(err);
createNotification({
text: "Failed to delete PKI subscriber",
type: "error"
});
}
};
return (
@@ -128,7 +128,6 @@ export const PkiTemplateForm = ({ certTemplate, handlePopUpToggle }: Props) => {
return;
}
try {
if (certTemplate) {
await updateCertTemplate({
templateName: certTemplate.name,
@@ -182,13 +181,6 @@ export const PkiTemplateForm = ({ certTemplate, handlePopUpToggle }: Props) => {
reset();
handlePopUpToggle(false);
} catch (err) {
console.error(err);
createNotification({
text: "Failed to save changes",
type: "error"
});
}
};
return (
@@ -51,7 +51,6 @@ export const CertificateProfilesTab = () => {
const handleDeleteConfirm = async () => {
if (!selectedProfile) return;
try {
await deleteProfile.mutateAsync({
profileId: selectedProfile.id
});
@@ -61,12 +60,6 @@ export const CertificateProfilesTab = () => {
text: `Certificate profile "${selectedProfile.slug}" deleted successfully`,
type: "success"
});
} catch (error) {
console.error(
`Failed to delete profile "${selectedProfile.slug}" (ID: ${selectedProfile.id}):`,
error
);
}
};
return (
@@ -236,7 +236,6 @@ export const CreateProfileModal = ({ isOpen, onClose, profile, mode = "create" }
}, [isEdit, profile, reset]);
const onFormSubmit = async (data: FormData) => {
try {
if (!currentProject?.id && !isEdit) return;
if (isEdit) {
@@ -287,13 +286,6 @@ export const CreateProfileModal = ({ isOpen, onClose, profile, mode = "create" }
reset();
onClose();
} catch (error) {
console.error(`Error ${isEdit ? "updating" : "creating"} profile:`, error);
createNotification({
text: `Failed to ${isEdit ? "update" : "create"} certificate profile`,
type: "error"
});
}
};
return (
@@ -48,7 +48,6 @@ export const CertificateTemplatesV2Tab = () => {
const handleDeleteConfirm = async () => {
if (!selectedTemplate) return;
try {
await deleteTemplateV2.mutateAsync({
templateId: selectedTemplate.id
});
@@ -58,13 +57,6 @@ export const CertificateTemplatesV2Tab = () => {
text: `Certificate template "${selectedTemplate.name}" deleted successfully`,
type: "success"
});
} catch (error) {
console.error("Failed to delete template:", error);
createNotification({
text: "Failed to delete certificate template",
type: "error"
});
}
};
return (
@@ -407,7 +407,6 @@ export const CreateTemplateModal = ({ isOpen, onClose, template, mode = "create"
};
const onFormSubmit = async (data: FormData) => {
try {
if (!currentProject?.id && !isEdit) return;
const hasEmptyAttributeValues = data.attributes?.some(
@@ -453,13 +452,6 @@ export const CreateTemplateModal = ({ isOpen, onClose, template, mode = "create"
reset();
onClose();
} catch (error) {
console.error(`Error ${isEdit ? "updating" : "creating"} template:`, error);
createNotification({
text: `Failed to ${isEdit ? "update" : "create"} certificate template`,
type: "error"
});
}
};
const addAttribute = () => {
@@ -17,7 +17,6 @@ export const DeleteKmipClientModal = ({ isOpen, onOpenChange, kmipClient }: Prop
const { id, projectId, name } = kmipClient;
const handleDeleteKmipClient = async () => {
try {
await deleteKmipClients.mutateAsync({
id,
projectId
@@ -29,16 +28,6 @@ export const DeleteKmipClientModal = ({ isOpen, onOpenChange, kmipClient }: Prop
});
onOpenChange(false);
} catch (err) {
console.error(err);
const error = err as any;
const text = error?.response?.data?.message ?? "Failed to delete KMIP client";
createNotification({
text,
type: "error"
});
}
};
return (
@@ -98,20 +98,12 @@ const KmipClientForm = ({ onComplete, kmipClient }: FormProps) => {
.map(([key]) => key as KmipPermission)
});
try {
await mutation;
createNotification({
text: `Successfully ${isUpdate ? "updated" : "added"} KMIP client`,
type: "success"
});
onComplete();
} catch (err) {
console.error(err);
createNotification({
text: `Failed to ${isUpdate ? "update" : "add"} KMIP client`,
type: "error"
});
}
};
return (
@@ -52,7 +52,6 @@ const DecryptForm = ({ cmek }: FormProps) => {
});
const handleDecryptData = async (formData: FormData) => {
try {
const data = await cmekDecrypt.mutateAsync({ ...formData, keyId: cmek.id });
createNotification({
text: "Successfully decrypted data",
@@ -62,13 +61,6 @@ const DecryptForm = ({ cmek }: FormProps) => {
setPlaintext(
shouldDecode ? Buffer.from(decodeBase64(data.plaintext)).toString("utf8") : data.plaintext
);
} catch (err) {
console.error(err);
createNotification({
text: "Failed to decrypt data",
type: "error"
});
}
};
useEffect(() => {
@@ -53,19 +53,11 @@ const EncryptForm = ({ cmek }: FormProps) => {
});
const handleEncryptData = async (formData: FormData) => {
try {
await cmekEncrypt.mutateAsync({ ...formData, keyId: cmek.id });
createNotification({
text: "Successfully encrypted data",
type: "success"
});
} catch (err) {
console.error(err);
createNotification({
text: "Failed to encrypt data",
type: "error"
});
}
};
const ciphertext = cmekEncrypt.data?.ciphertext;
@@ -86,20 +86,12 @@ const CmekForm = ({ onComplete, cmek }: FormProps) => {
encryptionAlgorithm: encryptionAlgorithm as AsymmetricKeyAlgorithm | SymmetricKeyAlgorithm
});
try {
await mutation;
createNotification({
text: `Successfully ${isUpdate ? "updated" : "added"} key`,
type: "success"
});
onComplete();
} catch (err) {
console.error(err);
createNotification({
text: `Failed to ${isUpdate ? "update" : "add"} key`,
type: "error"
});
}
};
const selectedKeyUsage = watch("keyUsage");
@@ -59,19 +59,11 @@ const SignForm = ({ cmek }: FormProps) => {
});
const handleSignData = async (formData: FormData) => {
try {
await cmekSign.mutateAsync({ ...formData, keyId: cmek.id });
createNotification({
text: "Successfully signed data",
type: "success"
});
} catch (err) {
console.error(err);
createNotification({
text: "Failed to sign data",
type: "error"
});
}
};
const signature = cmekSign.data?.signature;
@@ -152,7 +152,6 @@ export const CmekTable = () => {
const updateCmek = useUpdateCmek();
const handleDisableCmek = async ({ id: keyId, isDisabled }: TCmek) => {
try {
await updateCmek.mutateAsync({
keyId,
projectId,
@@ -163,17 +162,6 @@ export const CmekTable = () => {
text: `Key successfully ${isDisabled ? "enabled" : "disabled"}`,
type: "success"
});
} catch (err) {
console.error(err);
const error = err as any;
const text =
error?.response?.data?.message ?? `Failed to ${isDisabled ? "enable" : "disable"} key`;
createNotification({
text,
type: "error"
});
}
};
const cannotEditKey = permission.cannot(
@@ -69,7 +69,6 @@ const VerifyForm = ({ cmek }: FormProps) => {
});
const handleVerifyData = async (formData: FormData) => {
try {
const result = await cmekVerify.mutateAsync({ ...formData, keyId: cmek.id });
if (result.signatureValid) {
@@ -84,13 +83,6 @@ const VerifyForm = ({ cmek }: FormProps) => {
type: "error"
});
}
} catch (err) {
console.error(err);
createNotification({
text: "Failed to sign data",
type: "error"
});
}
};
const signature = watch("signature");
@@ -16,7 +16,6 @@ export const DeleteCmekModal = ({ isOpen, onOpenChange, cmek }: Props) => {
const { id: keyId, projectId, name } = cmek;
const handleDeleteCmek = async () => {
try {
await deleteCmek.mutateAsync({
keyId,
projectId
@@ -28,16 +27,6 @@ export const DeleteCmekModal = ({ isOpen, onOpenChange, cmek }: Props) => {
});
onOpenChange(false);
} catch (err) {
console.error(err);
const error = err as any;
const text = error?.response?.data?.message ?? "Failed to delete key";
createNotification({
text,
type: "error"
});
}
};
return (
@@ -74,7 +74,6 @@ export const OrgGroupModal = ({ popUp, handlePopUpClose, handlePopUpToggle }: Pr
}, [popUp?.group?.data, roles]);
const onGroupModalSubmit = async ({ name, slug, role }: TGroupFormData) => {
try {
if (!currentOrg?.id) return;
const group = popUp?.group?.data as {
@@ -105,12 +104,6 @@ export const OrgGroupModal = ({ popUp, handlePopUpClose, handlePopUpToggle }: Pr
text: `Successfully ${popUp?.group?.data ? "updated" : "created"} group`,
type: "success"
});
} catch {
createNotification({
text: `Failed to ${popUp?.group?.data ? "updated" : "created"} group`,
type: "error"
});
}
};
return (
@@ -36,7 +36,6 @@ export const OrgGroupsSection = () => {
};
const onDeleteGroupSubmit = async ({ name, groupId }: { name: string; groupId: string }) => {
try {
await deleteMutateAsync({
id: groupId
});
@@ -44,13 +43,6 @@ export const OrgGroupsSection = () => {
text: `Successfully deleted the group named ${name}`,
type: "success"
});
} catch (err) {
console.error(err);
createNotification({
text: `Failed to delete the group named ${name}`,
type: "error"
});
}
handlePopUpClose("deleteGroup");
};
@@ -79,7 +79,6 @@ export const OrgGroupsTable = ({ handlePopUpOpen }: Props) => {
const { data: roles } = useGetOrgRoles(orgId);
const handleChangeRole = async ({ id, role }: { id: string; role: string }) => {
try {
await updateMutateAsync({
id,
role
@@ -89,13 +88,6 @@ export const OrgGroupsTable = ({ handlePopUpOpen }: Props) => {
text: "Successfully updated group role",
type: "success"
});
} catch (err) {
console.error(err);
createNotification({
text: "Failed to update group role",
type: "error"
});
}
};
const {
@@ -140,7 +140,6 @@ export const IdentityAliCloudAuthForm = ({
accessTokenNumUsesLimit,
accessTokenTrustedIps
}: FormData) => {
try {
if (!identityId) return;
if (data) {
@@ -173,12 +172,6 @@ export const IdentityAliCloudAuthForm = ({
});
reset();
} catch {
createNotification({
text: `Failed to ${isUpdate ? "update" : "configure"} identity`,
type: "error"
});
}
};
return (
@@ -103,7 +103,6 @@ export const IdentityAuthTemplateModal = ({ popUp, handlePopUpToggle }: Props) =
const selectedMethod = watch("method");
const onFormSubmit = async (data: FormData) => {
try {
if (isEdit && template) {
await updateTemplate({
templateId: template.id,
@@ -142,17 +141,6 @@ export const IdentityAuthTemplateModal = ({ popUp, handlePopUpToggle }: Props) =
handlePopUpToggle(isEdit ? "editTemplate" : "createTemplate", false);
reset();
} catch (err) {
console.error(err);
const error = err as any;
const text =
error?.response?.data?.message ?? `Failed to ${isEdit ? "update" : "create"} auth template`;
createNotification({
text,
type: "error"
});
}
};
const handleClose = () => {
@@ -150,7 +150,6 @@ export const IdentityAwsAuthForm = ({
accessTokenNumUsesLimit,
accessTokenTrustedIps
}: FormData) => {
try {
if (!identityId) return;
if (data) {
@@ -187,12 +186,6 @@ export const IdentityAwsAuthForm = ({
});
reset();
} catch {
createNotification({
text: `Failed to ${isUpdate ? "update" : "configure"} identity`,
type: "error"
});
}
};
return (
@@ -146,7 +146,6 @@ export const IdentityAzureAuthForm = ({
accessTokenNumUsesLimit,
accessTokenTrustedIps
}: FormData) => {
try {
if (!identityId) return;
if (data) {
@@ -183,12 +182,6 @@ export const IdentityAzureAuthForm = ({
});
reset();
} catch {
createNotification({
text: `Failed to ${isUpdate ? "update" : "configure"} identity`,
type: "error"
});
}
};
return (
@@ -155,7 +155,6 @@ export const IdentityGcpAuthForm = ({
accessTokenNumUsesLimit,
accessTokenTrustedIps
}: FormData) => {
try {
if (!identityId) return;
if (data) {
@@ -194,12 +193,6 @@ export const IdentityGcpAuthForm = ({
});
reset();
} catch {
createNotification({
text: `Failed to ${isUpdate ? "update" : "configure"} identity`,
type: "error"
});
}
};
return (
@@ -220,7 +220,6 @@ export const IdentityJwtAuthForm = ({
boundClaims,
boundSubject
}: FormData) => {
try {
if (!identityId) {
return;
}
@@ -269,12 +268,6 @@ export const IdentityJwtAuthForm = ({
});
reset();
} catch {
createNotification({
text: `Failed to ${isUpdate ? "update" : "configure"} identity`,
type: "error"
});
}
};
return (
@@ -314,7 +314,6 @@ export const IdentityKubernetesAuthForm = ({
tokenReviewMode,
accessTokenTrustedIps
}: FormData) => {
try {
if (!identityId) return;
if (data) {
@@ -373,12 +372,6 @@ export const IdentityKubernetesAuthForm = ({
});
reset();
} catch {
createNotification({
text: `Failed to ${isUpdate ? "update" : "configure"} identity`,
type: "error"
});
}
};
const tokenReviewMode = watch("tokenReviewMode");
@@ -316,7 +316,6 @@ export const IdentityLdapAuthForm = ({
}, [subscription, handlePopUpOpen, handlePopUpToggle]);
const onFormSubmit = async (formData: FormData) => {
try {
if (!identityId) return;
const {
@@ -387,12 +386,6 @@ export const IdentityLdapAuthForm = ({
});
reset();
} catch {
createNotification({
text: `Failed to ${isUpdate ? "update" : "configure"} identity`,
type: "error"
});
}
};
return (
@@ -42,7 +42,6 @@ export const IdentityLinkForm = ({ onClose }: Props) => {
});
const onFormSubmit = async ({ identity, role }: FormData) => {
try {
await createMutateAsync({
identityId: identity.id,
roles: [{ role: role.slug, isTemporary: false }]
@@ -57,16 +56,6 @@ export const IdentityLinkForm = ({ onClose }: Props) => {
identityId: identity.id
}
});
} catch (err) {
console.error(err);
const error = err as any;
const text = error?.response?.data?.message ?? "Failed to link identity";
createNotification({
text,
type: "error"
});
}
};
return (
@@ -108,7 +108,6 @@ export const IdentityModal = ({ popUp, handlePopUpToggle }: Props) => {
}, [popUp?.identity?.data, roles]);
const onFormSubmit = async ({ name, role, metadata, hasDeleteProtection }: FormData) => {
try {
const identity = popUp?.identity?.data as {
identityId: string;
name: string;
@@ -171,18 +170,6 @@ export const IdentityModal = ({ popUp, handlePopUpToggle }: Props) => {
});
reset();
} catch (err) {
console.error(err);
const error = err as any;
const text =
error?.response?.data?.message ??
`Failed to ${popUp?.identity?.data ? "update" : "create"} identity`;
createNotification({
text,
type: "error"
});
}
};
return (
@@ -152,7 +152,6 @@ export const IdentityOciAuthForm = ({
accessTokenNumUsesLimit,
accessTokenTrustedIps
}: FormData) => {
try {
if (!identityId) return;
if (data) {
@@ -187,12 +186,6 @@ export const IdentityOciAuthForm = ({
});
reset();
} catch {
createNotification({
text: `Failed to ${isUpdate ? "update" : "configure"} identity`,
type: "error"
});
}
};
return (
@@ -204,7 +204,6 @@ export const IdentityOidcAuthForm = ({
claimMetadataMapping,
boundSubject
}: FormData) => {
try {
if (!identityId) {
return;
}
@@ -255,12 +254,6 @@ export const IdentityOidcAuthForm = ({
});
reset();
} catch {
createNotification({
text: `Failed to ${isUpdate ? "update" : "configure"} identity`,
type: "error"
});
}
};
return (
@@ -56,7 +56,6 @@ export const IdentitySection = withPermission(
const isEnterprise = subscription?.slug === "enterprise";
const onDeleteIdentitySubmit = async (identityId: string) => {
try {
await deleteMutateAsync({
identityId,
organizationId: orgId
@@ -68,20 +67,9 @@ export const IdentitySection = withPermission(
});
handlePopUpClose("deleteIdentity");
} catch (err) {
console.error(err);
const error = err as any;
const text = error?.response?.data?.message ?? "Failed to delete identity";
createNotification({
text,
type: "error"
});
}
};
const onDeleteTemplateSubmit = async (templateId: string) => {
try {
await deleteTemplateMutateAsync({
templateId,
organizationId: orgId
@@ -93,16 +81,6 @@ export const IdentitySection = withPermission(
});
handlePopUpClose("deleteTemplate");
} catch (err) {
console.error(err);
const error = err as any;
const text = error?.response?.data?.message ?? "Failed to delete template";
createNotification({
text,
type: "error"
});
}
};
return (

Some files were not shown because too many files have changed in this diff Show More