Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

refactor: streamline modal close handlers and completion callbacks across various components

Victor Santosb26fb73053b9
diff --git a/frontend/src/components/features/WishForm.tsx b/frontend/src/components/features/WishForm.tsx
index 118900bc92..28107809aa 100644
--- a/frontend/src/components/features/WishForm.tsx
+++ b/frontend/src/components/features/WishForm.tsx
@@ -35,23 +35,16 @@ export const WishForm = () => {
const [isOpen, setIsOpen] = useToggle(false);
const createWish = async (data: TFormData) => {
- try {
- await mutateAsync({
- text: data.text
- });
+ await mutateAsync({
+ text: data.text
+ });
- createNotification({
- text: "Your wish has been sent to the Infisical team!",
- type: "success"
- });
+ createNotification({
+ text: "Your wish has been sent to the Infisical team!",
+ type: "success"
+ });
- setIsOpen.off();
- } catch {
- createNotification({
- text: "An error occured while sending your wish to the Infisical team.",
- type: "error"
- });
- }
+ setIsOpen.off();
};
return (
diff --git a/frontend/src/components/organization/CreateOrgModal/CreateOrgModal.tsx b/frontend/src/components/organization/CreateOrgModal/CreateOrgModal.tsx
index 23c3fe6a53..84931f84a1 100644
--- a/frontend/src/components/organization/CreateOrgModal/CreateOrgModal.tsx
+++ b/frontend/src/components/organization/CreateOrgModal/CreateOrgModal.tsx
@@ -43,35 +43,27 @@ export const CreateOrgModal: FC<CreateOrgModalProps> = ({ isOpen, onClose }) =>
const { mutateAsync: selectOrg } = useSelectOrganization();
const onFormSubmit = async ({ name }: FormData) => {
- try {
- const organization = await createOrg({
- name
- });
+ const organization = await createOrg({
+ name
+ });
- await selectOrg({
- organizationId: organization.id
- });
+ await selectOrg({
+ organizationId: organization.id
+ });
- createNotification({
- text: "Successfully created organization",
- type: "success"
- });
+ createNotification({
+ text: "Successfully created organization",
+ type: "success"
+ });
- navigate({
- to: "/organization/projects"
- });
+ navigate({
+ to: "/organization/projects"
+ });
- localStorage.setItem("orgData.id", organization.id);
+ localStorage.setItem("orgData.id", organization.id);
- reset();
- onClose();
- } catch (err) {
- console.error(err);
- createNotification({
- text: "Failed to created organization",
- type: "error"
- });
- }
+ reset();
+ onClose();
};
return (
diff --git a/frontend/src/components/pki-syncs/DeletePkiSyncModal.tsx b/frontend/src/components/pki-syncs/DeletePkiSyncModal.tsx
index e465d3f342..c01efcbf2b 100644
--- a/frontend/src/components/pki-syncs/DeletePkiSyncModal.tsx
+++ b/frontend/src/components/pki-syncs/DeletePkiSyncModal.tsx
@@ -20,28 +20,19 @@ export const DeletePkiSyncModal = ({ isOpen, onOpenChange, pkiSync, onComplete }
const handleDeletePkiSync = async () => {
const destinationName = PKI_SYNC_MAP[destination].name;
- try {
- await deleteSync.mutateAsync({
- syncId,
- projectId,
- destination
- });
-
- createNotification({
- text: `Successfully deleted ${destinationName} PKI Sync`,
- type: "success"
- });
-
- if (onComplete) onComplete();
- onOpenChange(false);
- } catch (err) {
- console.error(err);
-
- createNotification({
- text: `Failed to delete ${destinationName} PKI Sync`,
- type: "error"
- });
- }
+ await deleteSync.mutateAsync({
+ syncId,
+ projectId,
+ destination
+ });
+
+ createNotification({
+ text: `Successfully deleted ${destinationName} PKI Sync`,
+ type: "success"
+ });
+
+ if (onComplete) onComplete();
+ onOpenChange(false);
};
return (
diff --git a/frontend/src/components/pki-syncs/PkiSyncImportCertificatesModal.tsx b/frontend/src/components/pki-syncs/PkiSyncImportCertificatesModal.tsx
index 33b06dbe47..43192c5e3c 100644
--- a/frontend/src/components/pki-syncs/PkiSyncImportCertificatesModal.tsx
+++ b/frontend/src/components/pki-syncs/PkiSyncImportCertificatesModal.tsx
@@ -21,27 +21,18 @@ const Content = ({ pkiSync, onComplete }: ContentProps) => {
const triggerImportCertificates = useTriggerPkiSyncImportCertificates();
const handleTriggerImportCertificates = async () => {
- try {
- await triggerImportCertificates.mutateAsync({
- syncId,
- destination,
- projectId
- });
+ await triggerImportCertificates.mutateAsync({
+ syncId,
+ destination,
+ projectId
+ });
- createNotification({
- text: `Successfully triggered certificate import for ${destinationName} Sync`,
- type: "success"
- });
+ createNotification({
+ text: `Successfully triggered certificate import for ${destinationName} Sync`,
+ type: "success"
+ });
- onComplete();
- } catch (err) {
- console.error(err);
-
- createNotification({
- text: `Failed to trigger certificate import for ${destinationName} Sync`,
- type: "error"
- });
- }
+ onComplete();
};
return (
diff --git a/frontend/src/components/pki-syncs/PkiSyncRemoveCertificatesModal.tsx b/frontend/src/components/pki-syncs/PkiSyncRemoveCertificatesModal.tsx
index f178552897..cee845381e 100644
--- a/frontend/src/components/pki-syncs/PkiSyncRemoveCertificatesModal.tsx
+++ b/frontend/src/components/pki-syncs/PkiSyncRemoveCertificatesModal.tsx
@@ -21,27 +21,18 @@ const Content = ({ pkiSync, onComplete }: ContentProps) => {
const triggerRemoveCertificates = useTriggerPkiSyncRemoveCertificates();
const handleTriggerRemoveCertificates = async () => {
- try {
- await triggerRemoveCertificates.mutateAsync({
- syncId,
- destination,
- projectId
- });
+ await triggerRemoveCertificates.mutateAsync({
+ syncId,
+ destination,
+ projectId
+ });
- createNotification({
- text: `Successfully triggered certificate removal for ${destinationName} Sync`,
- type: "success"
- });
+ createNotification({
+ text: `Successfully triggered certificate removal for ${destinationName} Sync`,
+ type: "success"
+ });
- onComplete();
- } catch (err) {
- console.error(err);
-
- createNotification({
- text: `Failed to trigger certificate removal for ${destinationName} Sync`,
- type: "error"
- });
- }
+ onComplete();
};
return (
diff --git a/frontend/src/components/pki-syncs/forms/CreatePkiSyncForm.tsx b/frontend/src/components/pki-syncs/forms/CreatePkiSyncForm.tsx
index 582518bd7c..085e57882f 100644
--- a/frontend/src/components/pki-syncs/forms/CreatePkiSyncForm.tsx
+++ b/frontend/src/components/pki-syncs/forms/CreatePkiSyncForm.tsx
@@ -72,14 +72,8 @@ export const CreatePkiSyncForm = ({ destination, onComplete, onCancel }: Props)
type: "success"
});
onComplete(pkiSync);
- } catch (err: Error | unknown) {
- console.error(err);
+ } catch {
setShowConfirmation(false);
- createNotification({
- title: `Failed to add ${destinationName} Certificate Sync`,
- text: err instanceof Error ? err.message : "An unknown error occurred",
- type: "error"
- });
}
};
diff --git a/frontend/src/components/pki-syncs/forms/EditPkiSyncForm.tsx b/frontend/src/components/pki-syncs/forms/EditPkiSyncForm.tsx
index 73f5bc2bc3..7f8ee207fb 100644
--- a/frontend/src/components/pki-syncs/forms/EditPkiSyncForm.tsx
+++ b/frontend/src/components/pki-syncs/forms/EditPkiSyncForm.tsx
@@ -38,28 +38,19 @@ export const EditPkiSyncForm = ({ pkiSync, fields, onComplete }: Props) => {
});
const onSubmit = async ({ connection, ...formData }: TUpdatePkiSyncForm) => {
- try {
- const updatedPkiSync = await updatePkiSync.mutateAsync({
- syncId: pkiSync.id,
- ...formData,
- connectionId: connection.id,
- projectId: pkiSync.projectId,
- destination: pkiSync.destination
- });
+ const updatedPkiSync = await updatePkiSync.mutateAsync({
+ syncId: pkiSync.id,
+ ...formData,
+ connectionId: connection.id,
+ projectId: pkiSync.projectId,
+ destination: pkiSync.destination
+ });
- createNotification({
- text: `Successfully updated ${destinationName} PKI Sync`,
- type: "success"
- });
- onComplete(updatedPkiSync);
- } catch (err: any) {
- console.error(err);
- createNotification({
- title: `Failed to update ${destinationName} PKI Sync`,
- text: err.message,
- type: "error"
- });
- }
+ createNotification({
+ text: `Successfully updated ${destinationName} PKI Sync`,
+ type: "success"
+ });
+ onComplete(updatedPkiSync);
};
let Component: ReactNode;
diff --git a/frontend/src/components/project/ProjectOverviewChangeSection.tsx b/frontend/src/components/project/ProjectOverviewChangeSection.tsx
index 548fbd1e34..455b0806a9 100644
--- a/frontend/src/components/project/ProjectOverviewChangeSection.tsx
+++ b/frontend/src/components/project/ProjectOverviewChangeSection.tsx
@@ -56,30 +56,22 @@ export const ProjectOverviewChangeSection = ({ showSlugField = false }: Props) =
}, [currentProject, showSlugField]);
const onFormSubmit = async (data: BaseFormData | FormDataWithSlug) => {
- try {
- if (!currentProject?.id) return;
+ if (!currentProject?.id) return;
- await mutateAsync({
- projectId: currentProject.id,
- newProjectName: data.name,
- newProjectDescription: data.description,
- ...(showSlugField &&
- "slug" in data && {
- newSlug: data.slug !== currentProject.slug ? data.slug : undefined
- })
- });
+ await mutateAsync({
+ projectId: currentProject.id,
+ newProjectName: data.name,
+ newProjectDescription: data.description,
+ ...(showSlugField &&
+ "slug" in data && {
+ newSlug: data.slug !== currentProject.slug ? data.slug : undefined
+ })
+ });
- createNotification({
- text: "Successfully updated project overview",
- type: "success"
- });
- } catch (err) {
- console.error(err);
- createNotification({
- text: "Failed to update project overview",
- type: "error"
- });
- }
+ createNotification({
+ text: "Successfully updated project overview",
+ type: "success"
+ });
};
return (
diff --git a/frontend/src/components/projects/NewProjectModal.tsx b/frontend/src/components/projects/NewProjectModal.tsx
index d71e7b957c..663d6a0b7e 100644
--- a/frontend/src/components/projects/NewProjectModal.tsx
+++ b/frontend/src/components/projects/NewProjectModal.tsx
@@ -141,29 +141,24 @@ const NewProjectForm = ({ onOpenChange }: NewProjectFormProps) => {
// type check
if (!currentOrg) return;
if (!user) return;
- try {
- const {
- data: { project }
- } = await createWs.mutateAsync({
- projectName: name,
- projectDescription: description,
- kmsKeyId: kmsKeyId !== INTERNAL_KMS_KEY_ID ? kmsKeyId : undefined,
- template,
- type
- });
- await refetchWorkspaces();
+ const {
+ data: { project }
+ } = await createWs.mutateAsync({
+ projectName: name,
+ projectDescription: description,
+ kmsKeyId: kmsKeyId !== INTERNAL_KMS_KEY_ID ? kmsKeyId : undefined,
+ template,
+ type
+ });
+ await refetchWorkspaces();
- createNotification({ text: "Project created", type: "success" });
- reset();
- onOpenChange(false);
- navigate({
- to: getProjectHomePage(project.type, project.environments),
- params: { projectId: project.id }
- });
- } catch (err) {
- console.error(err);
- createNotification({ text: "Failed to create project", type: "error" });
- }
+ createNotification({ text: "Project created", type: "success" });
+ reset();
+ onOpenChange(false);
+ navigate({
+ to: getProjectHomePage(project.type, project.environments),
+ params: { projectId: project.id }
+ });
};
const onSubmit = handleSubmit((data) => {
return onCreateProject(data);
diff --git a/frontend/src/components/secret-rotations-v2/DeleteSecretRotationV2Modal.tsx b/frontend/src/components/secret-rotations-v2/DeleteSecretRotationV2Modal.tsx
index 20b08eb497..524c669334 100644
--- a/frontend/src/components/secret-rotations-v2/DeleteSecretRotationV2Modal.tsx
+++ b/frontend/src/components/secret-rotations-v2/DeleteSecretRotationV2Modal.tsx
@@ -37,29 +37,22 @@ export const DeleteSecretRotationV2Modal = ({
const handleDeleteSecretRotation = async () => {
const rotationType = SECRET_ROTATION_MAP[type].name;
- try {
- await deleteSecretRotation.mutateAsync({
- rotationId,
- type,
- revokeGeneratedCredentials,
- deleteSecrets,
- projectId,
- secretPath: folder.path
- });
+ await deleteSecretRotation.mutateAsync({
+ rotationId,
+ type,
+ revokeGeneratedCredentials,
+ deleteSecrets,
+ projectId,
+ secretPath: folder.path
+ });
- createNotification({
- text: `Successfully deleted ${rotationType} Rotation`,
- type: "success"
- });
+ createNotification({
+ text: `Successfully deleted ${rotationType} Rotation`,
+ type: "success"
+ });
- if (onComplete) onComplete();
- onOpenChange(false);
- } catch {
- createNotification({
- text: `Failed to delete ${rotationType} Rotation`,
- type: "error"
- });
- }
+ if (onComplete) onComplete();
+ onOpenChange(false);
};
return (
diff --git a/frontend/src/components/secret-rotations-v2/RotateSecretRotationV2Modal.tsx b/frontend/src/components/secret-rotations-v2/RotateSecretRotationV2Modal.tsx
index e2c931d493..7ad9611be2 100644
--- a/frontend/src/components/secret-rotations-v2/RotateSecretRotationV2Modal.tsx
+++ b/frontend/src/components/secret-rotations-v2/RotateSecretRotationV2Modal.tsx
@@ -22,28 +22,19 @@ const Content = ({ secretRotation, onComplete }: ContentProps) => {
const rotationType = SECRET_ROTATION_MAP[type].name;
const handleRotateSecrets = async () => {
- try {
- await rotateSecrets.mutateAsync({
- rotationId,
- type,
- projectId,
- secretPath: folder.path
- });
+ await rotateSecrets.mutateAsync({
+ rotationId,
+ type,
+ projectId,
+ secretPath: folder.path
+ });
- createNotification({
- text: `Successfully rotated ${rotationType} secrets`,
- type: "success"
- });
+ createNotification({
+ text: `Successfully rotated ${rotationType} secrets`,
+ type: "success"
+ });
- onComplete();
- } catch (err) {
- console.error(err);
-
- createNotification({
- text: `Failed to rotate ${rotationType} secrets`,
- type: "error"
- });
- }
+ onComplete();
};
return (
diff --git a/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2Form.tsx b/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2Form.tsx
index 9887da026c..320793ed19 100644
--- a/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2Form.tsx
+++ b/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2Form.tsx
@@ -120,21 +120,13 @@ export const SecretRotationV2Form = ({
environment: environment.slug,
projectId: currentProject.id
});
- try {
- const rotation = await mutation;
-
- createNotification({
- text: `Successfully ${secretRotation ? "updated" : "created"} ${rotationType} Rotation`,
- type: "success"
- });
- onComplete(rotation);
- } catch (err: any) {
- createNotification({
- title: `Failed to ${secretRotation ? "update" : "create"} ${rotationType} Rotation`,
- text: err.message,
- type: "error"
- });
- }
+ const rotation = await mutation;
+
+ createNotification({
+ text: `Successfully ${secretRotation ? "updated" : "created"} ${rotationType} Rotation`,
+ type: "success"
+ });
+ onComplete(rotation);
};
const handlePrev = () => {
diff --git a/frontend/src/components/secret-scanning/DeleteSecretScanningDataSourceModal.tsx b/frontend/src/components/secret-scanning/DeleteSecretScanningDataSourceModal.tsx
index 9cf918dfbd..091de4cc03 100644
--- a/frontend/src/components/secret-scanning/DeleteSecretScanningDataSourceModal.tsx
+++ b/frontend/src/components/secret-scanning/DeleteSecretScanningDataSourceModal.tsx
@@ -28,26 +28,19 @@ export const DeleteSecretScanningDataSourceModal = ({
const handleDeleteDataSource = async () => {
const dataSourceType = SECRET_SCANNING_DATA_SOURCE_MAP[type].name;
- try {
- await deleteDataSource.mutateAsync({
- dataSourceId,
- type,
- projectId
- });
-
- createNotification({
- text: `Successfully deleted ${dataSourceType} Data Source`,
- type: "success"
- });
-
- if (onComplete) onComplete();
- onOpenChange(false);
- } catch {
- createNotification({
- text: `Failed to delete ${dataSourceType} Data Source`,
- type: "error"
- });
- }
+ await deleteDataSource.mutateAsync({
+ dataSourceId,
+ type,
+ projectId
+ });
+
+ createNotification({
+ text: `Successfully deleted ${dataSourceType} Data Source`,
+ type: "success"
+ });
+
+ if (onComplete) onComplete();
+ onOpenChange(false);
};
return (
diff --git a/frontend/src/components/secret-scanning/forms/SecretScanningDataSourceForm.tsx b/frontend/src/components/secret-scanning/forms/SecretScanningDataSourceForm.tsx
index 4d5ccdc799..563f82d461 100644
--- a/frontend/src/components/secret-scanning/forms/SecretScanningDataSourceForm.tsx
+++ b/frontend/src/components/secret-scanning/forms/SecretScanningDataSourceForm.tsx
@@ -73,21 +73,13 @@ export const SecretScanningDataSourceForm = ({
connectionId: connection?.id,
projectId: currentProject.id
});
- try {
- const source = await mutation;
-
- createNotification({
- text: `Successfully ${source ? "updated" : "created"} ${sourceType} Data Source`,
- type: "success"
- });
- onComplete(source);
- } catch (err: any) {
- createNotification({
- title: `Failed to ${dataSource ? "update" : "create"} ${sourceType} Data Source`,
- text: err.message,
- type: "error"
- });
- }
+ const source = await mutation;
+
+ createNotification({
+ text: `Successfully ${source ? "updated" : "created"} ${sourceType} Data Source`,
+ type: "success"
+ });
+ onComplete(source);
};
const handlePrev = () => {
diff --git a/frontend/src/components/secret-syncs/DeleteSecretSyncModal.tsx b/frontend/src/components/secret-syncs/DeleteSecretSyncModal.tsx
index 2b3903a9b8..de8b2e79da 100644
--- a/frontend/src/components/secret-syncs/DeleteSecretSyncModal.tsx
+++ b/frontend/src/components/secret-syncs/DeleteSecretSyncModal.tsx
@@ -23,29 +23,20 @@ export const DeleteSecretSyncModal = ({ isOpen, onOpenChange, secretSync, onComp
const handleDeleteSecretSync = async () => {
const destinationName = SECRET_SYNC_MAP[destination].name;
- try {
- await deleteSync.mutateAsync({
- syncId,
- destination,
- removeSecrets,
- projectId
- });
-
- createNotification({
- text: `Successfully removed ${destinationName} Sync`,
- type: "success"
- });
-
- if (onComplete) onComplete();
- onOpenChange(false);
- } catch (err) {
- console.error(err);
-
- createNotification({
- text: `Failed to remove ${destinationName} Sync`,
- type: "error"
- });
- }
+ await deleteSync.mutateAsync({
+ syncId,
+ destination,
+ removeSecrets,
+ projectId
+ });
+
+ createNotification({
+ text: `Successfully removed ${destinationName} Sync`,
+ type: "success"
+ });
+
+ if (onComplete) onComplete();
+ onOpenChange(false);
};
return (
diff --git a/frontend/src/components/secret-syncs/SecretSyncImportSecretsModal.tsx b/frontend/src/components/secret-syncs/SecretSyncImportSecretsModal.tsx
index c1b21a7719..656faffeb7 100644
--- a/frontend/src/components/secret-syncs/SecretSyncImportSecretsModal.tsx
+++ b/frontend/src/components/secret-syncs/SecretSyncImportSecretsModal.tsx
@@ -51,28 +51,19 @@ const Content = ({ secretSync, onComplete }: ContentProps) => {
const triggerImportSecrets = useTriggerSecretSyncImportSecrets();
const handleTriggerImportSecrets = async ({ importBehavior }: TFormData) => {
- try {
- await triggerImportSecrets.mutateAsync({
- syncId,
- destination,
- importBehavior,
- projectId
- });
-
- createNotification({
- text: `Successfully triggered secret import for ${destinationName} Sync`,
- type: "success"
- });
-
- onComplete();
- } catch (err) {
- console.error(err);
-
- createNotification({
- text: `Failed to trigger secret import for ${destinationName} Sync`,
- type: "error"
- });
- }
+ await triggerImportSecrets.mutateAsync({
+ syncId,
+ destination,
+ importBehavior,
+ projectId
+ });
+
+ createNotification({
+ text: `Successfully triggered secret import for ${destinationName} Sync`,
+ type: "success"
+ });
+
+ onComplete();
};
return (
diff --git a/frontend/src/components/secret-syncs/SecretSyncRemoveSecretsModal.tsx b/frontend/src/components/secret-syncs/SecretSyncRemoveSecretsModal.tsx
index 718392b920..9c9c0e6595 100644
--- a/frontend/src/components/secret-syncs/SecretSyncRemoveSecretsModal.tsx
+++ b/frontend/src/components/secret-syncs/SecretSyncRemoveSecretsModal.tsx
@@ -21,27 +21,18 @@ const Content = ({ secretSync, onComplete }: ContentProps) => {
const triggerSyncImport = useTriggerSecretSyncRemoveSecrets();
const handleTriggerRemoveSecrets = async () => {
- try {
- await triggerSyncImport.mutateAsync({
- syncId,
- destination,
- projectId
- });
+ await triggerSyncImport.mutateAsync({
+ syncId,
+ destination,
+ projectId
+ });
- createNotification({
- text: `Successfully triggered secret removal for ${destinationName} Sync`,
- type: "success"
- });
+ createNotification({
+ text: `Successfully triggered secret removal for ${destinationName} Sync`,
+ type: "success"
+ });
- onComplete();
- } catch (err) {
- console.error(err);
-
- createNotification({
- text: `Failed to trigger secret removal for ${destinationName} Sync`,
- type: "error"
- });
- }
+ onComplete();
};
return (
diff --git a/frontend/src/components/secret-syncs/forms/CreateSecretSyncForm.tsx b/frontend/src/components/secret-syncs/forms/CreateSecretSyncForm.tsx
index ebad86cbd9..21a69b1634 100644
--- a/frontend/src/components/secret-syncs/forms/CreateSecretSyncForm.tsx
+++ b/frontend/src/components/secret-syncs/forms/CreateSecretSyncForm.tsx
@@ -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"
- });
}
};
diff --git a/frontend/src/components/secret-syncs/forms/EditSecretSyncForm.tsx b/frontend/src/components/secret-syncs/forms/EditSecretSyncForm.tsx
index 2085afe9c2..207b72cd88 100644
--- a/frontend/src/components/secret-syncs/forms/EditSecretSyncForm.tsx
+++ b/frontend/src/components/secret-syncs/forms/EditSecretSyncForm.tsx
@@ -58,29 +58,20 @@ 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,
- ...updateData,
- environment: environment?.slug,
- connectionId: connection.id,
- projectId: secretSync.projectId
- });
-
- createNotification({
- text: `Successfully updated ${destinationName} Sync`,
- type: "success"
- });
- onComplete(updatedSecretSync);
- } catch (err: any) {
- console.error(err);
- createNotification({
- title: `Failed to update ${destinationName} Sync`,
- text: err.message,
- type: "error"
- });
- }
+ const { environment, connection, ...updateData } = formData;
+ const updatedSecretSync = await updateSecretSync.mutateAsync({
+ syncId: secretSync.id,
+ ...updateData,
+ environment: environment?.slug,
+ connectionId: connection.id,
+ projectId: secretSync.projectId
+ });
+
+ createNotification({
+ text: `Successfully updated ${destinationName} Sync`,
+ type: "success"
+ });
+ onComplete(updatedSecretSync);
},
[updateSecretSync, secretSync.id, secretSync.projectId, destinationName, onComplete]
);
diff --git a/frontend/src/components/tags/CreateTagModal/CreateTagModal.tsx b/frontend/src/components/tags/CreateTagModal/CreateTagModal.tsx
index 3c38926af8..97e74cae4f 100644
--- a/frontend/src/components/tags/CreateTagModal/CreateTagModal.tsx
+++ b/frontend/src/components/tags/CreateTagModal/CreateTagModal.tsx
@@ -130,26 +130,18 @@ export const CreateTagModal = ({ isOpen, onToggle, append, currentSecret }: Prop
}, [isOpen]);
const onFormSubmit = async ({ slug, color }: FormData) => {
- try {
- const data = await createWsTag({
- projectId,
- tagColor: color,
- tagSlug: slug
- });
- append(data);
- onToggle(false);
- reset();
- createNotification({
- text: "Successfully created a tag",
- type: "success"
- });
- } catch (error) {
- console.error(error);
- createNotification({
- text: "Failed to create a tag",
- type: "error"
- });
- }
+ const data = await createWsTag({
+ projectId,
+ tagColor: color,
+ tagSlug: slug
+ });
+ append(data);
+ onToggle(false);
+ reset();
+ createNotification({
+ text: "Successfully created a tag",
+ type: "success"
+ });
};
return (
diff --git a/frontend/src/layouts/OrganizationLayout/components/NavBar/NewSubOrganizationForm.tsx b/frontend/src/layouts/OrganizationLayout/components/NavBar/NewSubOrganizationForm.tsx
index 75041a69e9..bfea2e788f 100644
--- a/frontend/src/layouts/OrganizationLayout/components/NavBar/NewSubOrganizationForm.tsx
+++ b/frontend/src/layouts/OrganizationLayout/components/NavBar/NewSubOrganizationForm.tsx
@@ -36,28 +36,21 @@ export const NewSubOrganizationForm = ({ onClose }: ContentProps) => {
const router = useRouter();
const onSubmit = async ({ name }: FormData) => {
- try {
- const { organization } = await createSubOrg.mutateAsync({
- name
- });
+ const { organization } = await createSubOrg.mutateAsync({
+ name
+ });
- createNotification({
- type: "success",
- text: "Successfully created sub organization"
- });
- onClose();
+ createNotification({
+ type: "success",
+ text: "Successfully created sub organization"
+ });
+ onClose();
- navigate({
- to: "/organization/projects",
- search: (prev) => ({ ...prev, subOrganization: organization.name })
- });
- await router.invalidate({ sync: true }).catch(() => null);
- } catch {
- createNotification({
- text: "Failed to create sub organization",
- type: "error"
- });
- }
+ navigate({
+ to: "/organization/projects",
+ search: (prev) => ({ ...prev, subOrganization: organization.name })
+ });
+ await router.invalidate({ sync: true }).catch(() => null);
};
return (
diff --git a/frontend/src/layouts/ProjectLayout/components/ProjectSelect/ProjectSelect.tsx b/frontend/src/layouts/ProjectLayout/components/ProjectSelect/ProjectSelect.tsx
index c26333332c..8e985fe58b 100644
--- a/frontend/src/layouts/ProjectLayout/components/ProjectSelect/ProjectSelect.tsx
+++ b/frontend/src/layouts/ProjectLayout/components/ProjectSelect/ProjectSelect.tsx
@@ -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"
- });
- }
+ await updateUserProjectFavorites({
+ orgId: currentOrg!.id,
+ projectFavorites: [...(projectFavorites || []), projectId]
+ });
};
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"
- });
- }
+ await updateUserProjectFavorites({
+ orgId: currentOrg!.id,
+ projectFavorites: [...(projectFavorites || []).filter((entry) => entry !== projectId)]
+ });
};
const isAddingProjectsAllowed = subscription?.workspaceLimit
diff --git a/frontend/src/pages/admin/AccessManagementPage/components/AddServerAdminModal.tsx b/frontend/src/pages/admin/AccessManagementPage/components/AddServerAdminModal.tsx
index 3e7638627b..63ec2fa44a 100644
--- a/frontend/src/pages/admin/AccessManagementPage/components/AddServerAdminModal.tsx
+++ b/frontend/src/pages/admin/AccessManagementPage/components/AddServerAdminModal.tsx
@@ -65,20 +65,13 @@ const Content = ({ onClose }: ContentProps) => {
const users = usersData.filter((user) => !user.superAdmin);
const onSubmit = async ({ user }: FormData) => {
- try {
- await grantAdmin.mutateAsync(user.id);
-
- createNotification({
- type: "success",
- text: "Successfully granted server admin status"
- });
- onClose();
- } catch {
- createNotification({
- text: "Failed to grant server admin status",
- type: "error"
- });
- }
+ await grantAdmin.mutateAsync(user.id);
+
+ createNotification({
+ type: "success",
+ text: "Successfully granted server admin status"
+ });
+ onClose();
};
return (
diff --git a/frontend/src/pages/admin/AccessManagementPage/components/ServerAdminsTable.tsx b/frontend/src/pages/admin/AccessManagementPage/components/ServerAdminsTable.tsx
index 7e207fbc59..2e7016ee73 100644
--- a/frontend/src/pages/admin/AccessManagementPage/components/ServerAdminsTable.tsx
+++ b/frontend/src/pages/admin/AccessManagementPage/components/ServerAdminsTable.tsx
@@ -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"
- });
- }
+ await deleteUser(id);
+ createNotification({
+ type: "success",
+ text: "Successfully deleted user"
+ });
handlePopUpClose("removeUser");
};
@@ -322,39 +315,25 @@ 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"
- });
- }
+ await removeAdminAccess(id);
+ createNotification({
+ type: "success",
+ text: "Successfully removed server admin access from user"
+ });
handlePopUpClose("removeServerAdmin");
};
const handleRemoveUsers = async () => {
- try {
- await deleteUsers(selectedUsers.map((user) => user.id));
+ await deleteUsers(selectedUsers.map((user) => user.id));
- createNotification({
- text: "Successfully removed users",
- type: "success"
- });
+ createNotification({
+ text: "Successfully removed users",
+ type: "success"
+ });
- setSelectedUsers([]);
- handlePopUpClose("removeUsers");
- } catch {
- createNotification({
- text: "Failed to remove users",
- type: "error"
- });
- }
+ setSelectedUsers([]);
+ handlePopUpClose("removeUsers");
};
return (
diff --git a/frontend/src/pages/admin/AuthenticationPage/components/AuthenticationPageForm.tsx b/frontend/src/pages/admin/AuthenticationPage/components/AuthenticationPageForm.tsx
index 2abb96e60f..f8ca30c529 100644
--- a/frontend/src/pages/admin/AuthenticationPage/components/AuthenticationPageForm.tsx
+++ b/frontend/src/pages/admin/AuthenticationPage/components/AuthenticationPageForm.tsx
@@ -54,59 +54,51 @@ export const AuthenticationPageForm = () => {
});
const onAuthFormSubmit = async (formData: TAuthForm) => {
- try {
- const enabledMethods: LoginMethod[] = [];
- if (formData.isEmailEnabled) {
- enabledMethods.push(LoginMethod.EMAIL);
- }
-
- if (formData.isGoogleEnabled) {
- enabledMethods.push(LoginMethod.GOOGLE);
- }
-
- if (formData.isGithubEnabled) {
- enabledMethods.push(LoginMethod.GITHUB);
- }
-
- if (formData.isGitlabEnabled) {
- enabledMethods.push(LoginMethod.GITLAB);
- }
-
- if (formData.isSamlEnabled) {
- enabledMethods.push(LoginMethod.SAML);
- }
-
- if (formData.isLdapEnabled) {
- enabledMethods.push(LoginMethod.LDAP);
- }
-
- if (formData.isOidcEnabled) {
- enabledMethods.push(LoginMethod.OIDC);
- }
-
- if (!enabledMethods.length) {
- createNotification({
- type: "error",
- text: "At least one login method should be enabled."
- });
- return;
- }
-
- await updateServerConfig({
- enabledLoginMethods: enabledMethods
- });
+ const enabledMethods: LoginMethod[] = [];
+ if (formData.isEmailEnabled) {
+ enabledMethods.push(LoginMethod.EMAIL);
+ }
- createNotification({
- text: "Login methods have been successfully updated.",
- type: "success"
- });
- } catch (e) {
- console.error(e);
+ if (formData.isGoogleEnabled) {
+ enabledMethods.push(LoginMethod.GOOGLE);
+ }
+
+ if (formData.isGithubEnabled) {
+ enabledMethods.push(LoginMethod.GITHUB);
+ }
+
+ if (formData.isGitlabEnabled) {
+ enabledMethods.push(LoginMethod.GITLAB);
+ }
+
+ if (formData.isSamlEnabled) {
+ enabledMethods.push(LoginMethod.SAML);
+ }
+
+ if (formData.isLdapEnabled) {
+ enabledMethods.push(LoginMethod.LDAP);
+ }
+
+ if (formData.isOidcEnabled) {
+ enabledMethods.push(LoginMethod.OIDC);
+ }
+
+ if (!enabledMethods.length) {
createNotification({
type: "error",
- text: "Failed to update login methods."
+ text: "At least one login method should be enabled."
});
+ return;
}
+
+ await updateServerConfig({
+ enabledLoginMethods: enabledMethods
+ });
+
+ createNotification({
+ text: "Login methods have been successfully updated.",
+ type: "success"
+ });
};
return (
diff --git a/frontend/src/pages/admin/CachingPage/components/CachingPageForm.tsx b/frontend/src/pages/admin/CachingPage/components/CachingPageForm.tsx
index fbf956b7b7..e9bdc3d1ed 100644
--- a/frontend/src/pages/admin/CachingPage/components/CachingPageForm.tsx
+++ b/frontend/src/pages/admin/CachingPage/components/CachingPageForm.tsx
@@ -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" });
- }
+ await invalidateCache({ type });
+ createNotification({ text: `Began invalidating ${type} cache`, type: "success" });
+ setShouldPoll(true);
+ handlePopUpClose("invalidateCache");
};
useEffect(() => {
diff --git a/frontend/src/pages/admin/EncryptionPage/components/EncryptionPageForm.tsx b/frontend/src/pages/admin/EncryptionPage/components/EncryptionPageForm.tsx
index 8372dd557c..3dafdabd33 100644
--- a/frontend/src/pages/admin/EncryptionPage/components/EncryptionPageForm.tsx
+++ b/frontend/src/pages/admin/EncryptionPage/components/EncryptionPageForm.tsx
@@ -60,19 +60,12 @@ export const EncryptionPageForm = () => {
return;
}
- try {
- await updateEncryptionStrategy(formData.encryptionStrategy);
+ await updateEncryptionStrategy(formData.encryptionStrategy);
- createNotification({
- type: "success",
- text: "Encryption strategy updated successfully"
- });
- } catch {
- createNotification({
- type: "error",
- text: "Failed to update encryption strategy"
- });
- }
+ createNotification({
+ type: "success",
+ text: "Encryption strategy updated successfully"
+ });
}, []);
return (
diff --git a/frontend/src/pages/admin/EnvironmentPage/components/EnvironmentPageForm.tsx b/frontend/src/pages/admin/EnvironmentPage/components/EnvironmentPageForm.tsx
index 5f74593a3f..8361aa9440 100644
--- a/frontend/src/pages/admin/EnvironmentPage/components/EnvironmentPageForm.tsx
+++ b/frontend/src/pages/admin/EnvironmentPage/components/EnvironmentPageForm.tsx
@@ -176,31 +176,19 @@ export const EnvironmentPageForm = () => {
const onSubmit = useCallback(
async (formData: TForm) => {
- try {
- const filteredFormData = Object.fromEntries(
- Object.entries(formData).filter(([, value]) => value !== "")
- );
- await updateServerConfig({
- envOverrides: filteredFormData
- });
-
- createNotification({
- type: "success",
- text: "Environment overrides updated successfully. It can take up to 5 minutes to take effect."
- });
-
- 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
- });
- }
+ const filteredFormData = Object.fromEntries(
+ Object.entries(formData).filter(([, value]) => value !== "")
+ );
+ await updateServerConfig({
+ envOverrides: filteredFormData
+ });
+
+ createNotification({
+ type: "success",
+ text: "Environment overrides updated successfully. It can take up to 5 minutes to take effect."
+ });
+
+ reset(formData);
},
[reset, updateServerConfig]
);
diff --git a/frontend/src/pages/admin/GeneralPage/components/GeneralPageForm.tsx b/frontend/src/pages/admin/GeneralPage/components/GeneralPageForm.tsx
index be92dd6793..eff3e3cf88 100644
--- a/frontend/src/pages/admin/GeneralPage/components/GeneralPageForm.tsx
+++ b/frontend/src/pages/admin/GeneralPage/components/GeneralPageForm.tsx
@@ -68,37 +68,29 @@ export const GeneralPageForm = () => {
const organizations = useGetOrganizations();
const onFormSubmit = async (formData: TDashboardForm) => {
- try {
- const {
- allowedSignUpDomain,
- trustSamlEmails,
- trustLdapEmails,
- trustOidcEmails,
- authConsentContent,
- pageFrameContent
- } = formData;
+ const {
+ allowedSignUpDomain,
+ trustSamlEmails,
+ trustLdapEmails,
+ trustOidcEmails,
+ authConsentContent,
+ pageFrameContent
+ } = formData;
- await updateServerConfig({
- defaultAuthOrgId: defaultAuthOrgId || null,
- allowSignUp: signUpMode !== SignUpModes.Disabled,
- allowedSignUpDomain: signUpMode === SignUpModes.Anyone ? allowedSignUpDomain : null,
- trustSamlEmails,
- trustLdapEmails,
- trustOidcEmails,
- authConsentContent,
- pageFrameContent
- });
- createNotification({
- text: "Successfully changed sign up setting.",
- type: "success"
- });
- } catch (e) {
- console.error(e);
- createNotification({
- type: "error",
- text: "Failed to update sign up setting."
- });
- }
+ await updateServerConfig({
+ defaultAuthOrgId: defaultAuthOrgId || null,
+ allowSignUp: signUpMode !== SignUpModes.Disabled,
+ allowedSignUpDomain: signUpMode === SignUpModes.Anyone ? allowedSignUpDomain : null,
+ trustSamlEmails,
+ trustLdapEmails,
+ trustOidcEmails,
+ authConsentContent,
+ pageFrameContent
+ });
+ createNotification({
+ text: "Successfully changed sign up setting.",
+ type: "success"
+ });
};
return (
diff --git a/frontend/src/pages/admin/GeneralPage/components/UsageReportSection.tsx b/frontend/src/pages/admin/GeneralPage/components/UsageReportSection.tsx
index d05800996e..663aa18b72 100644
--- a/frontend/src/pages/admin/GeneralPage/components/UsageReportSection.tsx
+++ b/frontend/src/pages/admin/GeneralPage/components/UsageReportSection.tsx
@@ -10,23 +10,15 @@ export const UsageReportSection = () => {
const generateUsageReport = useGenerateUsageReport();
const handleGenerateReport = async () => {
- try {
- const response = await generateUsageReport.mutateAsync();
- const { csvContent, filename } = response;
-
- downloadFile(csvContent, filename, "text/csv");
-
- createNotification({
- 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"
- });
- }
+ const response = await generateUsageReport.mutateAsync();
+ const { csvContent, filename } = response;
+
+ downloadFile(csvContent, filename, "text/csv");
+
+ createNotification({
+ text: `Usage report downloaded: "${filename}"`,
+ type: "success"
+ });
};
return (
diff --git a/frontend/src/pages/admin/ResourceOverviewPage/components/AddOrganizationModal.tsx b/frontend/src/pages/admin/ResourceOverviewPage/components/AddOrganizationModal.tsx
index d577998b5f..48983496f3 100644
--- a/frontend/src/pages/admin/ResourceOverviewPage/components/AddOrganizationModal.tsx
+++ b/frontend/src/pages/admin/ResourceOverviewPage/components/AddOrganizationModal.tsx
@@ -81,25 +81,18 @@ const Content = ({ onClose }: ContentProps) => {
const { users = [] } = data ?? {};
const onSubmit = async ({ name, invitees }: FormData) => {
- try {
- await createOrg.mutateAsync({
- name,
- inviteAdminEmails: invitees
- .filter((user) => Boolean(user.email))
- .map((user) => user.email) as string[]
- });
-
- createNotification({
- type: "success",
- text: "Successfully created organization"
- });
- onClose();
- } catch {
- createNotification({
- text: "Failed to create organization",
- type: "error"
- });
- }
+ await createOrg.mutateAsync({
+ name,
+ inviteAdminEmails: invitees
+ .filter((user) => Boolean(user.email))
+ .map((user) => user.email) as string[]
+ });
+
+ createNotification({
+ type: "success",
+ text: "Successfully created organization"
+ });
+ onClose();
};
const { append } = useFieldArray<FormData>({ control, name: "invitees" });
diff --git a/frontend/src/pages/admin/ResourceOverviewPage/components/MachineIdentitiesTable.tsx b/frontend/src/pages/admin/ResourceOverviewPage/components/MachineIdentitiesTable.tsx
index 9929d75009..d177867127 100644
--- a/frontend/src/pages/admin/ResourceOverviewPage/components/MachineIdentitiesTable.tsx
+++ b/frontend/src/pages/admin/ResourceOverviewPage/components/MachineIdentitiesTable.tsx
@@ -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"
- });
- }
+ await deleteIdentitySuperAdminAccess(id);
+ createNotification({
+ type: "success",
+ text: "Successfully removed server admin permissions"
+ });
handlePopUpClose("removeServerAdmin");
};
diff --git a/frontend/src/pages/admin/ResourceOverviewPage/components/OrganizationsTable.tsx b/frontend/src/pages/admin/ResourceOverviewPage/components/OrganizationsTable.tsx
index fbb9462d0c..93d0253ff3 100644
--- a/frontend/src/pages/admin/ResourceOverviewPage/components/OrganizationsTable.tsx
+++ b/frontend/src/pages/admin/ResourceOverviewPage/components/OrganizationsTable.tsx
@@ -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,26 +473,19 @@ const OrganizationsPanelTable = ({
const { mutateAsync: accessOrganization } = useServerAdminAccessOrg();
const handleAccessOrg = async (orgId: string) => {
- try {
- await accessOrganization(orgId);
+ await accessOrganization(orgId);
- navigate({
- to: "/login/select-organization",
- search: {
- org_id: orgId
- }
- });
+ navigate({
+ to: "/login/select-organization",
+ search: {
+ org_id: orgId
+ }
+ });
- createNotification({
- text: "Successfully joined organization",
- type: "success"
- });
- } catch {
- createNotification({
- text: "Failed to join organization",
- type: "error"
- });
- }
+ createNotification({
+ text: "Successfully joined organization",
+ type: "success"
+ });
};
return (
diff --git a/frontend/src/pages/admin/ResourceOverviewPage/components/UserIdentitiesTable.tsx b/frontend/src/pages/admin/ResourceOverviewPage/components/UserIdentitiesTable.tsx
index 05d07d426d..4f44a32aae 100644
--- a/frontend/src/pages/admin/ResourceOverviewPage/components/UserIdentitiesTable.tsx
+++ b/frontend/src/pages/admin/ResourceOverviewPage/components/UserIdentitiesTable.tsx
@@ -367,18 +367,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"
- });
- }
+ await deleteUser(id);
+ createNotification({
+ type: "success",
+ text: "Successfully deleted user"
+ });
handlePopUpClose("removeUser");
};
@@ -386,18 +379,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"
- });
- }
+ await grantAdminAccess(id);
+ createNotification({
+ type: "success",
+ text: "Successfully granted server admin access to user"
+ });
handlePopUpClose("upgradeToServerAdmin");
};
@@ -405,39 +391,25 @@ 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"
- });
- }
+ await removeAdminAccess(id);
+ createNotification({
+ type: "success",
+ text: "Successfully removed server admin access from user"
+ });
handlePopUpClose("removeServerAdmin");
};
const handleRemoveUsers = async () => {
- try {
- await deleteUsers(selectedUsers.map((user) => user.id));
+ await deleteUsers(selectedUsers.map((user) => user.id));
- createNotification({
- text: "Successfully removed users",
- type: "success"
- });
+ createNotification({
+ text: "Successfully removed users",
+ type: "success"
+ });
- setSelectedUsers([]);
- handlePopUpClose("removeUsers");
- } catch {
- createNotification({
- text: "Failed to remove users",
- type: "error"
- });
- }
+ setSelectedUsers([]);
+ handlePopUpClose("removeUsers");
};
return (
diff --git a/frontend/src/pages/admin/SignUpPage/SignUpPage.tsx b/frontend/src/pages/admin/SignUpPage/SignUpPage.tsx
index 04bd2f55c8..81959a647f 100644
--- a/frontend/src/pages/admin/SignUpPage/SignUpPage.tsx
+++ b/frontend/src/pages/admin/SignUpPage/SignUpPage.tsx
@@ -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,29 +45,21 @@ export const SignUpPage = () => {
const handleFormSubmit = async ({ email, password, firstName, lastName }: TFormSchema) => {
// avoid multi submission
if (isSubmitting) return;
- try {
- const res = await createAdminUser({
- email,
- password,
- firstName,
- lastName
- });
+ const res = await createAdminUser({
+ email,
+ password,
+ firstName,
+ lastName
+ });
- SecurityClient.setToken(res.token);
- await selectOrganization({ organizationId: res.organization.id });
+ SecurityClient.setToken(res.token);
+ await selectOrganization({ organizationId: res.organization.id });
- // TODO(akhilmhdh): This is such a confusing pattern and too unreliable
- // Will be refactored in next iteration to make it url based rather than local storage ones
- // 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"
- });
- }
+ // TODO(akhilmhdh): This is such a confusing pattern and too unreliable
+ // Will be refactored in next iteration to make it url based rather than local storage ones
+ // Part of migration to nextjs 14
+ localStorage.setItem("orgData.id", res.organization.id);
+ navigate({ to: "/admin" });
};
if (config?.initialized) return <ContentLoader text="Redirecting to admin page..." />;
diff --git a/frontend/src/pages/auth/PasswordSetupPage/PasswordSetupPage.tsx b/frontend/src/pages/auth/PasswordSetupPage/PasswordSetupPage.tsx
index a1dad3cc50..9626f4cc5c 100644
--- a/frontend/src/pages/auth/PasswordSetupPage/PasswordSetupPage.tsx
+++ b/frontend/src/pages/auth/PasswordSetupPage/PasswordSetupPage.tsx
@@ -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" });
}
}
diff --git a/frontend/src/pages/auth/SignUpSsoPage/components/EmailConfirmationStep/EmailConfirmationStep.tsx b/frontend/src/pages/auth/SignUpSsoPage/components/EmailConfirmationStep/EmailConfirmationStep.tsx
index efa4987492..2240fe263a 100644
--- a/frontend/src/pages/auth/SignUpSsoPage/components/EmailConfirmationStep/EmailConfirmationStep.tsx
+++ b/frontend/src/pages/auth/SignUpSsoPage/components/EmailConfirmationStep/EmailConfirmationStep.tsx
@@ -73,67 +73,53 @@ export const EmailConfirmationStep = ({
const { mutateAsync: verifyEmailVerificationCode } = useVerifyEmailVerificationCode();
const checkCode = async () => {
- try {
- await verifyEmailVerificationCode({ username, code });
- setCodeError(false);
+ await verifyEmailVerificationCode({ username, code });
+ setCodeError(false);
- createNotification({
- text: "Successfully verified code",
- type: "success"
- });
+ createNotification({
+ text: "Successfully verified code",
+ type: "success"
+ });
- switch (authType) {
- case UserAliasType.SAML: {
- window.open(`/api/v1/sso/redirect/saml2/organizations/${organizationSlug}`);
- window.close();
- break;
- }
- case UserAliasType.LDAP: {
- navigate({ to: "/login/ldap", search: { organizationSlug } });
- break;
- }
- case UserAliasType.OIDC: {
- window.open(`/api/v1/sso/oidc/login?orgSlug=${organizationSlug}`);
- window.close();
- break;
- }
- default: {
- setStep(1);
- break;
- }
+ switch (authType) {
+ case UserAliasType.SAML: {
+ window.open(`/api/v1/sso/redirect/saml2/organizations/${organizationSlug}`);
+ window.close();
+ break;
+ }
+ case UserAliasType.LDAP: {
+ navigate({ to: "/login/ldap", search: { organizationSlug } });
+ break;
+ }
+ case UserAliasType.OIDC: {
+ window.open(`/api/v1/sso/oidc/login?orgSlug=${organizationSlug}`);
+ window.close();
+ break;
+ }
+ default: {
+ setStep(1);
+ 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) {
- createNotification({
- text: "Failed to resend code, no token found",
- type: "error"
- });
- return;
- }
- await sendEmailVerificationCode(token);
- createNotification({
- text: "Successfully resent code",
- type: "success"
- });
- } catch {
+ const queryParams = new URLSearchParams(window.location.search);
+ const token = queryParams.get("token");
+ if (!token) {
createNotification({
- text: "Failed to resend code",
+ text: "Failed to resend code, no token found",
type: "error"
});
+ return;
}
+ await sendEmailVerificationCode(token);
+ createNotification({
+ text: "Successfully resent code",
+ type: "success"
+ });
};
return (
diff --git a/frontend/src/pages/cert-manager/AlertingPage/components/PkiAlertModal.tsx b/frontend/src/pages/cert-manager/AlertingPage/components/PkiAlertModal.tsx
index 5601e48db6..af5bcb7aed 100644
--- a/frontend/src/pages/cert-manager/AlertingPage/components/PkiAlertModal.tsx
+++ b/frontend/src/pages/cert-manager/AlertingPage/components/PkiAlertModal.tsx
@@ -113,52 +113,44 @@ export const PkiAlertModal = ({ popUp, handlePopUpToggle }: Props) => {
alertUnit,
emails
}: FormData) => {
- try {
- if (!projectId) return;
+ if (!projectId) return;
- const emailArray = emails
- .split(",")
- .map((email) => email.trim())
- .filter((email) => email.length > 0);
+ const emailArray = emails
+ .split(",")
+ .map((email) => email.trim())
+ .filter((email) => email.length > 0);
- const alertBeforeDays = convertToDays(alertUnit, Number(alertBefore));
+ const alertBeforeDays = convertToDays(alertUnit, Number(alertBefore));
- if (alert) {
- // update
- await updatePkiAlert({
- alertId: alert.id,
- pkiCollectionId,
- name,
- projectId,
- alertBeforeDays,
- emails: emailArray
- });
- } else {
- // create
- await createPkiAlert({
- name,
- projectId,
- pkiCollectionId,
- alertBeforeDays,
- emails: emailArray
- });
- }
-
- handlePopUpToggle("pkiAlert", false);
-
- reset();
-
- createNotification({
- text: `Successfully ${alert ? "updated" : "created"} alert`,
- type: "success"
+ if (alert) {
+ // update
+ await updatePkiAlert({
+ alertId: alert.id,
+ pkiCollectionId,
+ name,
+ projectId,
+ alertBeforeDays,
+ emails: emailArray
});
- } catch (err) {
- console.error(err);
- createNotification({
- text: `Failed to ${alert ? "updated" : "created"} alert`,
- type: "error"
+ } else {
+ // create
+ await createPkiAlert({
+ name,
+ projectId,
+ pkiCollectionId,
+ alertBeforeDays,
+ emails: emailArray
});
}
+
+ handlePopUpToggle("pkiAlert", false);
+
+ reset();
+
+ createNotification({
+ text: `Successfully ${alert ? "updated" : "created"} alert`,
+ type: "success"
+ });
};
return (
diff --git a/frontend/src/pages/cert-manager/AlertingPage/components/PkiAlertsSection.tsx b/frontend/src/pages/cert-manager/AlertingPage/components/PkiAlertsSection.tsx
index 329974f65d..1529dfc199 100644
--- a/frontend/src/pages/cert-manager/AlertingPage/components/PkiAlertsSection.tsx
+++ b/frontend/src/pages/cert-manager/AlertingPage/components/PkiAlertsSection.tsx
@@ -22,27 +22,19 @@ export const PkiAlertsSection = () => {
] as const);
const onRemoveAlertSubmit = async (alertId: string) => {
- try {
- if (!projectId) return;
+ if (!projectId) return;
- await deletePkiAlert({
- alertId,
- projectId
- });
+ await deletePkiAlert({
+ alertId,
+ projectId
+ });
- createNotification({
- text: "Successfully deleted alert",
- type: "success"
- });
+ createNotification({
+ text: "Successfully deleted alert",
+ type: "success"
+ });
- handlePopUpClose("deletePkiAlert");
- } catch (err) {
- console.error(err);
- createNotification({
- text: "Failed to delete alert",
- type: "error"
- });
- }
+ handlePopUpClose("deletePkiAlert");
};
return (
diff --git a/frontend/src/pages/cert-manager/AlertingPage/components/PkiCollectionModal.tsx b/frontend/src/pages/cert-manager/AlertingPage/components/PkiCollectionModal.tsx
index 5900a1ba96..a29e9028b9 100644
--- a/frontend/src/pages/cert-manager/AlertingPage/components/PkiCollectionModal.tsx
+++ b/frontend/src/pages/cert-manager/AlertingPage/components/PkiCollectionModal.tsx
@@ -62,49 +62,41 @@ export const PkiCollectionModal = ({ popUp, handlePopUpToggle }: Props) => {
}, [pkiCollection]);
const onFormSubmit = async ({ name, description }: FormData) => {
- try {
- if (!projectId) return;
-
- if (pkiCollection) {
- // update
- await updatePkiCollection({
- collectionId: pkiCollection.id,
- name,
- description,
- projectId
- });
- } else {
- // create
- const { id: collectionId } = await createPkiCollection({
- name,
- description,
- projectId
- });
-
- navigate({
- to: "/projects/cert-management/$projectId/pki-collections/$collectionId",
- params: {
- projectId,
- collectionId
- }
- });
- }
-
- handlePopUpToggle("pkiCollection", false);
-
- reset();
-
- createNotification({
- text: `Successfully ${pkiCollection ? "updated" : "created"} PKI collection`,
- type: "success"
+ if (!projectId) return;
+
+ if (pkiCollection) {
+ // update
+ await updatePkiCollection({
+ collectionId: pkiCollection.id,
+ name,
+ description,
+ projectId
+ });
+ } else {
+ // create
+ const { id: collectionId } = await createPkiCollection({
+ name,
+ description,
+ projectId
});
- } catch (err) {
- console.error(err);
- createNotification({
- text: `Failed to ${pkiCollection ? "updated" : "created"} PKI collection`,
- type: "error"
+
+ navigate({
+ to: "/projects/cert-management/$projectId/pki-collections/$collectionId",
+ params: {
+ projectId,
+ collectionId
+ }
});
}
+
+ handlePopUpToggle("pkiCollection", false);
+
+ reset();
+
+ createNotification({
+ text: `Successfully ${pkiCollection ? "updated" : "created"} PKI collection`,
+ type: "success"
+ });
};
return (
diff --git a/frontend/src/pages/cert-manager/AlertingPage/components/PkiCollectionSection.tsx b/frontend/src/pages/cert-manager/AlertingPage/components/PkiCollectionSection.tsx
index eecceaa7d8..fa9cf7bea3 100644
--- a/frontend/src/pages/cert-manager/AlertingPage/components/PkiCollectionSection.tsx
+++ b/frontend/src/pages/cert-manager/AlertingPage/components/PkiCollectionSection.tsx
@@ -22,27 +22,19 @@ export const PkiCollectionSection = () => {
] as const);
const onRemovePkiCollectionSubmit = async (collectionId: string) => {
- try {
- if (!projectId) return;
+ if (!projectId) return;
- await deletePkiCollection({
- collectionId,
- projectId
- });
+ await deletePkiCollection({
+ collectionId,
+ projectId
+ });
- createNotification({
- text: "Successfully deleted PKI collection",
- type: "success"
- });
+ createNotification({
+ text: "Successfully deleted PKI collection",
+ type: "success"
+ });
- handlePopUpClose("deletePkiCollection");
- } catch (err) {
- console.error(err);
- createNotification({
- text: "Failed to delete PKI collection",
- type: "error"
- });
- }
+ handlePopUpClose("deletePkiCollection");
};
return (
diff --git a/frontend/src/pages/cert-manager/CertAuthDetailsByIDPage/CertAuthDetailsByIDPage.tsx b/frontend/src/pages/cert-manager/CertAuthDetailsByIDPage/CertAuthDetailsByIDPage.tsx
index ca73abd501..b464a2230a 100644
--- a/frontend/src/pages/cert-manager/CertAuthDetailsByIDPage/CertAuthDetailsByIDPage.tsx
+++ b/frontend/src/pages/cert-manager/CertAuthDetailsByIDPage/CertAuthDetailsByIDPage.tsx
@@ -57,33 +57,26 @@ const Page = () => {
] as const);
const onRemoveCaSubmit = async () => {
- try {
- if (!currentProject?.slug) return;
+ if (!currentProject?.slug) return;
- await deleteCa({
- caName,
- projectId: currentProject.id,
- type: CaType.INTERNAL
- });
+ await deleteCa({
+ caName,
+ projectId: currentProject.id,
+ type: CaType.INTERNAL
+ });
- createNotification({
- text: "Successfully deleted CA",
- type: "success"
- });
+ createNotification({
+ text: "Successfully deleted CA",
+ type: "success"
+ });
- handlePopUpClose("deleteCa");
- navigate({
- to: "/projects/cert-management/$projectId/certificate-authorities",
- params: {
- projectId
- }
- });
- } catch {
- createNotification({
- text: "Failed to delete CA",
- type: "error"
- });
- }
+ handlePopUpClose("deleteCa");
+ navigate({
+ to: "/projects/cert-management/$projectId/certificate-authorities",
+ params: {
+ projectId
+ }
+ });
};
return (
diff --git a/frontend/src/pages/cert-manager/CertAuthDetailsByIDPage/components/CaRenewalModal.tsx b/frontend/src/pages/cert-manager/CertAuthDetailsByIDPage/components/CaRenewalModal.tsx
index 857586a584..c6283da375 100644
--- a/frontend/src/pages/cert-manager/CertAuthDetailsByIDPage/components/CaRenewalModal.tsx
+++ b/frontend/src/pages/cert-manager/CertAuthDetailsByIDPage/components/CaRenewalModal.tsx
@@ -84,27 +84,23 @@ export const CaRenewalModal = ({ popUp, handlePopUpToggle }: Props) => {
// }, [ca, parentCa]);
const onFormSubmit = async ({ type, notAfter }: FormData) => {
- try {
- if (!projectSlug || !popUpData.caId) return;
-
- await renewCa({
- projectSlug,
- caId: popUpData.caId,
- notAfter,
- type
- });
-
- handlePopUpToggle("renewCa", false);
-
- createNotification({
- text: "Successfully renewed CA",
- type: "success"
- });
-
- reset();
- } catch (err) {
- console.error(err);
- }
+ if (!projectSlug || !popUpData.caId) return;
+
+ await renewCa({
+ projectSlug,
+ caId: popUpData.caId,
+ notAfter,
+ type
+ });
+
+ handlePopUpToggle("renewCa", false);
+
+ createNotification({
+ text: "Successfully renewed CA",
+ type: "success"
+ });
+
+ reset();
};
return (
diff --git a/frontend/src/pages/cert-manager/CertificateAuthoritiesPage/components/CaInstallCertModal/ExternalCaInstallForm.tsx b/frontend/src/pages/cert-manager/CertificateAuthoritiesPage/components/CaInstallCertModal/ExternalCaInstallForm.tsx
index f730322c9d..8a7e9690ec 100644
--- a/frontend/src/pages/cert-manager/CertificateAuthoritiesPage/components/CaInstallCertModal/ExternalCaInstallForm.tsx
+++ b/frontend/src/pages/cert-manager/CertificateAuthoritiesPage/components/CaInstallCertModal/ExternalCaInstallForm.tsx
@@ -48,29 +48,22 @@ export const ExternalCaInstallForm = ({ caId, handlePopUpToggle }: Props) => {
}, []);
const onFormSubmit = async ({ certificate, certificateChain }: FormData) => {
- try {
- if (!csr || !caId || !currentProject?.slug) return;
+ if (!csr || !caId || !currentProject?.slug) return;
- await importCaCertificate({
- caId,
- projectSlug: currentProject?.slug,
- certificate,
- certificateChain
- });
+ await importCaCertificate({
+ caId,
+ projectSlug: currentProject?.slug,
+ certificate,
+ certificateChain
+ });
- reset();
+ reset();
- createNotification({
- text: "Successfully installed certificate for CA",
- type: "success"
- });
- handlePopUpToggle("installCaCert", false);
- } catch {
- createNotification({
- text: "Failed to install certificate for CA",
- type: "error"
- });
- }
+ createNotification({
+ text: "Successfully installed certificate for CA",
+ type: "success"
+ });
+ handlePopUpToggle("installCaCert", false);
};
const downloadTxtFile = (filename: string, content: string) => {
diff --git a/frontend/src/pages/cert-manager/CertificateAuthoritiesPage/components/CaInstallCertModal/InternalCaInstallForm.tsx b/frontend/src/pages/cert-manager/CertificateAuthoritiesPage/components/CaInstallCertModal/InternalCaInstallForm.tsx
index 5979d97118..f80e21212e 100644
--- a/frontend/src/pages/cert-manager/CertificateAuthoritiesPage/components/CaInstallCertModal/InternalCaInstallForm.tsx
+++ b/frontend/src/pages/cert-manager/CertificateAuthoritiesPage/components/CaInstallCertModal/InternalCaInstallForm.tsx
@@ -101,37 +101,30 @@ 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({
- caId: parentCaId,
- csr,
- maxPathLength: Number(maxPathLength),
- notAfter,
- notBefore: new Date().toISOString()
- });
-
- await importCaCertificate({
- caId,
- projectSlug: currentProject?.slug,
- certificate,
- certificateChain
- });
-
- reset();
-
- createNotification({
- text: "Successfully installed certificate for CA",
- type: "success"
- });
- handlePopUpToggle("installCaCert", false);
- } catch {
- createNotification({
- text: "Failed to install certificate for CA",
- type: "error"
- });
- }
+ if (!csr || !caId || !currentProject?.slug) return;
+
+ const { certificate, certificateChain } = await signIntermediate({
+ caId: parentCaId,
+ csr,
+ maxPathLength: Number(maxPathLength),
+ notAfter,
+ notBefore: new Date().toISOString()
+ });
+
+ await importCaCertificate({
+ caId,
+ projectSlug: currentProject?.slug,
+ certificate,
+ certificateChain
+ });
+
+ reset();
+
+ createNotification({
+ text: "Successfully installed certificate for CA",
+ type: "success"
+ });
+ handlePopUpToggle("installCaCert", false);
};
function generatePathLengthOpts(parentCaMaxPathLength: number): number[] {
diff --git a/frontend/src/pages/cert-manager/CertificateAuthoritiesPage/components/CaModal.tsx b/frontend/src/pages/cert-manager/CertificateAuthoritiesPage/components/CaModal.tsx
index a19a3a9c77..53434b79d8 100644
--- a/frontend/src/pages/cert-manager/CertificateAuthoritiesPage/components/CaModal.tsx
+++ b/frontend/src/pages/cert-manager/CertificateAuthoritiesPage/components/CaModal.tsx
@@ -175,48 +175,40 @@ export const CaModal = ({ popUp, handlePopUpToggle }: Props) => {
status,
configuration
}: FormData) => {
- try {
- if (!currentProject?.slug) return;
+ if (!currentProject?.slug) return;
- if (ca) {
- // update
- await updateMutateAsync({
- caName: ca.name,
- projectId: currentProject.id,
- name,
- type: CaType.INTERNAL,
- status,
- enableDirectIssuance
- });
- } else {
- // create
- await createMutateAsync({
- projectId: currentProject.id,
- name,
- type,
- status,
- enableDirectIssuance,
- configuration: {
- ...configuration,
- maxPathLength: Number(configuration.maxPathLength)
- }
- });
- }
-
- reset();
- handlePopUpToggle("ca", false);
-
- createNotification({
- text: `Successfully ${ca ? "updated" : "created"} CA`,
- type: "success"
+ if (ca) {
+ // update
+ await updateMutateAsync({
+ caName: ca.name,
+ projectId: currentProject.id,
+ name,
+ type: CaType.INTERNAL,
+ status,
+ enableDirectIssuance
});
- } catch (err) {
- console.error(err);
- createNotification({
- text: "Failed to create CA",
- type: "error"
+ } else {
+ // create
+ await createMutateAsync({
+ projectId: currentProject.id,
+ name,
+ type,
+ status,
+ enableDirectIssuance,
+ configuration: {
+ ...configuration,
+ maxPathLength: Number(configuration.maxPathLength)
+ }
});
}
+
+ reset();
+ handlePopUpToggle("ca", false);
+
+ createNotification({
+ text: `Successfully ${ca ? "updated" : "created"} CA`,
+ type: "success"
+ });
};
return (
diff --git a/frontend/src/pages/cert-manager/CertificateAuthoritiesPage/components/CaSection.tsx b/frontend/src/pages/cert-manager/CertificateAuthoritiesPage/components/CaSection.tsx
index e853dc8010..a817042a7f 100644
--- a/frontend/src/pages/cert-manager/CertificateAuthoritiesPage/components/CaSection.tsx
+++ b/frontend/src/pages/cert-manager/CertificateAuthoritiesPage/components/CaSection.tsx
@@ -29,44 +29,29 @@ export const CaSection = () => {
] as const);
const onRemoveCaSubmit = async (caName: string) => {
- try {
- if (!currentProject?.slug) return;
+ if (!currentProject?.slug) return;
- await deleteCa({ caName, projectId: currentProject.id, type: CaType.INTERNAL });
+ await deleteCa({ caName, projectId: currentProject.id, type: CaType.INTERNAL });
- createNotification({
- text: "Successfully deleted CA",
- type: "success"
- });
+ createNotification({
+ text: "Successfully deleted CA",
+ type: "success"
+ });
- handlePopUpClose("deleteCa");
- } catch {
- createNotification({
- text: "Failed to delete CA",
- type: "error"
- });
- }
+ handlePopUpClose("deleteCa");
};
const onUpdateCaStatus = async ({ caName, status }: { caName: string; status: CaStatus }) => {
- try {
- if (!currentProject?.slug) return;
+ if (!currentProject?.slug) return;
- await updateCa({ caName, projectId: currentProject.id, type: CaType.INTERNAL, status });
+ await updateCa({ caName, projectId: currentProject.id, type: CaType.INTERNAL, status });
- createNotification({
- text: `Successfully ${status === CaStatus.ACTIVE ? "enabled" : "disabled"} CA`,
- type: "success"
- });
+ createNotification({
+ text: `Successfully ${status === CaStatus.ACTIVE ? "enabled" : "disabled"} CA`,
+ type: "success"
+ });
- handlePopUpClose("caStatus");
- } catch (err) {
- console.error(err);
- createNotification({
- text: `Failed to ${status === CaStatus.ACTIVE ? "enabled" : "disabled"} CA`,
- type: "error"
- });
- }
+ handlePopUpClose("caStatus");
};
return (
diff --git a/frontend/src/pages/cert-manager/CertificateAuthoritiesPage/components/ExternalCaModal.tsx b/frontend/src/pages/cert-manager/CertificateAuthoritiesPage/components/ExternalCaModal.tsx
index 121c32e5f5..825368d1cc 100644
--- a/frontend/src/pages/cert-manager/CertificateAuthoritiesPage/components/ExternalCaModal.tsx
+++ b/frontend/src/pages/cert-manager/CertificateAuthoritiesPage/components/ExternalCaModal.tsx
@@ -297,63 +297,55 @@ export const ExternalCaModal = ({ popUp, handlePopUpToggle }: Props) => {
status,
configuration: formConfiguration
}: FormData) => {
- try {
- if (!currentProject?.slug) return;
-
- let configPayload: any;
-
- if (type === CaType.ACME && "dnsAppConnection" in formConfiguration) {
- configPayload = {
- dnsProviderConfig: formConfiguration.dnsProviderConfig,
- directoryUrl: formConfiguration.directoryUrl,
- accountEmail: formConfiguration.accountEmail,
- dnsAppConnectionId: formConfiguration.dnsAppConnection.id,
- eabKid: formConfiguration.eabKid,
- eabHmacKey: formConfiguration.eabHmacKey
- };
- } else if (type === CaType.AZURE_AD_CS && "azureAdcsConnection" in formConfiguration) {
- configPayload = {
- azureAdcsConnectionId: formConfiguration.azureAdcsConnection.id
- };
- } else {
- throw new Error("Invalid certificate authority configuration");
- }
-
- if (ca) {
- await updateMutateAsync({
- caName: ca.name,
- projectId: currentProject.id,
- name,
- type,
- status,
- enableDirectIssuance: type === CaType.AZURE_AD_CS ? false : enableDirectIssuance,
- configuration: configPayload
- });
- } else {
- await createMutateAsync({
- projectId: currentProject.id,
- name,
- type,
- status,
- enableDirectIssuance: type === CaType.AZURE_AD_CS ? false : enableDirectIssuance,
- configuration: configPayload
- });
- }
-
- reset();
- handlePopUpToggle("ca", false);
+ if (!currentProject?.slug) return;
+
+ let configPayload: any;
+
+ if (type === CaType.ACME && "dnsAppConnection" in formConfiguration) {
+ configPayload = {
+ dnsProviderConfig: formConfiguration.dnsProviderConfig,
+ directoryUrl: formConfiguration.directoryUrl,
+ accountEmail: formConfiguration.accountEmail,
+ dnsAppConnectionId: formConfiguration.dnsAppConnection.id,
+ eabKid: formConfiguration.eabKid,
+ eabHmacKey: formConfiguration.eabHmacKey
+ };
+ } else if (type === CaType.AZURE_AD_CS && "azureAdcsConnection" in formConfiguration) {
+ configPayload = {
+ azureAdcsConnectionId: formConfiguration.azureAdcsConnection.id
+ };
+ } else {
+ throw new Error("Invalid certificate authority configuration");
+ }
- createNotification({
- text: `Successfully ${ca ? "updated" : "created"} CA`,
- type: "success"
+ if (ca) {
+ await updateMutateAsync({
+ caName: ca.name,
+ projectId: currentProject.id,
+ name,
+ type,
+ status,
+ enableDirectIssuance: type === CaType.AZURE_AD_CS ? false : enableDirectIssuance,
+ configuration: configPayload
});
- } catch (err) {
- console.error(err);
- createNotification({
- text: "Failed to create CA",
- type: "error"
+ } else {
+ await createMutateAsync({
+ projectId: currentProject.id,
+ name,
+ type,
+ status,
+ enableDirectIssuance: type === CaType.AZURE_AD_CS ? false : enableDirectIssuance,
+ configuration: configPayload
});
}
+
+ reset();
+ handlePopUpToggle("ca", false);
+
+ createNotification({
+ text: `Successfully ${ca ? "updated" : "created"} CA`,
+ type: "success"
+ });
};
return (
diff --git a/frontend/src/pages/cert-manager/CertificateAuthoritiesPage/components/ExternalCaSection.tsx b/frontend/src/pages/cert-manager/CertificateAuthoritiesPage/components/ExternalCaSection.tsx
index 14ce122ec9..b40dec6f53 100644
--- a/frontend/src/pages/cert-manager/CertificateAuthoritiesPage/components/ExternalCaSection.tsx
+++ b/frontend/src/pages/cert-manager/CertificateAuthoritiesPage/components/ExternalCaSection.tsx
@@ -25,23 +25,16 @@ export const ExternalCaSection = () => {
] as const);
const onRemoveCaSubmit = async (caName: string, type: CaType) => {
- try {
- if (!currentProject?.id) return;
+ if (!currentProject?.id) return;
- await deleteCa({ caName, type, projectId: currentProject.id });
+ await deleteCa({ caName, type, projectId: currentProject.id });
- createNotification({
- text: "Successfully deleted CA",
- type: "success"
- });
+ createNotification({
+ text: "Successfully deleted CA",
+ type: "success"
+ });
- handlePopUpClose("deleteCa");
- } catch {
- createNotification({
- text: "Failed to delete CA",
- type: "error"
- });
- }
+ handlePopUpClose("deleteCa");
};
const onUpdateCaStatus = async ({
@@ -53,24 +46,16 @@ export const ExternalCaSection = () => {
type: CaType;
status: CaStatus;
}) => {
- try {
- if (!currentProject?.slug) return;
+ if (!currentProject?.slug) return;
- await updateCa({ caName: name, type, status, projectId: currentProject.id });
+ await updateCa({ caName: name, type, status, projectId: currentProject.id });
- createNotification({
- text: `Successfully ${status === CaStatus.ACTIVE ? "enabled" : "disabled"} CA`,
- type: "success"
- });
+ createNotification({
+ text: `Successfully ${status === CaStatus.ACTIVE ? "enabled" : "disabled"} CA`,
+ type: "success"
+ });
- handlePopUpClose("caStatus");
- } catch (err) {
- console.error(err);
- createNotification({
- text: `Failed to ${status === CaStatus.ACTIVE ? "enable" : "disable"} CA`,
- type: "error"
- });
- }
+ handlePopUpClose("caStatus");
};
return (
diff --git a/frontend/src/pages/cert-manager/CertificatesPage/components/CertificateImportModal.tsx b/frontend/src/pages/cert-manager/CertificatesPage/components/CertificateImportModal.tsx
index bb0bbda0bd..d0434b79ad 100644
--- a/frontend/src/pages/cert-manager/CertificatesPage/components/CertificateImportModal.tsx
+++ b/frontend/src/pages/cert-manager/CertificatesPage/components/CertificateImportModal.tsx
@@ -71,38 +71,30 @@ export const CertificateImportModal = ({ popUp, handlePopUpToggle }: Props) => {
chainPem,
collectionId
}: FormData) => {
- try {
- if (!currentProject?.slug) return;
-
- const { serialNumber, certificate, certificateChain, privateKey } = await importCertificate({
- projectSlug: currentProject.slug,
-
- certificatePem,
- privateKeyPem,
- chainPem,
- pkiCollectionId: collectionId
- });
-
- reset();
-
- setCertificateDetails({
- serialNumber,
- certificate,
- certificateChain,
- privateKey
- });
-
- createNotification({
- text: "Successfully imported certificate",
- type: "success"
- });
- } catch (err) {
- console.error(err);
- createNotification({
- text: "Failed to import certificate",
- type: "error"
- });
- }
+ if (!currentProject?.slug) return;
+
+ const { serialNumber, certificate, certificateChain, privateKey } = await importCertificate({
+ projectSlug: currentProject.slug,
+
+ certificatePem,
+ privateKeyPem,
+ chainPem,
+ pkiCollectionId: collectionId
+ });
+
+ reset();
+
+ setCertificateDetails({
+ serialNumber,
+ certificate,
+ certificateChain,
+ privateKey
+ });
+
+ createNotification({
+ text: "Successfully imported certificate",
+ type: "success"
+ });
};
return (
diff --git a/frontend/src/pages/cert-manager/CertificatesPage/components/CertificateIssuanceModal.tsx b/frontend/src/pages/cert-manager/CertificatesPage/components/CertificateIssuanceModal.tsx
index dc0dffb0d4..537229714e 100644
--- a/frontend/src/pages/cert-manager/CertificatesPage/components/CertificateIssuanceModal.tsx
+++ b/frontend/src/pages/cert-manager/CertificatesPage/components/CertificateIssuanceModal.tsx
@@ -242,84 +242,72 @@ export const CertificateIssuanceModal = ({ popUp, handlePopUpToggle, profileId }
keyUsages,
extendedKeyUsages
}: FormData) => {
- try {
- if (!currentProject?.slug) {
- createNotification({
- text: "Project not found. Please refresh and try again.",
- type: "error"
- });
- return;
- }
+ if (!currentProject?.slug) {
+ createNotification({
+ text: "Project not found. Please refresh and try again.",
+ type: "error"
+ });
+ return;
+ }
- if (!formProfileId) {
+ if (!formProfileId) {
+ createNotification({
+ text: "Please select a certificate profile.",
+ type: "error"
+ });
+ return;
+ }
+
+ let commonName = "";
+ if (
+ constraints.shouldShowSubjectSection &&
+ subjectAttributes &&
+ subjectAttributes.length > 0
+ ) {
+ commonName = getAttributeValue(subjectAttributes, "common_name");
+ if (!commonName.trim()) {
createNotification({
- text: "Please select a certificate profile.",
+ text: "Common name is required.",
type: "error"
});
return;
}
+ }
- let commonName = "";
- if (
- constraints.shouldShowSubjectSection &&
- subjectAttributes &&
- subjectAttributes.length > 0
- ) {
- commonName = getAttributeValue(subjectAttributes, "common_name");
- if (!commonName.trim()) {
- createNotification({
- text: "Common name is required.",
- type: "error"
- });
- return;
- }
- }
-
- const certificateRequest: any = {
- profileId: formProfileId,
- projectSlug: currentProject.slug,
- ttl,
- signatureAlgorithm,
- keyAlgorithm,
- keyUsages: filterUsages(keyUsages) as CertKeyUsage[],
- extendedKeyUsages: filterUsages(extendedKeyUsages) as CertExtendedKeyUsage[]
- };
-
- if (constraints.shouldShowSubjectSection && commonName) {
- certificateRequest.commonName = commonName;
- }
- if (constraints.shouldShowSanSection && subjectAltNames && subjectAltNames.length > 0) {
- const formattedSans = formatSubjectAltNames(subjectAltNames);
- if (formattedSans && formattedSans.length > 0) {
- certificateRequest.altNames = formattedSans;
- }
+ const certificateRequest: any = {
+ profileId: formProfileId,
+ projectSlug: currentProject.slug,
+ ttl,
+ signatureAlgorithm,
+ keyAlgorithm,
+ keyUsages: filterUsages(keyUsages) as CertKeyUsage[],
+ extendedKeyUsages: filterUsages(extendedKeyUsages) as CertExtendedKeyUsage[]
+ };
+
+ if (constraints.shouldShowSubjectSection && commonName) {
+ certificateRequest.commonName = commonName;
+ }
+ if (constraints.shouldShowSanSection && subjectAltNames && subjectAltNames.length > 0) {
+ const formattedSans = formatSubjectAltNames(subjectAltNames);
+ if (formattedSans && formattedSans.length > 0) {
+ certificateRequest.altNames = formattedSans;
}
+ }
- const { serialNumber, certificate, certificateChain, privateKey } =
- await createCertificate(certificateRequest);
+ const { serialNumber, certificate, certificateChain, privateKey } =
+ await createCertificate(certificateRequest);
- setCertificateDetails({
- serialNumber,
- certificate,
- certificateChain,
- privateKey
- });
+ setCertificateDetails({
+ serialNumber,
+ certificate,
+ certificateChain,
+ privateKey
+ });
- createNotification({
- 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"
- });
- }
+ createNotification({
+ text: "Successfully created certificate",
+ type: "success"
+ });
},
[
currentProject?.slug,
diff --git a/frontend/src/pages/cert-manager/CertificatesPage/components/CertificateManageRenewalModal.tsx b/frontend/src/pages/cert-manager/CertificatesPage/components/CertificateManageRenewalModal.tsx
index d6199678a4..96eb2654a2 100644
--- a/frontend/src/pages/cert-manager/CertificatesPage/components/CertificateManageRenewalModal.tsx
+++ b/frontend/src/pages/cert-manager/CertificatesPage/components/CertificateManageRenewalModal.tsx
@@ -163,38 +163,28 @@ 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.",
- type: "error"
- });
- return;
- }
-
- await updateRenewalConfig({
- certificateId: certificateData.certificateId,
- renewBeforeDays: data.renewBeforeDays,
- projectSlug: currentProject.slug
- });
-
+ if (!currentProject?.slug) {
createNotification({
- text: isAutoRenewalEnabled
- ? "Auto-renewal configuration updated successfully"
- : "Auto-renewal enabled successfully",
- type: "success"
- });
-
- 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.",
+ text: "Unable to update auto-renewal: Project not found. Please refresh the page and try again.",
type: "error"
});
+ return;
}
+
+ await updateRenewalConfig({
+ certificateId: certificateData.certificateId,
+ renewBeforeDays: data.renewBeforeDays,
+ projectSlug: currentProject.slug
+ });
+
+ createNotification({
+ text: isAutoRenewalEnabled
+ ? "Auto-renewal configuration updated successfully"
+ : "Auto-renewal enabled successfully",
+ type: "success"
+ });
+
+ handlePopUpToggle("manageRenewal", false);
};
const getModalTitle = () => {
diff --git a/frontend/src/pages/cert-manager/CertificatesPage/components/CertificateModal.tsx b/frontend/src/pages/cert-manager/CertificatesPage/components/CertificateModal.tsx
index 22718222aa..f56f0fde83 100644
--- a/frontend/src/pages/cert-manager/CertificatesPage/components/CertificateModal.tsx
+++ b/frontend/src/pages/cert-manager/CertificatesPage/components/CertificateModal.tsx
@@ -186,45 +186,37 @@ export const CertificateModal = ({ popUp, handlePopUpToggle }: Props) => {
keyUsages,
extendedKeyUsages
}: FormData) => {
- try {
- if (!currentProject?.slug) return;
+ if (!currentProject?.slug) return;
- const { serialNumber, certificate, certificateChain, privateKey } = await createCertificate({
- caId: !selectedCertTemplate ? caId : undefined,
- certificateTemplateId: selectedCertTemplate ? selectedCertTemplateId : undefined,
- projectSlug: currentProject.slug,
- pkiCollectionId: collectionId,
- commonName,
- subjectAltNames,
- ttl,
- keyUsages: Object.entries(keyUsages)
- .filter(([, value]) => value)
- .map(([key]) => key as CertKeyUsage),
- extendedKeyUsages: Object.entries(extendedKeyUsages)
- .filter(([, value]) => value)
- .map(([key]) => key as CertExtendedKeyUsage)
- });
+ const { serialNumber, certificate, certificateChain, privateKey } = await createCertificate({
+ caId: !selectedCertTemplate ? caId : undefined,
+ certificateTemplateId: selectedCertTemplate ? selectedCertTemplateId : undefined,
+ projectSlug: currentProject.slug,
+ pkiCollectionId: collectionId,
+ commonName,
+ subjectAltNames,
+ ttl,
+ keyUsages: Object.entries(keyUsages)
+ .filter(([, value]) => value)
+ .map(([key]) => key as CertKeyUsage),
+ extendedKeyUsages: Object.entries(extendedKeyUsages)
+ .filter(([, value]) => value)
+ .map(([key]) => key as CertExtendedKeyUsage)
+ });
- reset();
+ reset();
- setCertificateDetails({
- serialNumber,
- certificate,
- certificateChain,
- privateKey
- });
+ setCertificateDetails({
+ serialNumber,
+ certificate,
+ certificateChain,
+ privateKey
+ });
- createNotification({
- text: "Successfully created certificate",
- type: "success"
- });
- } catch (err) {
- console.error(err);
- createNotification({
- text: "Failed to create certificate",
- type: "error"
- });
- }
+ createNotification({
+ text: "Successfully created certificate",
+ type: "success"
+ });
};
useEffect(() => {
diff --git a/frontend/src/pages/cert-manager/CertificatesPage/components/CertificateRenewalConfigModal.tsx b/frontend/src/pages/cert-manager/CertificatesPage/components/CertificateRenewalConfigModal.tsx
index c952f1e546..0391518665 100644
--- a/frontend/src/pages/cert-manager/CertificatesPage/components/CertificateRenewalConfigModal.tsx
+++ b/frontend/src/pages/cert-manager/CertificatesPage/components/CertificateRenewalConfigModal.tsx
@@ -61,34 +61,26 @@ export const CertificateRenewalConfigModal = ({ popUp, handlePopUpToggle }: Prop
const renewBeforeDays = watch("renewBeforeDays");
const onSubmit = async (data: FormData) => {
- try {
- if (!currentProject?.slug) {
- createNotification({
- text: "Project not found",
- type: "error"
- });
- return;
- }
-
- await updateRenewalConfig({
- certificateId: certificateData.certificateId,
- renewBeforeDays: data.renewBeforeDays,
- projectSlug: currentProject.slug
- });
-
- createNotification({
- text: "Successfully updated auto-renewal configuration",
- type: "success"
- });
-
- handlePopUpToggle("configureRenewal", false);
- } catch (err) {
- console.error(err);
+ if (!currentProject?.slug) {
createNotification({
- text: "Failed to update auto-renewal configuration",
+ text: "Project not found",
type: "error"
});
+ return;
}
+
+ await updateRenewalConfig({
+ certificateId: certificateData.certificateId,
+ renewBeforeDays: data.renewBeforeDays,
+ projectSlug: currentProject.slug
+ });
+
+ createNotification({
+ text: "Successfully updated auto-renewal configuration",
+ type: "success"
+ });
+
+ handlePopUpToggle("configureRenewal", false);
};
return (
diff --git a/frontend/src/pages/cert-manager/CertificatesPage/components/CertificateRenewalDisableModal.tsx b/frontend/src/pages/cert-manager/CertificatesPage/components/CertificateRenewalDisableModal.tsx
index 613080cd76..e44d7e774e 100644
--- a/frontend/src/pages/cert-manager/CertificatesPage/components/CertificateRenewalDisableModal.tsx
+++ b/frontend/src/pages/cert-manager/CertificatesPage/components/CertificateRenewalDisableModal.tsx
@@ -19,34 +19,26 @@ export const CertificateRenewalDisableModal = ({ popUp, handlePopUpToggle }: Pro
};
const onDisableConfirm = async () => {
- try {
- if (!currentProject?.slug) {
- createNotification({
- text: "Project not found",
- type: "error"
- });
- return;
- }
-
- await updateRenewalConfig({
- certificateId: certificateData.certificateId,
- projectSlug: currentProject.slug,
- enableAutoRenewal: false
- });
-
+ if (!currentProject?.slug) {
createNotification({
- text: "Successfully disabled auto-renewal",
- type: "success"
- });
-
- handlePopUpToggle("disableRenewal", false);
- } catch (err) {
- console.error(err);
- createNotification({
- text: "Failed to disable auto-renewal",
+ text: "Project not found",
type: "error"
});
+ return;
}
+
+ await updateRenewalConfig({
+ certificateId: certificateData.certificateId,
+ projectSlug: currentProject.slug,
+ enableAutoRenewal: false
+ });
+
+ createNotification({
+ text: "Successfully disabled auto-renewal",
+ type: "success"
+ });
+
+ handlePopUpToggle("disableRenewal", false);
};
return (
diff --git a/frontend/src/pages/cert-manager/CertificatesPage/components/CertificateRenewalModal.tsx b/frontend/src/pages/cert-manager/CertificatesPage/components/CertificateRenewalModal.tsx
index 0e2b1c17dc..87906e5a53 100644
--- a/frontend/src/pages/cert-manager/CertificatesPage/components/CertificateRenewalModal.tsx
+++ b/frontend/src/pages/cert-manager/CertificatesPage/components/CertificateRenewalModal.tsx
@@ -18,22 +18,18 @@ export const CertificateRenewalModal = ({ popUp, handlePopUpToggle }: Props) =>
const { mutateAsync: renewCertificate, isPending: isRenewing } = useRenewCertificate();
const onRenewConfirm = async () => {
- try {
- const { certificateId } = popUp.renewCertificate.data as { certificateId: string };
+ const { certificateId } = popUp.renewCertificate.data as { certificateId: string };
- await renewCertificate({
- certificateId
- });
+ await renewCertificate({
+ certificateId
+ });
- createNotification({
- text: "Certificate renewed successfully",
- type: "success"
- });
+ createNotification({
+ text: "Certificate renewed successfully",
+ type: "success"
+ });
- handlePopUpToggle("renewCertificate", false);
- } catch (err) {
- console.error(err);
- }
+ handlePopUpToggle("renewCertificate", false);
};
const certificateData = popUp.renewCertificate.data as {
diff --git a/frontend/src/pages/cert-manager/CertificatesPage/components/CertificateRevocationModal.tsx b/frontend/src/pages/cert-manager/CertificatesPage/components/CertificateRevocationModal.tsx
index 1d15392960..d9a564fb1d 100644
--- a/frontend/src/pages/cert-manager/CertificatesPage/components/CertificateRevocationModal.tsx
+++ b/frontend/src/pages/cert-manager/CertificatesPage/components/CertificateRevocationModal.tsx
@@ -48,31 +48,23 @@ export const CertificateRevocationModal = ({ popUp, handlePopUpToggle }: Props)
});
const onFormSubmit = async ({ revocationReason }: FormData) => {
- try {
- if (!currentProject?.slug) return;
+ if (!currentProject?.slug) return;
- const { serialNumber } = popUp.revokeCertificate.data as { serialNumber: string };
+ const { serialNumber } = popUp.revokeCertificate.data as { serialNumber: string };
- await revokeCertificate({
- projectSlug: currentProject.slug,
- serialNumber,
- revocationReason
- });
+ await revokeCertificate({
+ projectSlug: currentProject.slug,
+ serialNumber,
+ revocationReason
+ });
- reset();
- handlePopUpToggle("revokeCertificate", false);
+ reset();
+ handlePopUpToggle("revokeCertificate", false);
- createNotification({
- text: "Successfully revoked certificate",
- type: "success"
- });
- } catch (err) {
- console.error(err);
- createNotification({
- text: "Failed to revoke certificate",
- type: "error"
- });
- }
+ createNotification({
+ text: "Successfully revoked certificate",
+ type: "success"
+ });
};
return (
diff --git a/frontend/src/pages/cert-manager/CertificatesPage/components/CertificateTemplateModal.tsx b/frontend/src/pages/cert-manager/CertificatesPage/components/CertificateTemplateModal.tsx
index 9d5d9355f9..66e9ec57aa 100644
--- a/frontend/src/pages/cert-manager/CertificatesPage/components/CertificateTemplateModal.tsx
+++ b/frontend/src/pages/cert-manager/CertificatesPage/components/CertificateTemplateModal.tsx
@@ -159,61 +159,53 @@ export const CertificateTemplateModal = ({ popUp, handlePopUpToggle, caId }: Pro
return;
}
- try {
- if (certTemplate) {
- await updateCertTemplate({
- id: certTemplate.id,
- projectId: currentProject.id,
- pkiCollectionId: collectionId,
- caId,
- name,
- commonName,
- subjectAlternativeName,
- ttl,
- keyUsages: Object.entries(keyUsages)
- .filter(([, value]) => value)
- .map(([key]) => key as CertKeyUsage),
- extendedKeyUsages: Object.entries(extendedKeyUsages)
- .filter(([, value]) => value)
- .map(([key]) => key as CertExtendedKeyUsage)
- });
-
- createNotification({
- text: "Successfully updated certificate template",
- type: "success"
- });
- } else {
- await createCertTemplate({
- projectId: currentProject.id,
- pkiCollectionId: collectionId,
- caId,
- name,
- commonName,
- subjectAlternativeName,
- ttl,
- keyUsages: Object.entries(keyUsages)
- .filter(([, value]) => value)
- .map(([key]) => key as CertKeyUsage),
- extendedKeyUsages: Object.entries(extendedKeyUsages)
- .filter(([, value]) => value)
- .map(([key]) => key as CertExtendedKeyUsage)
- });
+ if (certTemplate) {
+ await updateCertTemplate({
+ id: certTemplate.id,
+ projectId: currentProject.id,
+ pkiCollectionId: collectionId,
+ caId,
+ name,
+ commonName,
+ subjectAlternativeName,
+ ttl,
+ keyUsages: Object.entries(keyUsages)
+ .filter(([, value]) => value)
+ .map(([key]) => key as CertKeyUsage),
+ extendedKeyUsages: Object.entries(extendedKeyUsages)
+ .filter(([, value]) => value)
+ .map(([key]) => key as CertExtendedKeyUsage)
+ });
- createNotification({
- text: "Successfully created certificate template",
- type: "success"
- });
- }
+ createNotification({
+ text: "Successfully updated certificate template",
+ type: "success"
+ });
+ } else {
+ await createCertTemplate({
+ projectId: currentProject.id,
+ pkiCollectionId: collectionId,
+ caId,
+ name,
+ commonName,
+ subjectAlternativeName,
+ ttl,
+ keyUsages: Object.entries(keyUsages)
+ .filter(([, value]) => value)
+ .map(([key]) => key as CertKeyUsage),
+ extendedKeyUsages: Object.entries(extendedKeyUsages)
+ .filter(([, value]) => value)
+ .map(([key]) => key as CertExtendedKeyUsage)
+ });
- reset();
- handlePopUpToggle("certificateTemplate", false);
- } catch (err) {
- console.error(err);
createNotification({
- text: "Failed to save changes",
- type: "error"
+ text: "Successfully created certificate template",
+ type: "success"
});
}
+
+ reset();
+ handlePopUpToggle("certificateTemplate", false);
};
return (
diff --git a/frontend/src/pages/cert-manager/CertificatesPage/components/CertificateTemplatesSection.tsx b/frontend/src/pages/cert-manager/CertificatesPage/components/CertificateTemplatesSection.tsx
index 629553200c..ce55c7e804 100644
--- a/frontend/src/pages/cert-manager/CertificatesPage/components/CertificateTemplatesSection.tsx
+++ b/frontend/src/pages/cert-manager/CertificatesPage/components/CertificateTemplatesSection.tsx
@@ -41,25 +41,17 @@ export const CertificateTemplatesSection = ({ caId }: Props) => {
return;
}
- try {
- await deleteCertTemplate({
- id,
- projectId: currentProject.id
- });
+ await deleteCertTemplate({
+ id,
+ projectId: currentProject.id
+ });
- createNotification({
- text: "Successfully deleted certificate template",
- type: "success"
- });
+ createNotification({
+ text: "Successfully deleted certificate template",
+ type: "success"
+ });
- handlePopUpClose("deleteCertificateTemplate");
- } catch (err) {
- console.error(err);
- createNotification({
- text: "Failed to delete certificate template",
- type: "error"
- });
- }
+ handlePopUpClose("deleteCertificateTemplate");
};
return (
diff --git a/frontend/src/pages/cert-manager/CertificatesPage/components/CertificatesSection.tsx b/frontend/src/pages/cert-manager/CertificatesPage/components/CertificatesSection.tsx
index 4102d8ea5e..0252b12382 100644
--- a/frontend/src/pages/cert-manager/CertificatesPage/components/CertificatesSection.tsx
+++ b/frontend/src/pages/cert-manager/CertificatesPage/components/CertificatesSection.tsx
@@ -41,24 +41,16 @@ export const CertificatesSection = () => {
] as const);
const onRemoveCertificateSubmit = async (serialNumber: string) => {
- try {
- if (!currentProject?.slug) return;
+ if (!currentProject?.slug) return;
- await deleteCert({ serialNumber, projectSlug: currentProject.slug });
+ await deleteCert({ serialNumber, projectSlug: currentProject.slug });
- createNotification({
- text: "Successfully deleted certificate",
- type: "success"
- });
+ createNotification({
+ text: "Successfully deleted certificate",
+ type: "success"
+ });
- handlePopUpClose("deleteCertificate");
- } catch (err) {
- console.error(err);
- createNotification({
- text: "Failed to delete certificate",
- type: "error"
- });
- }
+ handlePopUpClose("deleteCertificate");
};
return (
diff --git a/frontend/src/pages/cert-manager/CertificatesPage/components/CertificatesTable.tsx b/frontend/src/pages/cert-manager/CertificatesPage/components/CertificatesTable.tsx
index 500286d672..77f287ac56 100644
--- a/frontend/src/pages/cert-manager/CertificatesPage/components/CertificatesTable.tsx
+++ b/frontend/src/pages/cert-manager/CertificatesPage/components/CertificatesTable.tsx
@@ -200,32 +200,24 @@ 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.",
- type: "error"
- });
- return;
- }
-
- await updateRenewalConfig({
- certificateId,
- projectSlug: currentProject.slug,
- enableAutoRenewal: false
- });
-
- createNotification({
- text: `Auto-renewal disabled for ${commonName}`,
- type: "success"
- });
- } catch (err) {
- console.error(err);
+ if (!currentProject?.slug) {
createNotification({
- text: "Failed to disable auto-renewal. Please try again or contact support if the issue persists.",
+ text: "Unable to disable auto-renewal: Project not found. Please refresh the page and try again.",
type: "error"
});
+ return;
}
+
+ await updateRenewalConfig({
+ certificateId,
+ projectSlug: currentProject.slug,
+ enableAutoRenewal: false
+ });
+
+ createNotification({
+ text: `Auto-renewal disabled for ${commonName}`,
+ type: "success"
+ });
};
return (
diff --git a/frontend/src/pages/cert-manager/IntegrationsListPage/components/PkiSyncsTab/PkiSyncTable/PkiSyncsTable.tsx b/frontend/src/pages/cert-manager/IntegrationsListPage/components/PkiSyncsTab/PkiSyncTable/PkiSyncsTable.tsx
index ca4aa7473d..f997c350d1 100644
--- a/frontend/src/pages/cert-manager/IntegrationsListPage/components/PkiSyncsTab/PkiSyncTable/PkiSyncsTable.tsx
+++ b/frontend/src/pages/cert-manager/IntegrationsListPage/components/PkiSyncsTab/PkiSyncTable/PkiSyncsTable.tsx
@@ -226,46 +226,32 @@ export const PkiSyncsTable = ({ pkiSyncs }: Props) => {
const isAutoSyncEnabled = !pkiSync.isAutoSyncEnabled;
- try {
- await updateSync.mutateAsync({
- syncId: pkiSync.id,
- projectId: pkiSync.projectId,
- destination: pkiSync.destination,
- isAutoSyncEnabled
- });
-
- createNotification({
- 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"
- });
- }
+ await updateSync.mutateAsync({
+ syncId: pkiSync.id,
+ projectId: pkiSync.projectId,
+ destination: pkiSync.destination,
+ isAutoSyncEnabled
+ });
+
+ createNotification({
+ text: `Successfully ${isAutoSyncEnabled ? "enabled" : "disabled"} auto-sync for ${destinationName} Sync`,
+ type: "success"
+ });
};
const handleTriggerSync = async (pkiSync: TPkiSync) => {
const destinationName = PKI_SYNC_MAP[pkiSync.destination].name;
- try {
- await triggerSync.mutateAsync({
- syncId: pkiSync.id,
- destination: pkiSync.destination,
- projectId: pkiSync.projectId
- });
-
- createNotification({
- text: `Successfully triggered ${destinationName} Sync`,
- type: "success"
- });
- } catch {
- createNotification({
- text: `Failed to trigger ${destinationName} Sync`,
- type: "error"
- });
- }
+ await triggerSync.mutateAsync({
+ syncId: pkiSync.id,
+ destination: pkiSync.destination,
+ projectId: pkiSync.projectId
+ });
+
+ createNotification({
+ text: `Successfully triggered ${destinationName} Sync`,
+ type: "success"
+ });
};
return (
diff --git a/frontend/src/pages/cert-manager/PkiCollectionDetailsByIDPage/PkiCollectionDetailsByIDPage.tsx b/frontend/src/pages/cert-manager/PkiCollectionDetailsByIDPage/PkiCollectionDetailsByIDPage.tsx
index b8235f488d..064f8f7a24 100644
--- a/frontend/src/pages/cert-manager/PkiCollectionDetailsByIDPage/PkiCollectionDetailsByIDPage.tsx
+++ b/frontend/src/pages/cert-manager/PkiCollectionDetailsByIDPage/PkiCollectionDetailsByIDPage.tsx
@@ -45,31 +45,24 @@ export const PkiCollectionPage = () => {
] as const);
const onDeletePkiCollectionSubmit = async (collectionIdToDelete: string) => {
- try {
- if (!projectId) return;
+ if (!projectId) return;
- await deletePkiCollection({
- projectId,
- collectionId: collectionIdToDelete
- });
+ await deletePkiCollection({
+ projectId,
+ collectionId: collectionIdToDelete
+ });
- createNotification({
- text: "Successfully deleted PKI collection",
- type: "success"
- });
- handlePopUpClose("deletePkiCollection");
- navigate({
- to: "/projects/cert-management/$projectId/certificates",
- params: {
- projectId
- }
- });
- } catch {
- createNotification({
- text: "Failed to delete PKI collection",
- type: "error"
- });
- }
+ createNotification({
+ text: "Successfully deleted PKI collection",
+ type: "success"
+ });
+ handlePopUpClose("deletePkiCollection");
+ navigate({
+ to: "/projects/cert-management/$projectId/certificates",
+ params: {
+ projectId
+ }
+ });
};
return (
diff --git a/frontend/src/pages/cert-manager/PkiSubscriberDetailsByIDPage/PkiSubscriberDetailsByIDPage.tsx b/frontend/src/pages/cert-manager/PkiSubscriberDetailsByIDPage/PkiSubscriberDetailsByIDPage.tsx
index 1f723b395d..572ee998e3 100644
--- a/frontend/src/pages/cert-manager/PkiSubscriberDetailsByIDPage/PkiSubscriberDetailsByIDPage.tsx
+++ b/frontend/src/pages/cert-manager/PkiSubscriberDetailsByIDPage/PkiSubscriberDetailsByIDPage.tsx
@@ -51,30 +51,22 @@ const Page = () => {
] as const);
const onRemoveSubscriberSubmit = async (subscriberNameToDelete: string) => {
- try {
- if (!projectId) return;
+ if (!projectId) return;
- await deletePkiSubscriber({ subscriberName: subscriberNameToDelete, projectId });
+ await deletePkiSubscriber({ subscriberName: subscriberNameToDelete, projectId });
- createNotification({
- text: "Successfully deleted subscriber",
- type: "success"
- });
+ createNotification({
+ text: "Successfully deleted subscriber",
+ type: "success"
+ });
- handlePopUpClose("deletePkiSubscriber");
- navigate({
- to: "/projects/cert-management/$projectId/subscribers",
- params: {
- projectId
- }
- });
- } catch (err) {
- console.error(err);
- createNotification({
- text: "Failed to delete subscriber",
- type: "error"
- });
- }
+ handlePopUpClose("deletePkiSubscriber");
+ navigate({
+ to: "/projects/cert-management/$projectId/subscribers",
+ params: {
+ projectId
+ }
+ });
};
return (
diff --git a/frontend/src/pages/cert-manager/PkiSubscriberDetailsByIDPage/components/PkiSubscriberDetailsSection.tsx b/frontend/src/pages/cert-manager/PkiSubscriberDetailsByIDPage/components/PkiSubscriberDetailsSection.tsx
index f9c94740ae..5da5be55a4 100644
--- a/frontend/src/pages/cert-manager/PkiSubscriberDetailsByIDPage/components/PkiSubscriberDetailsSection.tsx
+++ b/frontend/src/pages/cert-manager/PkiSubscriberDetailsByIDPage/components/PkiSubscriberDetailsSection.tsx
@@ -70,36 +70,28 @@ export const PkiSubscriberDetailsSection = ({ subscriberName, handlePopUpOpen }:
useOrderPkiSubscriberCert();
const onIssuePkiSubscriberCert = async () => {
- try {
- if (pkiSubscriber?.supportsImmediateCertIssuance) {
- const response = await issuePkiSubscriberCert({ subscriberName, projectId });
-
- setCertificateDetails({
- serialNumber: response.serialNumber,
- certificate: response.certificate,
- certificateChain: response.certificateChain,
- privateKey: response.privateKey
- });
-
- setIsModalOpen(true);
-
- createNotification({
- text: "Successfully issued certificate",
- type: "success"
- });
- } else {
- await orderPkiSubscriberCert({ subscriberName, projectId });
-
- createNotification({
- text: "Successfully ordered certificate. It will be issued after CA processing which could take a few minutes.",
- type: "info"
- });
- }
- } catch (err) {
- console.error(err);
+ if (pkiSubscriber?.supportsImmediateCertIssuance) {
+ const response = await issuePkiSubscriberCert({ subscriberName, projectId });
+
+ setCertificateDetails({
+ serialNumber: response.serialNumber,
+ certificate: response.certificate,
+ certificateChain: response.certificateChain,
+ privateKey: response.privateKey
+ });
+
+ setIsModalOpen(true);
+
+ createNotification({
+ text: "Successfully issued certificate",
+ type: "success"
+ });
+ } else {
+ await orderPkiSubscriberCert({ subscriberName, projectId });
+
createNotification({
- text: "Failed to issue certificate",
- type: "error"
+ text: "Successfully ordered certificate. It will be issued after CA processing which could take a few minutes.",
+ type: "info"
});
}
};
diff --git a/frontend/src/pages/cert-manager/PkiSubscribersPage/components/PkiSubscriberModal.tsx b/frontend/src/pages/cert-manager/PkiSubscribersPage/components/PkiSubscriberModal.tsx
index 4bc427e48c..15c016587e 100644
--- a/frontend/src/pages/cert-manager/PkiSubscribersPage/components/PkiSubscriberModal.tsx
+++ b/frontend/src/pages/cert-manager/PkiSubscribersPage/components/PkiSubscriberModal.tsx
@@ -276,117 +276,109 @@ export const PkiSubscriberModal = ({ popUp, handlePopUpToggle }: Props) => {
locality,
emailAddress
}: FormData) => {
- try {
- if (!projectId) return;
-
- if (!caId) {
- createNotification({
- text: "Please select an Issuing CA",
- type: "error"
- });
- return;
- }
-
- // Check if there is already a different subscriber with the same name
- const existingNames =
- subscribers?.filter((s) => s.id !== pkiSubscriber?.id).map((s) => s.name) || [];
-
- if (existingNames.includes(name.trim())) {
- createNotification({
- text: "A subscriber with this name already exists.",
- type: "error"
- });
- return;
- }
-
- // Validate Azure template for Azure ADCS CA
- if (selectedCa?.type === CaType.AZURE_AD_CS && !azureTemplateType) {
- createNotification({
- text: "Please select an Azure certificate template",
- type: "error"
- });
- return;
- }
-
- const keyUsagesList =
- selectedCa?.type === CaType.AZURE_AD_CS
- ? []
- : Object.entries(keyUsages)
- .filter(([, value]) => value)
- .map(([key]) => key as CertKeyUsage);
-
- const extendedKeyUsagesList =
- selectedCa?.type === CaType.AZURE_AD_CS
- ? []
- : Object.entries(extendedKeyUsages)
- .filter(([, value]) => value)
- .map(([key]) => key as CertExtendedKeyUsage);
-
- const subjectAlternativeNamesList = subjectAlternativeNames
- .split(",")
- .map((san) => san.trim())
- .filter(Boolean);
-
- const autoRenewalPeriodInDays = enableAutoRenewal
- ? convertTimeUnitValueToDays(renewalUnit, renewalBefore)
- : undefined;
-
- // Build properties object
- const properties = {
- ...(selectedCa?.type === CaType.AZURE_AD_CS && azureTemplateType && { azureTemplateType }),
- ...(organization && { organization }),
- ...(organizationalUnit && { organizationalUnit }),
- ...(country && { country }),
- ...(state && { state }),
- ...(locality && { locality }),
- ...(emailAddress && { emailAddress })
- };
-
- if (pkiSubscriber) {
- await updateMutateAsync({
- subscriberName: pkiSubscriber.name,
- projectId,
- name,
- caId,
- commonName,
- subjectAlternativeNames: subjectAlternativeNamesList,
- ttl,
- keyUsages: keyUsagesList,
- extendedKeyUsages: extendedKeyUsagesList,
- enableAutoRenewal,
- autoRenewalPeriodInDays,
- properties: Object.keys(properties).length > 0 ? properties : undefined
- });
- } else {
- await createMutateAsync({
- projectId,
- name,
- caId,
- commonName,
- subjectAlternativeNames: subjectAlternativeNamesList,
- ttl,
- keyUsages: keyUsagesList,
- extendedKeyUsages: extendedKeyUsagesList,
- enableAutoRenewal,
- autoRenewalPeriodInDays,
- properties: Object.keys(properties).length > 0 ? properties : undefined
- });
- }
-
- reset();
- handlePopUpToggle("pkiSubscriber", false);
+ if (!projectId) return;
+ if (!caId) {
createNotification({
- text: `Successfully ${pkiSubscriber ? "updated" : "added"} PKI subscriber`,
- type: "success"
+ text: "Please select an Issuing CA",
+ type: "error"
});
- } catch (err) {
- console.error(err);
+ return;
+ }
+
+ // Check if there is already a different subscriber with the same name
+ const existingNames =
+ subscribers?.filter((s) => s.id !== pkiSubscriber?.id).map((s) => s.name) || [];
+
+ if (existingNames.includes(name.trim())) {
+ createNotification({
+ text: "A subscriber with this name already exists.",
+ type: "error"
+ });
+ return;
+ }
+
+ // Validate Azure template for Azure ADCS CA
+ if (selectedCa?.type === CaType.AZURE_AD_CS && !azureTemplateType) {
createNotification({
- text: `Failed to ${pkiSubscriber ? "update" : "add"} PKI subscriber`,
+ text: "Please select an Azure certificate template",
type: "error"
});
+ return;
}
+
+ const keyUsagesList =
+ selectedCa?.type === CaType.AZURE_AD_CS
+ ? []
+ : Object.entries(keyUsages)
+ .filter(([, value]) => value)
+ .map(([key]) => key as CertKeyUsage);
+
+ const extendedKeyUsagesList =
+ selectedCa?.type === CaType.AZURE_AD_CS
+ ? []
+ : Object.entries(extendedKeyUsages)
+ .filter(([, value]) => value)
+ .map(([key]) => key as CertExtendedKeyUsage);
+
+ const subjectAlternativeNamesList = subjectAlternativeNames
+ .split(",")
+ .map((san) => san.trim())
+ .filter(Boolean);
+
+ const autoRenewalPeriodInDays = enableAutoRenewal
+ ? convertTimeUnitValueToDays(renewalUnit, renewalBefore)
+ : undefined;
+
+ // Build properties object
+ const properties = {
+ ...(selectedCa?.type === CaType.AZURE_AD_CS && azureTemplateType && { azureTemplateType }),
+ ...(organization && { organization }),
+ ...(organizationalUnit && { organizationalUnit }),
+ ...(country && { country }),
+ ...(state && { state }),
+ ...(locality && { locality }),
+ ...(emailAddress && { emailAddress })
+ };
+
+ if (pkiSubscriber) {
+ await updateMutateAsync({
+ subscriberName: pkiSubscriber.name,
+ projectId,
+ name,
+ caId,
+ commonName,
+ subjectAlternativeNames: subjectAlternativeNamesList,
+ ttl,
+ keyUsages: keyUsagesList,
+ extendedKeyUsages: extendedKeyUsagesList,
+ enableAutoRenewal,
+ autoRenewalPeriodInDays,
+ properties: Object.keys(properties).length > 0 ? properties : undefined
+ });
+ } else {
+ await createMutateAsync({
+ projectId,
+ name,
+ caId,
+ commonName,
+ subjectAlternativeNames: subjectAlternativeNamesList,
+ ttl,
+ keyUsages: keyUsagesList,
+ extendedKeyUsages: extendedKeyUsagesList,
+ enableAutoRenewal,
+ autoRenewalPeriodInDays,
+ properties: Object.keys(properties).length > 0 ? properties : undefined
+ });
+ }
+
+ reset();
+ handlePopUpToggle("pkiSubscriber", false);
+
+ createNotification({
+ text: `Successfully ${pkiSubscriber ? "updated" : "added"} PKI subscriber`,
+ type: "success"
+ });
};
return (
diff --git a/frontend/src/pages/cert-manager/PkiSubscribersPage/components/PkiSubscriberSection.tsx b/frontend/src/pages/cert-manager/PkiSubscribersPage/components/PkiSubscriberSection.tsx
index cb4b9ef396..e902711ce8 100644
--- a/frontend/src/pages/cert-manager/PkiSubscribersPage/components/PkiSubscriberSection.tsx
+++ b/frontend/src/pages/cert-manager/PkiSubscribersPage/components/PkiSubscriberSection.tsx
@@ -33,22 +33,14 @@ export const PkiSubscriberSection = () => {
] as const);
const onRemovePkiSubscriberSubmit = async (subscriberName: string) => {
- try {
- const subscriber = await deletePkiSubscriber({ subscriberName, projectId });
+ const subscriber = await deletePkiSubscriber({ subscriberName, projectId });
- createNotification({
- text: `Successfully deleted PKI subscriber: ${subscriber.name}`,
- type: "success"
- });
+ createNotification({
+ text: `Successfully deleted PKI subscriber: ${subscriber.name}`,
+ type: "success"
+ });
- handlePopUpClose("deletePkiSubscriber");
- } catch (err) {
- console.error(err);
- createNotification({
- text: "Failed to delete PKI subscriber",
- type: "error"
- });
- }
+ handlePopUpClose("deletePkiSubscriber");
};
const onUpdatePkiSubscriberStatus = async ({
@@ -58,24 +50,16 @@ export const PkiSubscriberSection = () => {
subscriberName: string;
status: PkiSubscriberStatus;
}) => {
- try {
- if (!currentProject?.slug) return;
+ if (!currentProject?.slug) return;
- await updatePkiSubscriber({ subscriberName, projectId, status });
+ await updatePkiSubscriber({ subscriberName, projectId, status });
- createNotification({
- text: `Successfully ${status === PkiSubscriberStatus.ACTIVE ? "enabled" : "disabled"} subscriber`,
- type: "success"
- });
+ createNotification({
+ text: `Successfully ${status === PkiSubscriberStatus.ACTIVE ? "enabled" : "disabled"} subscriber`,
+ type: "success"
+ });
- handlePopUpClose("pkiSubscriberStatus");
- } catch (err) {
- console.error(err);
- createNotification({
- text: `Failed to ${status === PkiSubscriberStatus.ACTIVE ? "enable" : "disable"} subscriber`,
- type: "error"
- });
- }
+ handlePopUpClose("pkiSubscriberStatus");
};
const subscriberStatusData = popUp?.pkiSubscriberStatus?.data as {
diff --git a/frontend/src/pages/cert-manager/PkiSyncDetailsByIDPage/components/PkiSyncActionTriggers.tsx b/frontend/src/pages/cert-manager/PkiSyncDetailsByIDPage/components/PkiSyncActionTriggers.tsx
index bb8e9d02ac..5171b4d951 100644
--- a/frontend/src/pages/cert-manager/PkiSyncDetailsByIDPage/components/PkiSyncActionTriggers.tsx
+++ b/frontend/src/pages/cert-manager/PkiSyncDetailsByIDPage/components/PkiSyncActionTriggers.tsx
@@ -86,44 +86,28 @@ export const PkiSyncActionTriggers = ({ pkiSync }: Props) => {
}, [pkiSync.id, setIsIdCopied]);
const handleTriggerSync = useCallback(async () => {
- try {
- await triggerSyncMutation.mutateAsync({
- syncId: id,
- destination,
- projectId
- });
- createNotification({
- 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"
- });
- }
+ await triggerSyncMutation.mutateAsync({
+ syncId: id,
+ destination,
+ projectId
+ });
+ createNotification({
+ text: "PKI sync job queued successfully",
+ type: "success"
+ });
}, [triggerSyncMutation, id, destination, projectId]);
const handleToggleAutoSync = useCallback(async () => {
- try {
- await updatePkiSyncMutation.mutateAsync({
- syncId: id,
- projectId,
- destination,
- isAutoSyncEnabled: !pkiSync.isAutoSyncEnabled
- });
- createNotification({
- 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"
- });
- }
+ await updatePkiSyncMutation.mutateAsync({
+ syncId: id,
+ projectId,
+ destination,
+ isAutoSyncEnabled: !pkiSync.isAutoSyncEnabled
+ });
+ createNotification({
+ text: `Auto-sync ${pkiSync.isAutoSyncEnabled ? "disabled" : "enabled"} successfully`,
+ type: "success"
+ });
}, [updatePkiSyncMutation, id, projectId, pkiSync.isAutoSyncEnabled]);
const permissionSubject = subject(ProjectPermissionSub.PkiSyncs, {
diff --git a/frontend/src/pages/cert-manager/PkiTemplateListPage/PkiTemplateListPage.tsx b/frontend/src/pages/cert-manager/PkiTemplateListPage/PkiTemplateListPage.tsx
index b395d0ec24..9ad2900625 100644
--- a/frontend/src/pages/cert-manager/PkiTemplateListPage/PkiTemplateListPage.tsx
+++ b/frontend/src/pages/cert-manager/PkiTemplateListPage/PkiTemplateListPage.tsx
@@ -78,25 +78,17 @@ export const PkiTemplateListPage = () => {
const deleteCertTemplate = useDeleteCertTemplateV2();
const onRemovePkiSubscriberSubmit = async () => {
- try {
- const pkiTemplate = await deleteCertTemplate.mutateAsync({
- projectId: currentProject.id,
- templateName: popUp?.deleteTemplate?.data?.name
- });
+ const pkiTemplate = await deleteCertTemplate.mutateAsync({
+ projectId: currentProject.id,
+ templateName: popUp?.deleteTemplate?.data?.name
+ });
- createNotification({
- text: `Successfully deleted PKI template: ${pkiTemplate.name}`,
- type: "success"
- });
+ createNotification({
+ text: `Successfully deleted PKI template: ${pkiTemplate.name}`,
+ type: "success"
+ });
- handlePopUpClose("deleteTemplate");
- } catch (err) {
- console.error(err);
- createNotification({
- text: "Failed to delete PKI subscriber",
- type: "error"
- });
- }
+ handlePopUpClose("deleteTemplate");
};
return (
diff --git a/frontend/src/pages/cert-manager/PkiTemplateListPage/components/PkiTemplateForm.tsx b/frontend/src/pages/cert-manager/PkiTemplateListPage/components/PkiTemplateForm.tsx
index 093a2fcc16..00aa192a6d 100644
--- a/frontend/src/pages/cert-manager/PkiTemplateListPage/components/PkiTemplateForm.tsx
+++ b/frontend/src/pages/cert-manager/PkiTemplateListPage/components/PkiTemplateForm.tsx
@@ -128,59 +128,51 @@ export const PkiTemplateForm = ({ certTemplate, handlePopUpToggle }: Props) => {
return;
}
- try {
- if (certTemplate) {
- await updateCertTemplate({
- templateName: certTemplate.name,
- projectId: currentProject.id,
- caName: ca.name,
- name,
- commonName,
- subjectAlternativeName,
- ttl,
- keyUsages: Object.entries(keyUsages)
- .filter(([, value]) => value)
- .map(([key]) => key as CertKeyUsage),
- extendedKeyUsages: Object.entries(extendedKeyUsages)
- .filter(([, value]) => value)
- .map(([key]) => key as CertExtendedKeyUsage)
- });
-
- createNotification({
- text: "Successfully updated certificate template",
- type: "success"
- });
- } else {
- await createCertTemplate({
- projectId: currentProject.id,
- caName: ca.name,
- name,
- commonName,
- subjectAlternativeName,
- ttl,
- keyUsages: Object.entries(keyUsages)
- .filter(([, value]) => value)
- .map(([key]) => key as CertKeyUsage),
- extendedKeyUsages: Object.entries(extendedKeyUsages)
- .filter(([, value]) => value)
- .map(([key]) => key as CertExtendedKeyUsage)
- });
+ if (certTemplate) {
+ await updateCertTemplate({
+ templateName: certTemplate.name,
+ projectId: currentProject.id,
+ caName: ca.name,
+ name,
+ commonName,
+ subjectAlternativeName,
+ ttl,
+ keyUsages: Object.entries(keyUsages)
+ .filter(([, value]) => value)
+ .map(([key]) => key as CertKeyUsage),
+ extendedKeyUsages: Object.entries(extendedKeyUsages)
+ .filter(([, value]) => value)
+ .map(([key]) => key as CertExtendedKeyUsage)
+ });
- createNotification({
- text: "Successfully created certificate template",
- type: "success"
- });
- }
+ createNotification({
+ text: "Successfully updated certificate template",
+ type: "success"
+ });
+ } else {
+ await createCertTemplate({
+ projectId: currentProject.id,
+ caName: ca.name,
+ name,
+ commonName,
+ subjectAlternativeName,
+ ttl,
+ keyUsages: Object.entries(keyUsages)
+ .filter(([, value]) => value)
+ .map(([key]) => key as CertKeyUsage),
+ extendedKeyUsages: Object.entries(extendedKeyUsages)
+ .filter(([, value]) => value)
+ .map(([key]) => key as CertExtendedKeyUsage)
+ });
- reset();
- handlePopUpToggle(false);
- } catch (err) {
- console.error(err);
createNotification({
- text: "Failed to save changes",
- type: "error"
+ text: "Successfully created certificate template",
+ type: "success"
});
}
+
+ reset();
+ handlePopUpToggle(false);
};
return (
diff --git a/frontend/src/pages/cert-manager/PoliciesPage/components/CertificateProfilesTab/CertificateProfilesTab.tsx b/frontend/src/pages/cert-manager/PoliciesPage/components/CertificateProfilesTab/CertificateProfilesTab.tsx
index d034aeda18..7938d04f52 100644
--- a/frontend/src/pages/cert-manager/PoliciesPage/components/CertificateProfilesTab/CertificateProfilesTab.tsx
+++ b/frontend/src/pages/cert-manager/PoliciesPage/components/CertificateProfilesTab/CertificateProfilesTab.tsx
@@ -51,22 +51,15 @@ export const CertificateProfilesTab = () => {
const handleDeleteConfirm = async () => {
if (!selectedProfile) return;
- try {
- await deleteProfile.mutateAsync({
- profileId: selectedProfile.id
- });
- setIsDeleteModalOpen(false);
- setSelectedProfile(null);
- createNotification({
- text: `Certificate profile "${selectedProfile.slug}" deleted successfully`,
- type: "success"
- });
- } catch (error) {
- console.error(
- `Failed to delete profile "${selectedProfile.slug}" (ID: ${selectedProfile.id}):`,
- error
- );
- }
+ await deleteProfile.mutateAsync({
+ profileId: selectedProfile.id
+ });
+ setIsDeleteModalOpen(false);
+ setSelectedProfile(null);
+ createNotification({
+ text: `Certificate profile "${selectedProfile.slug}" deleted successfully`,
+ type: "success"
+ });
};
return (
diff --git a/frontend/src/pages/cert-manager/PoliciesPage/components/CertificateProfilesTab/CreateProfileModal.tsx b/frontend/src/pages/cert-manager/PoliciesPage/components/CertificateProfilesTab/CreateProfileModal.tsx
index ea82fd843c..56e72ca2b1 100644
--- a/frontend/src/pages/cert-manager/PoliciesPage/components/CertificateProfilesTab/CreateProfileModal.tsx
+++ b/frontend/src/pages/cert-manager/PoliciesPage/components/CertificateProfilesTab/CreateProfileModal.tsx
@@ -236,64 +236,56 @@ export const CreateProfileModal = ({ isOpen, onClose, profile, mode = "create" }
}, [isEdit, profile, reset]);
const onFormSubmit = async (data: FormData) => {
- try {
- if (!currentProject?.id && !isEdit) return;
-
- if (isEdit) {
- const updateData: TUpdateCertificateProfileDTO = {
- profileId: profile.id,
- slug: data.slug,
- description: data.description
- };
-
- if (data.enrollmentType === "est" && data.estConfig) {
- updateData.estConfig = data.estConfig;
- } else if (data.enrollmentType === "api" && data.apiConfig) {
- updateData.apiConfig = data.apiConfig;
- }
+ if (!currentProject?.id && !isEdit) return;
+
+ if (isEdit) {
+ const updateData: TUpdateCertificateProfileDTO = {
+ profileId: profile.id,
+ slug: data.slug,
+ description: data.description
+ };
+
+ if (data.enrollmentType === "est" && data.estConfig) {
+ updateData.estConfig = data.estConfig;
+ } else if (data.enrollmentType === "api" && data.apiConfig) {
+ updateData.apiConfig = data.apiConfig;
+ }
- await updateProfile.mutateAsync(updateData);
- } else {
- if (!currentProject?.id) {
- throw new Error("Project ID is required for creating a profile");
- }
+ await updateProfile.mutateAsync(updateData);
+ } else {
+ if (!currentProject?.id) {
+ throw new Error("Project ID is required for creating a profile");
+ }
- const createData: TCreateCertificateProfileDTO = {
- projectId: currentProject.id,
- slug: data.slug,
- description: data.description,
- enrollmentType: data.enrollmentType,
- caId: data.certificateAuthorityId,
- certificateTemplateId: data.certificateTemplateId
+ const createData: TCreateCertificateProfileDTO = {
+ projectId: currentProject.id,
+ slug: data.slug,
+ description: data.description,
+ enrollmentType: data.enrollmentType,
+ caId: data.certificateAuthorityId,
+ certificateTemplateId: data.certificateTemplateId
+ };
+
+ if (data.enrollmentType === "est" && data.estConfig) {
+ createData.estConfig = {
+ passphrase: data.estConfig.passphrase,
+ caChain: data.estConfig.caChain || undefined,
+ disableBootstrapCaValidation: data.estConfig.disableBootstrapCaValidation
};
-
- if (data.enrollmentType === "est" && data.estConfig) {
- createData.estConfig = {
- passphrase: data.estConfig.passphrase,
- caChain: data.estConfig.caChain || undefined,
- disableBootstrapCaValidation: data.estConfig.disableBootstrapCaValidation
- };
- } else if (data.enrollmentType === "api" && data.apiConfig) {
- createData.apiConfig = data.apiConfig;
- }
-
- await createProfile.mutateAsync(createData);
+ } else if (data.enrollmentType === "api" && data.apiConfig) {
+ createData.apiConfig = data.apiConfig;
}
- createNotification({
- text: `Certificate profile ${isEdit ? "updated" : "created"} successfully`,
- type: "success"
- });
-
- reset();
- onClose();
- } catch (error) {
- console.error(`Error ${isEdit ? "updating" : "creating"} profile:`, error);
- createNotification({
- text: `Failed to ${isEdit ? "update" : "create"} certificate profile`,
- type: "error"
- });
+ await createProfile.mutateAsync(createData);
}
+
+ createNotification({
+ text: `Certificate profile ${isEdit ? "updated" : "created"} successfully`,
+ type: "success"
+ });
+
+ reset();
+ onClose();
};
return (
diff --git a/frontend/src/pages/cert-manager/PoliciesPage/components/CertificateTemplatesV2Tab/CertificateTemplatesV2Tab.tsx b/frontend/src/pages/cert-manager/PoliciesPage/components/CertificateTemplatesV2Tab/CertificateTemplatesV2Tab.tsx
index ae14f2deaf..ec660b3396 100644
--- a/frontend/src/pages/cert-manager/PoliciesPage/components/CertificateTemplatesV2Tab/CertificateTemplatesV2Tab.tsx
+++ b/frontend/src/pages/cert-manager/PoliciesPage/components/CertificateTemplatesV2Tab/CertificateTemplatesV2Tab.tsx
@@ -48,23 +48,15 @@ export const CertificateTemplatesV2Tab = () => {
const handleDeleteConfirm = async () => {
if (!selectedTemplate) return;
- try {
- await deleteTemplateV2.mutateAsync({
- templateId: selectedTemplate.id
- });
- setIsDeleteModalOpen(false);
- setSelectedTemplate(null);
- createNotification({
- 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"
- });
- }
+ await deleteTemplateV2.mutateAsync({
+ templateId: selectedTemplate.id
+ });
+ setIsDeleteModalOpen(false);
+ setSelectedTemplate(null);
+ createNotification({
+ text: `Certificate template "${selectedTemplate.name}" deleted successfully`,
+ type: "success"
+ });
};
return (
diff --git a/frontend/src/pages/cert-manager/PoliciesPage/components/CertificateTemplatesV2Tab/CreateTemplateModal.tsx b/frontend/src/pages/cert-manager/PoliciesPage/components/CertificateTemplatesV2Tab/CreateTemplateModal.tsx
index a96beccadb..1387171fb9 100644
--- a/frontend/src/pages/cert-manager/PoliciesPage/components/CertificateTemplatesV2Tab/CreateTemplateModal.tsx
+++ b/frontend/src/pages/cert-manager/PoliciesPage/components/CertificateTemplatesV2Tab/CreateTemplateModal.tsx
@@ -407,59 +407,51 @@ export const CreateTemplateModal = ({ isOpen, onClose, template, mode = "create"
};
const onFormSubmit = async (data: FormData) => {
- try {
- if (!currentProject?.id && !isEdit) return;
-
- const hasEmptyAttributeValues = data.attributes?.some(
- (attr) => !attr.value || attr.value.length === 0 || attr.value.some((v) => !v.trim())
- );
-
- const hasEmptySanValues = data.subjectAlternativeNames?.some(
- (san) => !san.value || san.value.length === 0 || san.value.some((v) => !v.trim())
- );
-
- if (hasEmptyAttributeValues || hasEmptySanValues) {
- createNotification({
- text: "All values must be non-empty. Use wildcards (*) if needed.",
- type: "error"
- });
- return;
- }
-
- const transformedData = transformToApiFormat(data);
-
- if (isEdit) {
- const updateData = {
- templateId: template.id,
- ...transformedData
- };
- await updateTemplate.mutateAsync(updateData);
- } else {
- if (!currentProject?.id) {
- throw new Error("Project ID is required for creating a template");
- }
+ if (!currentProject?.id && !isEdit) return;
- const createData = {
- projectId: currentProject.id,
- ...transformedData
- };
- await createTemplate.mutateAsync(createData);
- }
+ const hasEmptyAttributeValues = data.attributes?.some(
+ (attr) => !attr.value || attr.value.length === 0 || attr.value.some((v) => !v.trim())
+ );
- createNotification({
- text: `Certificate template ${isEdit ? "updated" : "created"} successfully`,
- type: "success"
- });
+ const hasEmptySanValues = data.subjectAlternativeNames?.some(
+ (san) => !san.value || san.value.length === 0 || san.value.some((v) => !v.trim())
+ );
- reset();
- onClose();
- } catch (error) {
- console.error(`Error ${isEdit ? "updating" : "creating"} template:`, error);
+ if (hasEmptyAttributeValues || hasEmptySanValues) {
createNotification({
- text: `Failed to ${isEdit ? "update" : "create"} certificate template`,
+ text: "All values must be non-empty. Use wildcards (*) if needed.",
type: "error"
});
+ return;
}
+
+ const transformedData = transformToApiFormat(data);
+
+ if (isEdit) {
+ const updateData = {
+ templateId: template.id,
+ ...transformedData
+ };
+ await updateTemplate.mutateAsync(updateData);
+ } else {
+ if (!currentProject?.id) {
+ throw new Error("Project ID is required for creating a template");
+ }
+
+ const createData = {
+ projectId: currentProject.id,
+ ...transformedData
+ };
+ await createTemplate.mutateAsync(createData);
+ }
+
+ createNotification({
+ text: `Certificate template ${isEdit ? "updated" : "created"} successfully`,
+ type: "success"
+ });
+
+ reset();
+ onClose();
};
const addAttribute = () => {
diff --git a/frontend/src/pages/kms/KmipPage/components/DeleteKmipClientModal.tsx b/frontend/src/pages/kms/KmipPage/components/DeleteKmipClientModal.tsx
index fe9c956ab4..2d6accf76d 100644
--- a/frontend/src/pages/kms/KmipPage/components/DeleteKmipClientModal.tsx
+++ b/frontend/src/pages/kms/KmipPage/components/DeleteKmipClientModal.tsx
@@ -17,28 +17,17 @@ export const DeleteKmipClientModal = ({ isOpen, onOpenChange, kmipClient }: Prop
const { id, projectId, name } = kmipClient;
const handleDeleteKmipClient = async () => {
- try {
- await deleteKmipClients.mutateAsync({
- id,
- projectId
- });
-
- createNotification({
- text: "KMIP client successfully deleted",
- type: "success"
- });
-
- 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"
- });
- }
+ await deleteKmipClients.mutateAsync({
+ id,
+ projectId
+ });
+
+ createNotification({
+ text: "KMIP client successfully deleted",
+ type: "success"
+ });
+
+ onOpenChange(false);
};
return (
diff --git a/frontend/src/pages/kms/KmipPage/components/KmipClientModal.tsx b/frontend/src/pages/kms/KmipPage/components/KmipClientModal.tsx
index b3f3fb3803..f10d077a4a 100644
--- a/frontend/src/pages/kms/KmipPage/components/KmipClientModal.tsx
+++ b/frontend/src/pages/kms/KmipPage/components/KmipClientModal.tsx
@@ -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"
- });
- }
+ await mutation;
+ createNotification({
+ text: `Successfully ${isUpdate ? "updated" : "added"} KMIP client`,
+ type: "success"
+ });
+ onComplete();
};
return (
diff --git a/frontend/src/pages/kms/OverviewPage/components/CmekDecryptModal.tsx b/frontend/src/pages/kms/OverviewPage/components/CmekDecryptModal.tsx
index 4c9cf685bf..4fd6b34193 100644
--- a/frontend/src/pages/kms/OverviewPage/components/CmekDecryptModal.tsx
+++ b/frontend/src/pages/kms/OverviewPage/components/CmekDecryptModal.tsx
@@ -52,23 +52,15 @@ const DecryptForm = ({ cmek }: FormProps) => {
});
const handleDecryptData = async (formData: FormData) => {
- try {
- const data = await cmekDecrypt.mutateAsync({ ...formData, keyId: cmek.id });
- createNotification({
- text: "Successfully decrypted data",
- type: "success"
- });
-
- setPlaintext(
- shouldDecode ? Buffer.from(decodeBase64(data.plaintext)).toString("utf8") : data.plaintext
- );
- } catch (err) {
- console.error(err);
- createNotification({
- text: "Failed to decrypt data",
- type: "error"
- });
- }
+ const data = await cmekDecrypt.mutateAsync({ ...formData, keyId: cmek.id });
+ createNotification({
+ text: "Successfully decrypted data",
+ type: "success"
+ });
+
+ setPlaintext(
+ shouldDecode ? Buffer.from(decodeBase64(data.plaintext)).toString("utf8") : data.plaintext
+ );
};
useEffect(() => {
diff --git a/frontend/src/pages/kms/OverviewPage/components/CmekEncryptModal.tsx b/frontend/src/pages/kms/OverviewPage/components/CmekEncryptModal.tsx
index 4fb09cf4eb..a5bf01d5ac 100644
--- a/frontend/src/pages/kms/OverviewPage/components/CmekEncryptModal.tsx
+++ b/frontend/src/pages/kms/OverviewPage/components/CmekEncryptModal.tsx
@@ -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"
- });
- }
+ await cmekEncrypt.mutateAsync({ ...formData, keyId: cmek.id });
+ createNotification({
+ text: "Successfully encrypted data",
+ type: "success"
+ });
};
const ciphertext = cmekEncrypt.data?.ciphertext;
diff --git a/frontend/src/pages/kms/OverviewPage/components/CmekModal.tsx b/frontend/src/pages/kms/OverviewPage/components/CmekModal.tsx
index c3cccd6787..e79d91e151 100644
--- a/frontend/src/pages/kms/OverviewPage/components/CmekModal.tsx
+++ b/frontend/src/pages/kms/OverviewPage/components/CmekModal.tsx
@@ -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"
- });
- }
+ await mutation;
+ createNotification({
+ text: `Successfully ${isUpdate ? "updated" : "added"} key`,
+ type: "success"
+ });
+ onComplete();
};
const selectedKeyUsage = watch("keyUsage");
diff --git a/frontend/src/pages/kms/OverviewPage/components/CmekSignModal.tsx b/frontend/src/pages/kms/OverviewPage/components/CmekSignModal.tsx
index fec66a31f7..e52c03dbe6 100644
--- a/frontend/src/pages/kms/OverviewPage/components/CmekSignModal.tsx
+++ b/frontend/src/pages/kms/OverviewPage/components/CmekSignModal.tsx
@@ -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"
- });
- }
+ await cmekSign.mutateAsync({ ...formData, keyId: cmek.id });
+ createNotification({
+ text: "Successfully signed data",
+ type: "success"
+ });
};
const signature = cmekSign.data?.signature;
diff --git a/frontend/src/pages/kms/OverviewPage/components/CmekTable.tsx b/frontend/src/pages/kms/OverviewPage/components/CmekTable.tsx
index a6675ea888..c9a0054c56 100644
--- a/frontend/src/pages/kms/OverviewPage/components/CmekTable.tsx
+++ b/frontend/src/pages/kms/OverviewPage/components/CmekTable.tsx
@@ -152,28 +152,16 @@ export const CmekTable = () => {
const updateCmek = useUpdateCmek();
const handleDisableCmek = async ({ id: keyId, isDisabled }: TCmek) => {
- try {
- await updateCmek.mutateAsync({
- keyId,
- projectId,
- isDisabled: !isDisabled
- });
+ await updateCmek.mutateAsync({
+ keyId,
+ projectId,
+ isDisabled: !isDisabled
+ });
- createNotification({
- 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"
- });
- }
+ createNotification({
+ text: `Key successfully ${isDisabled ? "enabled" : "disabled"}`,
+ type: "success"
+ });
};
const cannotEditKey = permission.cannot(
diff --git a/frontend/src/pages/kms/OverviewPage/components/CmekVerifyModal.tsx b/frontend/src/pages/kms/OverviewPage/components/CmekVerifyModal.tsx
index 5c9eac072d..d8203e373d 100644
--- a/frontend/src/pages/kms/OverviewPage/components/CmekVerifyModal.tsx
+++ b/frontend/src/pages/kms/OverviewPage/components/CmekVerifyModal.tsx
@@ -69,25 +69,17 @@ const VerifyForm = ({ cmek }: FormProps) => {
});
const handleVerifyData = async (formData: FormData) => {
- try {
- const result = await cmekVerify.mutateAsync({ ...formData, keyId: cmek.id });
+ const result = await cmekVerify.mutateAsync({ ...formData, keyId: cmek.id });
- if (result.signatureValid) {
- createNotification({
- text: "Successfully verified signature",
- type: "success"
- });
- } else {
- createNotification({
- title: "Signature Verification Failed",
- text: "The signature is invalid. The signature was not created using the same signing algorithm and key as the one used to sign the data. The data and signature may have been tampered with.",
- type: "error"
- });
- }
- } catch (err) {
- console.error(err);
+ if (result.signatureValid) {
+ createNotification({
+ text: "Successfully verified signature",
+ type: "success"
+ });
+ } else {
createNotification({
- text: "Failed to sign data",
+ title: "Signature Verification Failed",
+ text: "The signature is invalid. The signature was not created using the same signing algorithm and key as the one used to sign the data. The data and signature may have been tampered with.",
type: "error"
});
}
diff --git a/frontend/src/pages/kms/OverviewPage/components/DeleteCmekModal.tsx b/frontend/src/pages/kms/OverviewPage/components/DeleteCmekModal.tsx
index 4c5528c39e..62389d1ba7 100644
--- a/frontend/src/pages/kms/OverviewPage/components/DeleteCmekModal.tsx
+++ b/frontend/src/pages/kms/OverviewPage/components/DeleteCmekModal.tsx
@@ -16,28 +16,17 @@ export const DeleteCmekModal = ({ isOpen, onOpenChange, cmek }: Props) => {
const { id: keyId, projectId, name } = cmek;
const handleDeleteCmek = async () => {
- try {
- await deleteCmek.mutateAsync({
- keyId,
- projectId
- });
-
- createNotification({
- text: "Key successfully deleted",
- type: "success"
- });
-
- 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"
- });
- }
+ await deleteCmek.mutateAsync({
+ keyId,
+ projectId
+ });
+
+ createNotification({
+ text: "Key successfully deleted",
+ type: "success"
+ });
+
+ onOpenChange(false);
};
return (
diff --git a/frontend/src/pages/organization/AccessManagementPage/components/OrgGroupsTab/components/OrgGroupsSection/OrgGroupModal.tsx b/frontend/src/pages/organization/AccessManagementPage/components/OrgGroupsTab/components/OrgGroupsSection/OrgGroupModal.tsx
index 908be4935b..4b6ea0858e 100644
--- a/frontend/src/pages/organization/AccessManagementPage/components/OrgGroupsTab/components/OrgGroupsSection/OrgGroupModal.tsx
+++ b/frontend/src/pages/organization/AccessManagementPage/components/OrgGroupsTab/components/OrgGroupsSection/OrgGroupModal.tsx
@@ -74,43 +74,36 @@ export const OrgGroupModal = ({ popUp, handlePopUpClose, handlePopUpToggle }: Pr
}, [popUp?.group?.data, roles]);
const onGroupModalSubmit = async ({ name, slug, role }: TGroupFormData) => {
- try {
- if (!currentOrg?.id) return;
+ if (!currentOrg?.id) return;
- const group = popUp?.group?.data as {
- groupId: string;
- name: string;
- slug: string;
- };
-
- if (group) {
- await updateMutateAsync({
- id: group.groupId,
- name,
- slug,
- role: role.slug || undefined
- });
- } else {
- await createMutateAsync({
- name,
- slug,
- organizationId: currentOrg.id,
- role: role.slug || undefined
- });
- }
- handlePopUpToggle("group", false);
- reset();
+ const group = popUp?.group?.data as {
+ groupId: string;
+ name: string;
+ slug: string;
+ };
- createNotification({
- text: `Successfully ${popUp?.group?.data ? "updated" : "created"} group`,
- type: "success"
+ if (group) {
+ await updateMutateAsync({
+ id: group.groupId,
+ name,
+ slug,
+ role: role.slug || undefined
});
- } catch {
- createNotification({
- text: `Failed to ${popUp?.group?.data ? "updated" : "created"} group`,
- type: "error"
+ } else {
+ await createMutateAsync({
+ name,
+ slug,
+ organizationId: currentOrg.id,
+ role: role.slug || undefined
});
}
+ handlePopUpToggle("group", false);
+ reset();
+
+ createNotification({
+ text: `Successfully ${popUp?.group?.data ? "updated" : "created"} group`,
+ type: "success"
+ });
};
return (
diff --git a/frontend/src/pages/organization/AccessManagementPage/components/OrgGroupsTab/components/OrgGroupsSection/OrgGroupsSection.tsx b/frontend/src/pages/organization/AccessManagementPage/components/OrgGroupsTab/components/OrgGroupsSection/OrgGroupsSection.tsx
index 88cbc17f03..1cf5407d1e 100644
--- a/frontend/src/pages/organization/AccessManagementPage/components/OrgGroupsTab/components/OrgGroupsSection/OrgGroupsSection.tsx
+++ b/frontend/src/pages/organization/AccessManagementPage/components/OrgGroupsTab/components/OrgGroupsSection/OrgGroupsSection.tsx
@@ -37,21 +37,13 @@ export const OrgGroupsSection = () => {
};
const onDeleteGroupSubmit = async ({ name, groupId }: { name: string; groupId: string }) => {
- try {
- await deleteMutateAsync({
- id: groupId
- });
- createNotification({
- 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"
- });
- }
+ await deleteMutateAsync({
+ id: groupId
+ });
+ createNotification({
+ text: `Successfully deleted the group named ${name}`,
+ type: "success"
+ });
handlePopUpClose("deleteGroup");
};
diff --git a/frontend/src/pages/organization/AccessManagementPage/components/OrgGroupsTab/components/OrgGroupsSection/OrgGroupsTable.tsx b/frontend/src/pages/organization/AccessManagementPage/components/OrgGroupsTab/components/OrgGroupsSection/OrgGroupsTable.tsx
index 61119fce1c..cc6d7c7aa0 100644
--- a/frontend/src/pages/organization/AccessManagementPage/components/OrgGroupsTab/components/OrgGroupsSection/OrgGroupsTable.tsx
+++ b/frontend/src/pages/organization/AccessManagementPage/components/OrgGroupsTab/components/OrgGroupsSection/OrgGroupsTable.tsx
@@ -79,23 +79,15 @@ export const OrgGroupsTable = ({ handlePopUpOpen }: Props) => {
const { data: roles } = useGetOrgRoles(orgId);
const handleChangeRole = async ({ id, role }: { id: string; role: string }) => {
- try {
- await updateMutateAsync({
- id,
- role
- });
+ await updateMutateAsync({
+ id,
+ role
+ });
- createNotification({
- text: "Successfully updated group role",
- type: "success"
- });
- } catch (err) {
- console.error(err);
- createNotification({
- text: "Failed to update group role",
- type: "error"
- });
- }
+ createNotification({
+ text: "Successfully updated group role",
+ type: "success"
+ });
};
const {
diff --git a/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentitySection.tsx b/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentitySection.tsx
index 355dec803a..b7ebfcdc4f 100644
--- a/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentitySection.tsx
+++ b/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentitySection.tsx
@@ -56,53 +56,31 @@ export const IdentitySection = withPermission(
const isEnterprise = subscription?.slug === "enterprise";
const onDeleteIdentitySubmit = async (identityId: string) => {
- try {
- await deleteMutateAsync({
- identityId,
- organizationId: orgId
- });
+ await deleteMutateAsync({
+ identityId,
+ organizationId: orgId
+ });
- createNotification({
- text: "Successfully deleted identity",
- type: "success"
- });
+ createNotification({
+ text: "Successfully deleted identity",
+ type: "success"
+ });
- 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"
- });
- }
+ handlePopUpClose("deleteIdentity");
};
const onDeleteTemplateSubmit = async (templateId: string) => {
- try {
- await deleteTemplateMutateAsync({
- templateId,
- organizationId: orgId
- });
-
- createNotification({
- text: "Successfully deleted template",
- type: "success"
- });
+ await deleteTemplateMutateAsync({
+ templateId,
+ organizationId: orgId
+ });
- handlePopUpClose("deleteTemplate");
- } catch (err) {
- console.error(err);
- const error = err as any;
- const text = error?.response?.data?.message ?? "Failed to delete template";
+ createNotification({
+ text: "Successfully deleted template",
+ type: "success"
+ });
- createNotification({
- text,
- type: "error"
- });
- }
+ handlePopUpClose("deleteTemplate");
};
return (
diff --git a/frontend/src/pages/organization/AccessManagementPage/components/OrgMembersTab/components/OrgMembersSection/OrgMembersSection.tsx b/frontend/src/pages/organization/AccessManagementPage/components/OrgMembersTab/components/OrgMembersSection/OrgMembersSection.tsx
index adb729d751..dc033f3fad 100644
--- a/frontend/src/pages/organization/AccessManagementPage/components/OrgMembersTab/components/OrgMembersSection/OrgMembersSection.tsx
+++ b/frontend/src/pages/organization/AccessManagementPage/components/OrgMembersTab/components/OrgMembersSection/OrgMembersSection.tsx
@@ -85,46 +85,30 @@ export const OrgMembersSection = () => {
};
const onDeactivateMemberSubmit = async (orgMembershipId: string) => {
- try {
- await updateOrgMembership({
- organizationId: orgId,
- membershipId: orgMembershipId,
- isActive: false
- });
+ await updateOrgMembership({
+ organizationId: orgId,
+ membershipId: orgMembershipId,
+ isActive: false
+ });
- createNotification({
- text: "Successfully deactivated user in organization",
- type: "success"
- });
- } catch (err) {
- console.error(err);
- createNotification({
- text: "Failed to deactivate user in organization",
- type: "error"
- });
- }
+ createNotification({
+ text: "Successfully deactivated user in organization",
+ type: "success"
+ });
handlePopUpClose("deactivateMember");
};
const onRemoveMemberSubmit = async (orgMembershipId: string) => {
- try {
- await deleteMutateAsync({
- orgId,
- membershipId: orgMembershipId
- });
+ await deleteMutateAsync({
+ orgId,
+ membershipId: orgMembershipId
+ });
- createNotification({
- text: "Successfully removed user from org",
- type: "success"
- });
- } catch (err) {
- console.error(err);
- createNotification({
- text: "Failed to remove user from the organization",
- type: "error"
- });
- }
+ createNotification({
+ text: "Successfully removed user from org",
+ type: "success"
+ });
handlePopUpClose("removeMember");
};
@@ -132,27 +116,20 @@ export const OrgMembersSection = () => {
const { data: members = [] } = useGetOrgUsers(orgId);
const handleRemoveMembers = async (selectedMembers: OrgUser[]) => {
- try {
- await deleteBatchMutateAsync({
- orgId,
- membershipIds: selectedMembers
- .filter((member) => member.user.id !== userId)
- .map((member) => member.id)
- });
+ await deleteBatchMutateAsync({
+ orgId,
+ membershipIds: selectedMembers
+ .filter((member) => member.user.id !== userId)
+ .map((member) => member.id)
+ });
- createNotification({
- text: "Successfully removed users from organization",
- type: "success"
- });
+ createNotification({
+ text: "Successfully removed users from organization",
+ type: "success"
+ });
- setSelectedMemberIds([]);
- handlePopUpClose("removeMembers");
- } catch {
- createNotification({
- text: "Failed to remove users from the organization",
- type: "error"
- });
- }
+ setSelectedMemberIds([]);
+ handlePopUpClose("removeMembers");
};
return (
diff --git a/frontend/src/pages/organization/AccessManagementPage/components/OrgMembersTab/components/OrgMembersSection/OrgMembersTable.tsx b/frontend/src/pages/organization/AccessManagementPage/components/OrgMembersTab/components/OrgMembersSection/OrgMembersTable.tsx
index 68a4e795a3..fe71c207dd 100644
--- a/frontend/src/pages/organization/AccessManagementPage/components/OrgMembersTab/components/OrgMembersSection/OrgMembersTable.tsx
+++ b/frontend/src/pages/organization/AccessManagementPage/components/OrgMembersTab/components/OrgMembersSection/OrgMembersTable.tsx
@@ -127,35 +127,26 @@ export const OrgMembersTable = ({
const onRoleChange = async (membershipId: string, role: string) => {
if (!currentOrg?.id) return;
- try {
- // TODO: replace hardcoding default role
- const isCustomRole = !["admin", "member", "no-access"].includes(role);
-
- if (isCustomRole && subscription && !subscription?.rbac) {
- handlePopUpOpen("upgradePlan", {
- description:
- "You can assign custom roles to members if you switch to Infisical's Pro plan."
- });
- return;
- }
+ // TODO: replace hardcoding default role
+ const isCustomRole = !["admin", "member", "no-access"].includes(role);
- await updateOrgMembership({
- organizationId: currentOrg?.id,
- membershipId,
- role
- });
-
- createNotification({
- text: "Successfully updated user role",
- type: "success"
- });
- } catch (error) {
- console.error(error);
- createNotification({
- text: "Failed to update user role",
- type: "error"
+ if (isCustomRole && subscription && !subscription?.rbac) {
+ handlePopUpOpen("upgradePlan", {
+ description: "You can assign custom roles to members if you switch to Infisical's Pro plan."
});
+ return;
}
+
+ await updateOrgMembership({
+ organizationId: currentOrg?.id,
+ membershipId,
+ role
+ });
+
+ createNotification({
+ text: "Successfully updated user role",
+ type: "success"
+ });
};
const onResendInvite = async (membershipId: string) => {
@@ -174,12 +165,6 @@ export const OrgMembersTable = ({
text: "Successfully resent org invitation",
type: "success"
});
- } catch (err) {
- console.error(err);
- createNotification({
- text: "Failed to resend org invitation",
- type: "error"
- });
} finally {
setResendInviteId(null);
}
diff --git a/frontend/src/pages/organization/AccessManagementPage/components/OrgRoleTabSection/OrgRoleTable.tsx b/frontend/src/pages/organization/AccessManagementPage/components/OrgRoleTabSection/OrgRoleTable.tsx
index d6dae6ae22..36249967a3 100644
--- a/frontend/src/pages/organization/AccessManagementPage/components/OrgRoleTabSection/OrgRoleTable.tsx
+++ b/frontend/src/pages/organization/AccessManagementPage/components/OrgRoleTabSection/OrgRoleTable.tsx
@@ -86,17 +86,12 @@ export const OrgRoleTable = () => {
const handleRoleDelete = async () => {
const { id } = popUp?.deleteRole?.data as TOrgRole;
- try {
- await deleteRole({
- orgId,
- id
- });
- createNotification({ type: "success", text: "Successfully removed the role" });
- handlePopUpClose("deleteRole");
- } catch (err) {
- console.log(err);
- createNotification({ type: "error", text: "Failed to delete role" });
- }
+ await deleteRole({
+ orgId,
+ id
+ });
+ createNotification({ type: "success", text: "Successfully removed the role" });
+ handlePopUpClose("deleteRole");
};
const handleSetRoleAsDefault = async (defaultMembershipRoleSlug: string) => {
@@ -110,17 +105,12 @@ export const OrgRoleTable = () => {
return;
}
- try {
- await updateOrg({
- orgId,
- defaultMembershipRoleSlug
- });
- createNotification({ type: "success", text: "Successfully updated default membership role" });
- handlePopUpClose("deleteRole");
- } catch (err) {
- console.log(err);
- createNotification({ type: "error", text: "Failed to update default membership role" });
- }
+ await updateOrg({
+ orgId,
+ defaultMembershipRoleSlug
+ });
+ createNotification({ type: "success", text: "Successfully updated default membership role" });
+ handlePopUpClose("deleteRole");
};
const {
diff --git a/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/AppConnectionForm.tsx b/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/AppConnectionForm.tsx
index c09a589600..9d7e3ab482 100644
--- a/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/AppConnectionForm.tsx
+++ b/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/AppConnectionForm.tsx
@@ -73,24 +73,15 @@ const CreateForm = ({ app, onComplete, projectId }: CreateFormProps) => {
"method" | "name" | "app" | "credentials" | "isPlatformManagedCredentials"
>
) => {
- try {
- const connection = await createAppConnection.mutateAsync({
- ...formData,
- projectId
- });
- createNotification({
- text: `Successfully added ${appName} Connection`,
- type: "success"
- });
- onComplete(connection);
- } catch (err: any) {
- console.error(err);
- createNotification({
- title: `Failed to add ${appName} Connection`,
- text: err.message,
- type: "error"
- });
- }
+ const connection = await createAppConnection.mutateAsync({
+ ...formData,
+ projectId
+ });
+ createNotification({
+ text: `Successfully added ${appName} Connection`,
+ type: "success"
+ });
+ onComplete(connection);
};
switch (app) {
@@ -191,24 +182,15 @@ const UpdateForm = ({ appConnection, onComplete }: UpdateFormProps) => {
"method" | "name" | "app" | "credentials" | "isPlatformManagedCredentials"
>
) => {
- try {
- const connection = await updateAppConnection.mutateAsync({
- connectionId: appConnection.id,
- ...formData
- });
- createNotification({
- text: `Successfully updated ${appName} Connection`,
- type: "success"
- });
- onComplete(connection);
- } catch (err: any) {
- console.error(err);
- createNotification({
- title: `Failed to update ${appName} Connection`,
- text: err.message,
- type: "error"
- });
- }
+ const connection = await updateAppConnection.mutateAsync({
+ connectionId: appConnection.id,
+ ...formData
+ });
+ createNotification({
+ text: `Successfully updated ${appName} Connection`,
+ type: "success"
+ });
+ onComplete(connection);
};
switch (appConnection.app) {
diff --git a/frontend/src/pages/organization/GroupDetailsByIDPage/components/GroupCreateUpdateModal.tsx b/frontend/src/pages/organization/GroupDetailsByIDPage/components/GroupCreateUpdateModal.tsx
index e4364e8742..bc6e3fab58 100644
--- a/frontend/src/pages/organization/GroupDetailsByIDPage/components/GroupCreateUpdateModal.tsx
+++ b/frontend/src/pages/organization/GroupDetailsByIDPage/components/GroupCreateUpdateModal.tsx
@@ -77,43 +77,36 @@ export const GroupCreateUpdateModal = ({ popUp, handlePopUpClose, handlePopUpTog
}, [popUp?.groupCreateUpdate?.data, roles]);
const onGroupModalSubmit = async ({ name, slug, role }: TGroupFormData) => {
- try {
- if (!currentOrg?.id) return;
+ if (!currentOrg?.id) return;
- const group = popUp?.groupCreateUpdate?.data as {
- groupId: string;
- name: string;
- slug: string;
- };
-
- if (group) {
- await updateMutateAsync({
- id: group.groupId,
- name,
- slug,
- role: role.slug || undefined
- });
- } else {
- await createMutateAsync({
- name,
- slug,
- organizationId: currentOrg.id,
- role: role.slug || undefined
- });
- }
- handlePopUpToggle("groupCreateUpdate", false);
- reset();
+ const group = popUp?.groupCreateUpdate?.data as {
+ groupId: string;
+ name: string;
+ slug: string;
+ };
- createNotification({
- text: `Successfully ${popUp?.groupCreateUpdate?.data ? "updated" : "created"} group`,
- type: "success"
+ if (group) {
+ await updateMutateAsync({
+ id: group.groupId,
+ name,
+ slug,
+ role: role.slug || undefined
});
- } catch {
- createNotification({
- text: `Failed to ${popUp?.groupCreateUpdate?.data ? "updated" : "created"} group`,
- type: "error"
+ } else {
+ await createMutateAsync({
+ name,
+ slug,
+ organizationId: currentOrg.id,
+ role: role.slug || undefined
});
}
+ handlePopUpToggle("groupCreateUpdate", false);
+ reset();
+
+ createNotification({
+ text: `Successfully ${popUp?.groupCreateUpdate?.data ? "updated" : "created"} group`,
+ type: "success"
+ });
};
return (
diff --git a/frontend/src/pages/organization/IdentityDetailsByIDPage/IdentityDetailsByIDPage.tsx b/frontend/src/pages/organization/IdentityDetailsByIDPage/IdentityDetailsByIDPage.tsx
index f3bd05eeb1..c2e7bbe57b 100644
--- a/frontend/src/pages/organization/IdentityDetailsByIDPage/IdentityDetailsByIDPage.tsx
+++ b/frontend/src/pages/organization/IdentityDetailsByIDPage/IdentityDetailsByIDPage.tsx
@@ -44,34 +44,23 @@ const Page = () => {
] as const);
const onDeleteIdentitySubmit = async (id: string) => {
- try {
- await deleteIdentity({
- identityId: id,
- organizationId: orgId
- });
+ await deleteIdentity({
+ identityId: id,
+ organizationId: orgId
+ });
- createNotification({
- text: "Successfully deleted identity",
- type: "success"
- });
+ createNotification({
+ text: "Successfully deleted identity",
+ type: "success"
+ });
- handlePopUpClose("deleteIdentity");
- navigate({
- to: "/organization/access-management",
- search: {
- selectedTab: OrgAccessControlTabSections.Identities
- }
- });
- } catch (err) {
- console.error(err);
- const error = err as any;
- const text = error?.response?.data?.message ?? "Failed to delete identity";
-
- createNotification({
- text,
- type: "error"
- });
- }
+ handlePopUpClose("deleteIdentity");
+ navigate({
+ to: "/organization/access-management",
+ search: {
+ selectedTab: OrgAccessControlTabSections.Identities
+ }
+ });
};
return (
diff --git a/frontend/src/pages/organization/RoleByIDPage/components/RolePermissionsSection/RolePermissionsSection.tsx b/frontend/src/pages/organization/RoleByIDPage/components/RolePermissionsSection/RolePermissionsSection.tsx
index 0d6b269a8c..c25d11cb74 100644
--- a/frontend/src/pages/organization/RoleByIDPage/components/RolePermissionsSection/RolePermissionsSection.tsx
+++ b/frontend/src/pages/organization/RoleByIDPage/components/RolePermissionsSection/RolePermissionsSection.tsx
@@ -107,18 +107,13 @@ export const RolePermissionsSection = ({ roleId }: Props) => {
const { mutateAsync: updateRole } = useUpdateOrgRole();
const onSubmit = async (el: TFormSchema) => {
- try {
- await updateRole({
- orgId,
- id: roleId,
- ...el,
- permissions: formRolePermission2API(el.permissions)
- });
- createNotification({ type: "success", text: "Successfully updated role" });
- } catch (err) {
- console.log(err);
- createNotification({ type: "error", text: "Failed to update role" });
- }
+ await updateRole({
+ orgId,
+ id: roleId,
+ ...el,
+ permissions: formRolePermission2API(el.permissions)
+ });
+ createNotification({ type: "success", text: "Successfully updated role" });
};
const isCustomRole = !["admin", "member", "no-access"].includes(role?.slug ?? "");
diff --git a/frontend/src/pages/organization/UserDetailsByIDPage/UserDetailsByIDPage.tsx b/frontend/src/pages/organization/UserDetailsByIDPage/UserDetailsByIDPage.tsx
index 2d433bba8a..8ddc27763e 100644
--- a/frontend/src/pages/organization/UserDetailsByIDPage/UserDetailsByIDPage.tsx
+++ b/frontend/src/pages/organization/UserDetailsByIDPage/UserDetailsByIDPage.tsx
@@ -64,56 +64,38 @@ const Page = withPermission(
] as const);
const onDeactivateMemberSubmit = async (orgMembershipId: string) => {
- try {
- await updateOrgMembership({
- organizationId: orgId,
- membershipId: orgMembershipId,
- isActive: false
- });
+ await updateOrgMembership({
+ organizationId: orgId,
+ membershipId: orgMembershipId,
+ isActive: false
+ });
- createNotification({
- text: "Successfully deactivated user in organization",
- type: "success"
- });
- } catch (err) {
- console.error(err);
- createNotification({
- text: "Failed to deactivate user in organization",
- type: "error"
- });
- }
+ createNotification({
+ text: "Successfully deactivated user in organization",
+ type: "success"
+ });
handlePopUpClose("deactivateMember");
};
const onRemoveMemberSubmit = async (orgMembershipId: string) => {
- try {
- await deleteOrgMembership({
- orgId,
- membershipId: orgMembershipId
- });
+ await deleteOrgMembership({
+ orgId,
+ membershipId: orgMembershipId
+ });
- createNotification({
- text: "Successfully removed user from org",
- type: "success"
- });
-
- handlePopUpClose("removeMember");
- navigate({
- to: "/organization/access-management" as const,
- search: {
- selectedTab: OrgAccessControlTabSections.Member
- }
- });
- } catch (err) {
- console.error(err);
- createNotification({
- text: "Failed to remove user from the organization",
- type: "error"
- });
- }
+ createNotification({
+ text: "Successfully removed user from org",
+ type: "success"
+ });
handlePopUpClose("removeMember");
+ navigate({
+ to: "/organization/access-management" as const,
+ search: {
+ selectedTab: OrgAccessControlTabSections.Member
+ }
+ });
};
return (
diff --git a/frontend/src/pages/organization/UserDetailsByIDPage/components/UserDetailsSection.tsx b/frontend/src/pages/organization/UserDetailsByIDPage/components/UserDetailsSection.tsx
index bef98e875e..d26163de03 100644
--- a/frontend/src/pages/organization/UserDetailsByIDPage/components/UserDetailsSection.tsx
+++ b/frontend/src/pages/organization/UserDetailsByIDPage/components/UserDetailsSection.tsx
@@ -46,26 +46,18 @@ export const UserDetailsSection = ({ membershipId, handlePopUpOpen }: Props) =>
const { mutateAsync: resendOrgMemberInvitation, isPending } = useResendOrgMemberInvitation();
const onResendInvite = async () => {
- try {
- const signupToken = await resendOrgMemberInvitation({
- membershipId
- });
+ const signupToken = await resendOrgMemberInvitation({
+ membershipId
+ });
- if (signupToken) {
- return;
- }
-
- createNotification({
- text: "Successfully resent org invitation",
- type: "success"
- });
- } catch (err) {
- console.error(err);
- createNotification({
- text: "Failed to resend org invitation",
- type: "error"
- });
+ if (signupToken) {
+ return;
}
+
+ createNotification({
+ text: "Successfully resent org invitation",
+ type: "success"
+ });
};
const getStatus = (m: OrgUser) => {
diff --git a/frontend/src/pages/pam/PamAccountsPage/components/PamAccountForm/PamAccountForm.tsx b/frontend/src/pages/pam/PamAccountsPage/components/PamAccountForm/PamAccountForm.tsx
index b9599be2d6..346195e11b 100644
--- a/frontend/src/pages/pam/PamAccountsPage/components/PamAccountForm/PamAccountForm.tsx
+++ b/frontend/src/pages/pam/PamAccountsPage/components/PamAccountForm/PamAccountForm.tsx
@@ -38,27 +38,18 @@ const CreateForm = ({
const onSubmit = async (
formData: DiscriminativePick<TPamAccount, "name" | "description" | "credentials">
) => {
- try {
- const account = await createPamAccount.mutateAsync({
- ...formData,
- folderId,
- resourceId,
- resourceType,
- projectId
- });
- createNotification({
- text: "Successfully created account",
- type: "success"
- });
- onComplete(account);
- } catch (err: any) {
- console.error(err);
- createNotification({
- title: "Failed to create account",
- text: err.message,
- type: "error"
- });
- }
+ const account = await createPamAccount.mutateAsync({
+ ...formData,
+ folderId,
+ resourceId,
+ resourceType,
+ projectId
+ });
+ createNotification({
+ text: "Successfully created account",
+ type: "success"
+ });
+ onComplete(account);
};
switch (resourceType) {
@@ -85,25 +76,16 @@ const UpdateForm = ({ account, onComplete }: UpdateFormProps) => {
const onSubmit = async (
formData: DiscriminativePick<TPamAccount, "name" | "description" | "credentials">
) => {
- try {
- const updatedAccount = await updatePamAccount.mutateAsync({
- accountId: account.id,
- resourceType: account.resource.resourceType,
- ...formData
- });
- createNotification({
- text: "Successfully updated account",
- type: "success"
- });
- onComplete(updatedAccount);
- } catch (err: any) {
- console.error(err);
- createNotification({
- title: "Failed to update account",
- text: err.message,
- type: "error"
- });
- }
+ const updatedAccount = await updatePamAccount.mutateAsync({
+ accountId: account.id,
+ resourceType: account.resource.resourceType,
+ ...formData
+ });
+ createNotification({
+ text: "Successfully updated account",
+ type: "success"
+ });
+ onComplete(updatedAccount);
};
switch (account.resource.resourceType) {
diff --git a/frontend/src/pages/pam/PamAccountsPage/components/PamAddFolderModal.tsx b/frontend/src/pages/pam/PamAccountsPage/components/PamAddFolderModal.tsx
index 7b057a6487..266a724cd0 100644
--- a/frontend/src/pages/pam/PamAccountsPage/components/PamAddFolderModal.tsx
+++ b/frontend/src/pages/pam/PamAccountsPage/components/PamAddFolderModal.tsx
@@ -17,25 +17,16 @@ export const PamAddFolderModal = ({ isOpen, onOpenChange, projectId, currentFold
console.log({ currentFolderId });
const onSubmit = async (formData: Pick<TPamFolder, "name" | "description">) => {
- try {
- await createPamFolder.mutateAsync({
- ...formData,
- parentId: currentFolderId,
- projectId
- });
- createNotification({
- text: "Successfully created folder",
- type: "success"
- });
- onOpenChange(false);
- } catch (err: any) {
- console.error(err);
- createNotification({
- title: "Failed to create folder",
- text: err.message,
- type: "error"
- });
- }
+ await createPamFolder.mutateAsync({
+ ...formData,
+ parentId: currentFolderId,
+ projectId
+ });
+ createNotification({
+ text: "Successfully created folder",
+ type: "success"
+ });
+ onOpenChange(false);
};
return (
diff --git a/frontend/src/pages/pam/PamAccountsPage/components/PamDeleteAccountModal.tsx b/frontend/src/pages/pam/PamAccountsPage/components/PamDeleteAccountModal.tsx
index 45ac030825..c094d3c53f 100644
--- a/frontend/src/pages/pam/PamAccountsPage/components/PamDeleteAccountModal.tsx
+++ b/frontend/src/pages/pam/PamAccountsPage/components/PamDeleteAccountModal.tsx
@@ -20,25 +20,17 @@ export const PamDeleteAccountModal = ({ isOpen, onOpenChange, account }: Props)
} = account;
const handleDelete = async () => {
- try {
- await deletePamAccount.mutateAsync({
- accountId,
- resourceType
- });
-
- createNotification({
- text: "Successfully deleted account",
- type: "success"
- });
-
- onOpenChange(false);
- } catch (err) {
- console.error(err);
- createNotification({
- text: "Failed to delete account",
- type: "error"
- });
- }
+ await deletePamAccount.mutateAsync({
+ accountId,
+ resourceType
+ });
+
+ createNotification({
+ text: "Successfully deleted account",
+ type: "success"
+ });
+
+ onOpenChange(false);
};
return (
diff --git a/frontend/src/pages/pam/PamAccountsPage/components/PamDeleteFolderModal.tsx b/frontend/src/pages/pam/PamAccountsPage/components/PamDeleteFolderModal.tsx
index f0e2476c28..d901d0ba08 100644
--- a/frontend/src/pages/pam/PamAccountsPage/components/PamDeleteFolderModal.tsx
+++ b/frontend/src/pages/pam/PamAccountsPage/components/PamDeleteFolderModal.tsx
@@ -16,24 +16,16 @@ export const PamDeleteFolderModal = ({ isOpen, onOpenChange, folder }: Props) =>
const { id: folderId, name } = folder;
const handleDelete = async () => {
- try {
- await deletePamFolder.mutateAsync({
- folderId
- });
-
- createNotification({
- text: "Successfully deleted folder",
- type: "success"
- });
-
- onOpenChange(false);
- } catch (err) {
- console.error(err);
- createNotification({
- text: "Failed to delete folder",
- type: "error"
- });
- }
+ await deletePamFolder.mutateAsync({
+ folderId
+ });
+
+ createNotification({
+ text: "Successfully deleted folder",
+ type: "success"
+ });
+
+ onOpenChange(false);
};
return (
diff --git a/frontend/src/pages/pam/PamAccountsPage/components/PamUpdateFolderModal.tsx b/frontend/src/pages/pam/PamAccountsPage/components/PamUpdateFolderModal.tsx
index b4bcc46a4d..4162ce25fc 100644
--- a/frontend/src/pages/pam/PamAccountsPage/components/PamUpdateFolderModal.tsx
+++ b/frontend/src/pages/pam/PamAccountsPage/components/PamUpdateFolderModal.tsx
@@ -16,24 +16,15 @@ export const PamUpdateFolderModal = ({ isOpen, onOpenChange, folder }: Props) =>
if (!folder) return null;
const onSubmit = async (formData: Pick<TPamFolder, "name" | "description">) => {
- try {
- await updatePamFolder.mutateAsync({
- ...formData,
- folderId: folder.id
- });
- createNotification({
- text: "Successfully updated folder",
- type: "success"
- });
- onOpenChange(false);
- } catch (err: any) {
- console.error(err);
- createNotification({
- title: "Failed to updated folder",
- text: err.message,
- type: "error"
- });
- }
+ await updatePamFolder.mutateAsync({
+ ...formData,
+ folderId: folder.id
+ });
+ createNotification({
+ text: "Successfully updated folder",
+ type: "success"
+ });
+ onOpenChange(false);
};
return (
diff --git a/frontend/src/pages/pam/PamResourcesPage/components/PamDeleteResourceModal.tsx b/frontend/src/pages/pam/PamResourcesPage/components/PamDeleteResourceModal.tsx
index efda534667..7f0d2bd192 100644
--- a/frontend/src/pages/pam/PamResourcesPage/components/PamDeleteResourceModal.tsx
+++ b/frontend/src/pages/pam/PamResourcesPage/components/PamDeleteResourceModal.tsx
@@ -16,25 +16,17 @@ export const PamDeleteResourceModal = ({ isOpen, onOpenChange, resource }: Props
const { id: resourceId, name, resourceType } = resource;
const handleDelete = async () => {
- try {
- await deletePamResource.mutateAsync({
- resourceId,
- resourceType
- });
-
- createNotification({
- text: `Successfully removed ${PAM_RESOURCE_TYPE_MAP[resourceType].name} resource`,
- type: "success"
- });
-
- onOpenChange(false);
- } catch (err) {
- console.error(err);
- createNotification({
- text: `Failed to remove ${PAM_RESOURCE_TYPE_MAP[resourceType].name} resource`,
- type: "error"
- });
- }
+ await deletePamResource.mutateAsync({
+ resourceId,
+ resourceType
+ });
+
+ createNotification({
+ text: `Successfully removed ${PAM_RESOURCE_TYPE_MAP[resourceType].name} resource`,
+ type: "success"
+ });
+
+ onOpenChange(false);
};
return (
diff --git a/frontend/src/pages/pam/PamResourcesPage/components/PamResourceForm/PamResourceForm.tsx b/frontend/src/pages/pam/PamResourcesPage/components/PamResourceForm/PamResourceForm.tsx
index 2bc54e7cd0..3dd3aeec8d 100644
--- a/frontend/src/pages/pam/PamResourcesPage/components/PamResourceForm/PamResourceForm.tsx
+++ b/frontend/src/pages/pam/PamResourcesPage/components/PamResourceForm/PamResourceForm.tsx
@@ -35,24 +35,15 @@ const CreateForm = ({ resourceType, onComplete, projectId }: CreateFormProps) =>
"name" | "resourceType" | "connectionDetails" | "gatewayId"
>
) => {
- try {
- const resource = await createPamResource.mutateAsync({
- ...formData,
- projectId
- });
- createNotification({
- text: `Successfully created ${resourceName} resource`,
- type: "success"
- });
- onComplete(resource);
- } catch (err: any) {
- console.error(err);
- createNotification({
- title: `Failed to create ${resourceName} resource`,
- text: err.message,
- type: "error"
- });
- }
+ const resource = await createPamResource.mutateAsync({
+ ...formData,
+ projectId
+ });
+ createNotification({
+ text: `Successfully created ${resourceName} resource`,
+ type: "success"
+ });
+ onComplete(resource);
};
switch (resourceType) {
@@ -72,24 +63,15 @@ const UpdateForm = ({ resource, onComplete }: UpdateFormProps) => {
const onSubmit = async (
formData: DiscriminativePick<TPamResource, "name" | "resourceType" | "connectionDetails">
) => {
- try {
- const updatedResource = await updatePamResource.mutateAsync({
- resourceId: resource.id,
- ...formData
- });
- createNotification({
- text: `Successfully updated ${resourceName} resource`,
- type: "success"
- });
- onComplete(updatedResource);
- } catch (err: any) {
- console.error(err);
- createNotification({
- title: `Failed to update ${resourceName} resource`,
- text: err.message,
- type: "error"
- });
- }
+ const updatedResource = await updatePamResource.mutateAsync({
+ resourceId: resource.id,
+ ...formData
+ });
+ createNotification({
+ text: `Successfully updated ${resourceName} resource`,
+ type: "success"
+ });
+ onComplete(updatedResource);
};
switch (resource.resourceType) {
diff --git a/frontend/src/pages/project/AccessControlPage/components/MembersTab/components/MemberRoleForm/MemberRbacSection.tsx b/frontend/src/pages/project/AccessControlPage/components/MembersTab/components/MemberRoleForm/MemberRbacSection.tsx
index 291a5b58b6..5be2390429 100644
--- a/frontend/src/pages/project/AccessControlPage/components/MembersTab/components/MemberRoleForm/MemberRbacSection.tsx
+++ b/frontend/src/pages/project/AccessControlPage/components/MembersTab/components/MemberRoleForm/MemberRbacSection.tsx
@@ -127,17 +127,13 @@ export const MemberRbacSection = ({ projectMember, onOpenUpgradeModal }: Props)
return;
}
- try {
- await updateMembershipRole.mutateAsync({
- projectId,
- membershipId: projectMember.id,
- roles: sanitizedRoles
- });
- createNotification({ text: "Successfully updated roles", type: "success" });
- roleForm.reset(undefined, { keepValues: true });
- } catch {
- createNotification({ text: "Failed to update role", type: "error" });
- }
+ await updateMembershipRole.mutateAsync({
+ projectId,
+ membershipId: projectMember.id,
+ roles: sanitizedRoles
+ });
+ createNotification({ text: "Successfully updated roles", type: "success" });
+ roleForm.reset(undefined, { keepValues: true });
};
if (isRolesLoading)
diff --git a/frontend/src/pages/project/IdentityDetailsByIDPage/components/IdentityRoleDetailsSection/IdentityRoleModify.tsx b/frontend/src/pages/project/IdentityDetailsByIDPage/components/IdentityRoleDetailsSection/IdentityRoleModify.tsx
index a74428e981..8bc451151e 100644
--- a/frontend/src/pages/project/IdentityDetailsByIDPage/components/IdentityRoleDetailsSection/IdentityRoleModify.tsx
+++ b/frontend/src/pages/project/IdentityDetailsByIDPage/components/IdentityRoleDetailsSection/IdentityRoleModify.tsx
@@ -114,16 +114,12 @@ export const IdentityRoleModify = ({ identityProjectMembership }: Props) => {
};
});
- try {
- await updateIdentityWorkspaceRole.mutateAsync({
- projectId,
- identityId: identityProjectMembership.identity.id,
- roles: sanitizedRoles
- });
- createNotification({ text: "Successfully updated roles", type: "success" });
- } catch {
- createNotification({ text: "Failed to update roles", type: "error" });
- }
+ await updateIdentityWorkspaceRole.mutateAsync({
+ projectId,
+ identityId: identityProjectMembership.identity.id,
+ roles: sanitizedRoles
+ });
+ createNotification({ text: "Successfully updated roles", type: "success" });
};
if (isRolesLoading)
diff --git a/frontend/src/pages/project/MemberDetailsByIDPage/components/MemberRoleDetailsSection/MemberRoleDetailsSection.tsx b/frontend/src/pages/project/MemberDetailsByIDPage/components/MemberRoleDetailsSection/MemberRoleDetailsSection.tsx
index 703511c84a..2654e237e2 100644
--- a/frontend/src/pages/project/MemberDetailsByIDPage/components/MemberRoleDetailsSection/MemberRoleDetailsSection.tsx
+++ b/frontend/src/pages/project/MemberDetailsByIDPage/components/MemberRoleDetailsSection/MemberRoleDetailsSection.tsx
@@ -55,42 +55,37 @@ export const MemberRoleDetailsSection = ({
const handleRoleDelete = async () => {
const { id } = popUp?.deleteRole?.data as TProjectRole;
- try {
- const updatedRoles = membershipDetails?.roles?.filter((el) => el.id !== id);
- await updateUserWorkspaceRole({
- projectId,
- roles: updatedRoles.map(
- ({
- role,
- customRoleSlug,
- isTemporary,
- temporaryMode,
- temporaryRange,
- temporaryAccessStartTime,
- temporaryAccessEndTime
- }) => ({
- role: role === "custom" ? customRoleSlug : role,
- ...(isTemporary
- ? {
- isTemporary,
- temporaryMode,
- temporaryRange,
- temporaryAccessStartTime,
- temporaryAccessEndTime
- }
- : {
- isTemporary
- })
- })
- ),
- membershipId: membershipDetails.id
- });
- createNotification({ type: "success", text: "Successfully removed role" });
- handlePopUpClose("deleteRole");
- } catch (err) {
- console.log(err);
- createNotification({ type: "error", text: "Failed to delete role" });
- }
+ const updatedRoles = membershipDetails?.roles?.filter((el) => el.id !== id);
+ await updateUserWorkspaceRole({
+ projectId,
+ roles: updatedRoles.map(
+ ({
+ role,
+ customRoleSlug,
+ isTemporary,
+ temporaryMode,
+ temporaryRange,
+ temporaryAccessStartTime,
+ temporaryAccessEndTime
+ }) => ({
+ role: role === "custom" ? customRoleSlug : role,
+ ...(isTemporary
+ ? {
+ isTemporary,
+ temporaryMode,
+ temporaryRange,
+ temporaryAccessStartTime,
+ temporaryAccessEndTime
+ }
+ : {
+ isTemporary
+ })
+ })
+ ),
+ membershipId: membershipDetails.id
+ });
+ createNotification({ type: "success", text: "Successfully removed role" });
+ handlePopUpClose("deleteRole");
};
return (
diff --git a/frontend/src/pages/project/MemberDetailsByIDPage/components/MemberRoleDetailsSection/MemberRoleModify.tsx b/frontend/src/pages/project/MemberDetailsByIDPage/components/MemberRoleDetailsSection/MemberRoleModify.tsx
index 287ea3ad77..9474241911 100644
--- a/frontend/src/pages/project/MemberDetailsByIDPage/components/MemberRoleDetailsSection/MemberRoleModify.tsx
+++ b/frontend/src/pages/project/MemberDetailsByIDPage/components/MemberRoleDetailsSection/MemberRoleModify.tsx
@@ -126,16 +126,12 @@ export const MemberRoleModify = ({ projectMember, onOpenUpgradeModal }: Props) =
return;
}
- try {
- await updateMembershipRole.mutateAsync({
- projectId,
- membershipId: projectMember.id,
- roles: sanitizedRoles
- });
- createNotification({ text: "Successfully updated roles", type: "success" });
- } catch {
- createNotification({ text: "Failed to update roles", type: "error" });
- }
+ await updateMembershipRole.mutateAsync({
+ projectId,
+ membershipId: projectMember.id,
+ roles: sanitizedRoles
+ });
+ createNotification({ text: "Successfully updated roles", type: "success" });
};
if (isRolesLoading)
diff --git a/frontend/src/pages/secret-manager/SecretRotationPage/SecretRotationPage.tsx b/frontend/src/pages/secret-manager/SecretRotationPage/SecretRotationPage.tsx
index 8efa28a63a..b69d8fadbd 100644
--- a/frontend/src/pages/secret-manager/SecretRotationPage/SecretRotationPage.tsx
+++ b/frontend/src/pages/secret-manager/SecretRotationPage/SecretRotationPage.tsx
@@ -95,42 +95,26 @@ const Page = () => {
const handleDeleteRotation = async () => {
const { id } = popUp.deleteRotation.data as { id: string };
- try {
- await deleteSecretRotation({
- id,
- workspaceId
- });
- handlePopUpClose("deleteRotation");
- createNotification({
- type: "success",
- text: "Successfully removed rotation"
- });
- } catch (error) {
- console.log(error);
- createNotification({
- type: "error",
- text: "Failed to remove rotation"
- });
- }
+ await deleteSecretRotation({
+ id,
+ workspaceId
+ });
+ handlePopUpClose("deleteRotation");
+ createNotification({
+ type: "success",
+ text: "Successfully removed rotation"
+ });
};
const handleRestartRotation = async (id: string) => {
- try {
- await restartSecretRotation({
- id,
- workspaceId
- });
- createNotification({
- type: "success",
- text: "Secret rotation initiated"
- });
- } catch (error) {
- console.log(error);
- createNotification({
- type: "error",
- text: "Failed to restart rotation"
- });
- }
+ await restartSecretRotation({
+ id,
+ workspaceId
+ });
+ createNotification({
+ type: "success",
+ text: "Secret rotation initiated"
+ });
};
const handleCreateRotation = (provider: TSecretRotationProviderTemplate) => {
diff --git a/frontend/src/pages/secret-manager/SecretSyncDetailsByIDPage/components/SecretSyncActionTriggers.tsx b/frontend/src/pages/secret-manager/SecretSyncDetailsByIDPage/components/SecretSyncActionTriggers.tsx
index 78cdf899e7..ad82460eb4 100644
--- a/frontend/src/pages/secret-manager/SecretSyncDetailsByIDPage/components/SecretSyncActionTriggers.tsx
+++ b/frontend/src/pages/secret-manager/SecretSyncDetailsByIDPage/components/SecretSyncActionTriggers.tsx
@@ -89,44 +89,30 @@ export const SecretSyncActionTriggers = ({ secretSync }: Props) => {
const handleToggleEnableSync = async () => {
const isAutoSyncEnabled = !secretSync.isAutoSyncEnabled;
- try {
- await updateSync.mutateAsync({
- syncId: secretSync.id,
- destination: secretSync.destination,
- isAutoSyncEnabled,
- projectId: secretSync.projectId
- });
+ await updateSync.mutateAsync({
+ syncId: secretSync.id,
+ destination: secretSync.destination,
+ isAutoSyncEnabled,
+ projectId: secretSync.projectId
+ });
- createNotification({
- 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"
- });
- }
+ createNotification({
+ text: `Successfully ${isAutoSyncEnabled ? "enabled" : "disabled"} auto-sync for ${destinationName} Sync`,
+ type: "success"
+ });
};
const handleTriggerSync = async () => {
- try {
- await triggerSyncSecrets.mutateAsync({
- syncId: secretSync.id,
- destination: secretSync.destination,
- projectId: secretSync.projectId
- });
+ await triggerSyncSecrets.mutateAsync({
+ syncId: secretSync.id,
+ destination: secretSync.destination,
+ projectId: secretSync.projectId
+ });
- createNotification({
- text: `Successfully triggered ${destinationName} Sync`,
- type: "success"
- });
- } catch {
- createNotification({
- text: `Failed to trigger ${destinationName} Sync`,
- type: "error"
- });
- }
+ createNotification({
+ text: `Successfully triggered ${destinationName} Sync`,
+ type: "success"
+ });
};
const permissionSubject =
diff --git a/frontend/src/pages/secret-manager/SettingsPage/components/WorkflowIntegrationSection/components/SlackIntegrationForm.tsx b/frontend/src/pages/secret-manager/SettingsPage/components/WorkflowIntegrationSection/components/SlackIntegrationForm.tsx
index bcc2d81b58..4af602e12e 100644
--- a/frontend/src/pages/secret-manager/SettingsPage/components/WorkflowIntegrationSection/components/SlackIntegrationForm.tsx
+++ b/frontend/src/pages/secret-manager/SettingsPage/components/WorkflowIntegrationSection/components/SlackIntegrationForm.tsx
@@ -76,32 +76,25 @@ export const SlackIntegrationForm = ({ onClose }: Props) => {
});
const handleIntegrationSave = async (data: TSlackConfigForm) => {
- try {
- if (!currentProject) {
- return;
- }
+ if (!currentProject) {
+ return;
+ }
- await updateProjectSlackConfig({
- ...data,
- projectId: currentProject.id,
- integration: WorkflowIntegrationPlatform.SLACK,
- integrationId: data.slackIntegrationId,
- accessRequestChannels: data.accessRequestChannels.filter(Boolean).join(", "),
- secretRequestChannels: data.secretRequestChannels.filter(Boolean).join(", ")
- });
+ await updateProjectSlackConfig({
+ ...data,
+ projectId: currentProject.id,
+ integration: WorkflowIntegrationPlatform.SLACK,
+ integrationId: data.slackIntegrationId,
+ accessRequestChannels: data.accessRequestChannels.filter(Boolean).join(", "),
+ secretRequestChannels: data.secretRequestChannels.filter(Boolean).join(", ")
+ });
- createNotification({
- type: "success",
- text: "Successfully created slack integration"
- });
+ createNotification({
+ type: "success",
+ text: "Successfully created slack integration"
+ });
- onClose();
- } catch {
- createNotification({
- type: "error",
- text: "Failed to create slack integration"
- });
- }
+ onClose();
};
const secretRequestNotifState = watch("isSecretRequestNotificationEnabled");
diff --git a/frontend/src/pages/secret-scanning/SecretScanningDataSourceByIdPage/components/SecretScanningResourceRow.tsx b/frontend/src/pages/secret-scanning/SecretScanningDataSourceByIdPage/components/SecretScanningResourceRow.tsx
index 740cf6d717..b2021bf5c6 100644
--- a/frontend/src/pages/secret-scanning/SecretScanningDataSourceByIdPage/components/SecretScanningResourceRow.tsx
+++ b/frontend/src/pages/secret-scanning/SecretScanningDataSourceByIdPage/components/SecretScanningResourceRow.tsx
@@ -81,24 +81,17 @@ export const SecretScanningResourceRow = ({ resource, dataSource }: Props) => {
const navigate = useNavigate();
const handleTriggerScan = async () => {
- try {
- await triggerDataSourceScan.mutateAsync({
- dataSourceId: dataSource.id,
- type: dataSource.type,
- projectId: dataSource.projectId,
- resourceId: id
- });
+ await triggerDataSourceScan.mutateAsync({
+ dataSourceId: dataSource.id,
+ type: dataSource.type,
+ projectId: dataSource.projectId,
+ resourceId: id
+ });
- createNotification({
- text: `Successfully triggered scan for ${name}`,
- type: "success"
- });
- } catch {
- createNotification({
- text: `Failed to trigger scan for ${name}`,
- type: "error"
- });
- }
+ createNotification({
+ text: `Successfully triggered scan for ${name}`,
+ type: "success"
+ });
};
const [isIdCopied, setIsIdCopied] = useToggle(false);
diff --git a/frontend/src/pages/secret-scanning/SecretScanningFindingsPage/components/SecretScanningUpdateFindingModal.tsx b/frontend/src/pages/secret-scanning/SecretScanningFindingsPage/components/SecretScanningUpdateFindingModal.tsx
index 484cbcf362..c4838673b1 100644
--- a/frontend/src/pages/secret-scanning/SecretScanningFindingsPage/components/SecretScanningUpdateFindingModal.tsx
+++ b/frontend/src/pages/secret-scanning/SecretScanningFindingsPage/components/SecretScanningUpdateFindingModal.tsx
@@ -55,39 +55,32 @@ const Content = ({ findings, onComplete }: ContentProps) => {
const onSubmit = async (data: FormType) => {
if (!data.status) return;
- try {
- if (findings.length > 1) {
- await updateMultipleFindings.mutateAsync(
- findings.map((f) => ({
- ...data,
- status: data.status!,
- findingId: f.id,
- projectId: f.projectId
- }))
- );
- } else {
- await updateMultipleFindings.mutateAsync([
- {
- ...data,
- status: data.status,
- findingId: findings[0].id,
- projectId: findings[0].projectId
- }
- ]);
- }
+ if (findings.length > 1) {
+ await updateMultipleFindings.mutateAsync(
+ findings.map((f) => ({
+ ...data,
+ status: data.status!,
+ findingId: f.id,
+ projectId: f.projectId
+ }))
+ );
+ } else {
+ await updateMultipleFindings.mutateAsync([
+ {
+ ...data,
+ status: data.status,
+ findingId: findings[0].id,
+ projectId: findings[0].projectId
+ }
+ ]);
+ }
- createNotification({
- type: "success",
- text: `Finding status${single ? "" : "es"} successfully updated`
- });
+ createNotification({
+ type: "success",
+ text: `Finding status${single ? "" : "es"} successfully updated`
+ });
- onComplete();
- } catch {
- createNotification({
- type: "error",
- text: `Failed to update finding status${single ? "" : "es"}`
- });
- }
+ onComplete();
};
return (
diff --git a/frontend/src/pages/secret-scanning/SettingsPage/components/ProjectScanningConfigTab/SecretScanningConfigForm.tsx b/frontend/src/pages/secret-scanning/SettingsPage/components/ProjectScanningConfigTab/SecretScanningConfigForm.tsx
index c9df333c47..7ff36964d8 100644
--- a/frontend/src/pages/secret-scanning/SettingsPage/components/ProjectScanningConfigTab/SecretScanningConfigForm.tsx
+++ b/frontend/src/pages/secret-scanning/SettingsPage/components/ProjectScanningConfigTab/SecretScanningConfigForm.tsx
@@ -38,22 +38,15 @@ export const SecretScanningConfigForm = ({ config }: Props) => {
});
const onSubmit = async ({ content }: FormType) => {
- try {
- await updateConfig.mutateAsync({
- projectId: config.projectId,
- content: content || null
- });
+ await updateConfig.mutateAsync({
+ projectId: config.projectId,
+ content: content || null
+ });
- createNotification({
- type: "success",
- text: "Configuration successfully updated"
- });
- } catch {
- createNotification({
- type: "error",
- text: "Failed to update Configuration"
- });
- }
+ createNotification({
+ type: "success",
+ text: "Configuration successfully updated"
+ });
};
return (
diff --git a/frontend/src/pages/ssh/SshHostGroupDetailsByIDPage/components/SshHostGroupHostsSection.tsx b/frontend/src/pages/ssh/SshHostGroupDetailsByIDPage/components/SshHostGroupHostsSection.tsx
index df6f2b723e..9b482538cb 100644
--- a/frontend/src/pages/ssh/SshHostGroupDetailsByIDPage/components/SshHostGroupHostsSection.tsx
+++ b/frontend/src/pages/ssh/SshHostGroupDetailsByIDPage/components/SshHostGroupHostsSection.tsx
@@ -41,25 +41,17 @@ export const SshHostGroupHostsSection = ({ sshHostGroupId }: Props) => {
};
const onRemoveSshHostSubmit = async (sshHostId: string) => {
- try {
- await removeHostFromGroup({
- sshHostId,
- sshHostGroupId
- });
+ await removeHostFromGroup({
+ sshHostId,
+ sshHostGroupId
+ });
- await createNotification({
- text: "Successfully removed host from SSH group",
- type: "success"
- });
+ createNotification({
+ text: "Successfully removed host from SSH group",
+ type: "success"
+ });
- handlePopUpClose("removeHostFromSshHostGroup");
- } catch (err) {
- console.error(err);
- createNotification({
- text: "Failed to remove host from SSH group",
- type: "error"
- });
- }
+ handlePopUpClose("removeHostFromSshHostGroup");
};
return (
diff --git a/frontend/src/pages/ssh/SshHostsPage/components/SshHostGroupsSection.tsx b/frontend/src/pages/ssh/SshHostsPage/components/SshHostGroupsSection.tsx
index 189a49686a..e690480e12 100644
--- a/frontend/src/pages/ssh/SshHostsPage/components/SshHostGroupsSection.tsx
+++ b/frontend/src/pages/ssh/SshHostsPage/components/SshHostGroupsSection.tsx
@@ -35,22 +35,14 @@ export const SshHostGroupsSection = () => {
};
const onRemoveSshHostGroupSubmit = async (sshHostGroupId: string) => {
- try {
- const hostGroup = await deleteSshHostGroup({ sshHostGroupId });
+ const hostGroup = await deleteSshHostGroup({ sshHostGroupId });
- createNotification({
- text: `Successfully deleted SSH host group: ${hostGroup.name}`,
- type: "success"
- });
+ createNotification({
+ text: `Successfully deleted SSH host group: ${hostGroup.name}`,
+ type: "success"
+ });
- handlePopUpClose("deleteSshHostGroup");
- } catch (err) {
- console.error(err);
- createNotification({
- text: "Failed to delete SSH host group",
- type: "error"
- });
- }
+ handlePopUpClose("deleteSshHostGroup");
};
return (
diff --git a/frontend/src/pages/ssh/SshHostsPage/components/SshHostModal.tsx b/frontend/src/pages/ssh/SshHostsPage/components/SshHostModal.tsx
index e9b0d870a4..afcde908ff 100644
--- a/frontend/src/pages/ssh/SshHostsPage/components/SshHostModal.tsx
+++ b/frontend/src/pages/ssh/SshHostsPage/components/SshHostModal.tsx
@@ -140,93 +140,84 @@ export const SshHostModal = ({ popUp, handlePopUpToggle }: Props) => {
}, [sshHost]);
const onFormSubmit = async ({ hostname, alias, userCertTtl, loginMappings }: FormData) => {
- try {
- if (!projectId) return;
+ if (!projectId) return;
- // Filter out login mappings that are from host groups
- const hostLoginMappings = loginMappings.filter(
- (mapping) => mapping.source === LoginMappingSource.HOST
- );
+ // Filter out login mappings that are from host groups
+ const hostLoginMappings = loginMappings.filter(
+ (mapping) => mapping.source === LoginMappingSource.HOST
+ );
+
+ // check if there is already a different host with the same hostname
+ const existingHostnames =
+ sshHosts?.filter((h) => h.id !== sshHost?.id).map((h) => h.hostname) || [];
+
+ if (existingHostnames.includes(hostname.trim())) {
+ createNotification({
+ text: "A host with this hostname already exists.",
+ type: "error"
+ });
+ return;
+ }
- // check if there is already a different host with the same hostname
- const existingHostnames =
- sshHosts?.filter((h) => h.id !== sshHost?.id).map((h) => h.hostname) || [];
+ const trimmedAlias = alias.trim();
- if (existingHostnames.includes(hostname.trim())) {
+ // check if there is already a different host with the same non-null alias
+ if (trimmedAlias) {
+ const existingAliases =
+ sshHosts?.filter((h) => h.id !== sshHost?.id && h.alias !== null).map((h) => h.alias) || [];
+
+ if (existingAliases.includes(trimmedAlias)) {
createNotification({
- text: "A host with this hostname already exists.",
+ text: "A host with this alias already exists.",
type: "error"
});
return;
}
+ }
- const trimmedAlias = alias.trim();
+ const transformedLoginMappings = hostLoginMappings.map(({ loginUser, allowedPrincipals }) => {
+ const usernames = allowedPrincipals
+ .filter((p) => p.type === "user" && p.value)
+ .map((p) => p.value);
- // check if there is already a different host with the same non-null alias
- if (trimmedAlias) {
- const existingAliases =
- sshHosts?.filter((h) => h.id !== sshHost?.id && h.alias !== null).map((h) => h.alias) ||
- [];
+ const groupNames = allowedPrincipals
+ .filter((p) => p.type === "group" && p.value)
+ .map((p) => p.value);
- if (existingAliases.includes(trimmedAlias)) {
- createNotification({
- text: "A host with this alias already exists.",
- type: "error"
- });
- return;
+ return {
+ loginUser,
+ allowedPrincipals: {
+ usernames,
+ groups: groupNames
}
- }
-
- const transformedLoginMappings = hostLoginMappings.map(({ loginUser, allowedPrincipals }) => {
- const usernames = allowedPrincipals
- .filter((p) => p.type === "user" && p.value)
- .map((p) => p.value);
+ };
+ });
- const groupNames = allowedPrincipals
- .filter((p) => p.type === "group" && p.value)
- .map((p) => p.value);
-
- return {
- loginUser,
- allowedPrincipals: {
- usernames,
- groups: groupNames
- }
- };
- });
-
- if (sshHost) {
- await updateMutateAsync({
- sshHostId: sshHost.id,
- hostname,
- alias: trimmedAlias,
- userCertTtl,
- loginMappings: transformedLoginMappings
- });
- } else {
- await createMutateAsync({
- projectId,
- hostname,
- alias: trimmedAlias,
- userCertTtl,
- loginMappings: transformedLoginMappings
- });
- }
-
- reset();
- handlePopUpToggle("sshHost", false);
-
- createNotification({
- text: `Successfully ${sshHost ? "updated" : "added"} SSH host`,
- type: "success"
+ if (sshHost) {
+ await updateMutateAsync({
+ sshHostId: sshHost.id,
+ hostname,
+ alias: trimmedAlias,
+ userCertTtl,
+ loginMappings: transformedLoginMappings
});
- } catch (err) {
- console.error(err);
- createNotification({
- text: `Failed to ${sshHost ? "update" : "add"} SSH host`,
- type: "error"
+ } else {
+ await createMutateAsync({
+ projectId,
+ hostname,
+ alias: trimmedAlias,
+ userCertTtl,
+ loginMappings: transformedLoginMappings
});
}
+
+ reset();
+ handlePopUpToggle("sshHost", false);
+
+ createNotification({
+ text: `Successfully ${sshHost ? "updated" : "added"} SSH host`,
+ type: "success"
+ });
};
const toggleMapping = (index: number) => {