refactor: enhance notification handling and streamline async logic across secret management components

This commit is contained in:
Victor Santos
2025-11-03 18:24:35 -03:00
parent edd34f5561
commit a73ba232ab
65 changed files with 1159 additions and 1714 deletions
@@ -64,7 +64,6 @@ export const IPAllowlistModal = ({ popUp, handlePopUpClose, handlePopUpToggle }:
}, [popUp?.trustedIp?.data]); }, [popUp?.trustedIp?.data]);
const onIPAllowlistModalSubmit = async ({ ipAddress, comment }: FormData) => { const onIPAllowlistModalSubmit = async ({ ipAddress, comment }: FormData) => {
try {
if (!currentProject?.id) return; if (!currentProject?.id) return;
if (popUp?.trustedIp?.data) { if (popUp?.trustedIp?.data) {
@@ -91,12 +90,6 @@ export const IPAllowlistModal = ({ popUp, handlePopUpClose, handlePopUpToggle }:
reset(); reset();
handlePopUpClose("trustedIp"); handlePopUpClose("trustedIp");
} catch {
createNotification({
text: `Failed to ${popUp?.trustedIp?.data ? "update" : "add"} trusted IP`,
type: "error"
});
}
}; };
return ( return (
@@ -29,7 +29,6 @@ export const IPAllowlistSection = () => {
] as const); ] as const);
const onDeleteTrustedIpSubmit = async (trustedIpId: string) => { const onDeleteTrustedIpSubmit = async (trustedIpId: string) => {
try {
if (!currentProject?.id) return; if (!currentProject?.id) return;
await mutateAsync({ await mutateAsync({
@@ -43,13 +42,6 @@ export const IPAllowlistSection = () => {
}); });
handlePopUpClose("deleteTrustedIp"); handlePopUpClose("deleteTrustedIp");
} catch (err) {
console.log(err);
createNotification({
text: "Failed to delete IP access range",
type: "error"
});
}
}; };
return ( return (
@@ -235,7 +235,6 @@ export const SecretSyncsTable = ({ secretSyncs }: Props) => {
const isAutoSyncEnabled = !secretSync.isAutoSyncEnabled; const isAutoSyncEnabled = !secretSync.isAutoSyncEnabled;
try {
await updateSync.mutateAsync({ await updateSync.mutateAsync({
syncId: secretSync.id, syncId: secretSync.id,
destination: secretSync.destination, destination: secretSync.destination,
@@ -247,18 +246,11 @@ export const SecretSyncsTable = ({ secretSyncs }: Props) => {
text: `Successfully ${isAutoSyncEnabled ? "enabled" : "disabled"} auto-sync for ${destinationName} Sync`, text: `Successfully ${isAutoSyncEnabled ? "enabled" : "disabled"} auto-sync for ${destinationName} Sync`,
type: "success" type: "success"
}); });
} catch {
createNotification({
text: `Failed to ${isAutoSyncEnabled ? "enable" : "disable"} auto-sync for ${destinationName} Sync`,
type: "error"
});
}
}; };
const handleTriggerSync = async (secretSync: TSecretSync) => { const handleTriggerSync = async (secretSync: TSecretSync) => {
const destinationName = SECRET_SYNC_MAP[secretSync.destination].name; const destinationName = SECRET_SYNC_MAP[secretSync.destination].name;
try {
await triggerSync.mutateAsync({ await triggerSync.mutateAsync({
syncId: secretSync.id, syncId: secretSync.id,
destination: secretSync.destination, destination: secretSync.destination,
@@ -269,12 +261,6 @@ export const SecretSyncsTable = ({ secretSyncs }: Props) => {
text: `Successfully triggered ${destinationName} Sync`, text: `Successfully triggered ${destinationName} Sync`,
type: "success" type: "success"
}); });
} catch {
createNotification({
text: `Failed to trigger ${destinationName} Sync`,
type: "error"
});
}
}; };
return ( return (
@@ -65,7 +65,6 @@ export const SecretV2MigrationSection = () => {
const didProjectUpgradeFailed = workspaceDetails?.upgradeStatus === ProjectUpgradeStatus.Failed; const didProjectUpgradeFailed = workspaceDetails?.upgradeStatus === ProjectUpgradeStatus.Failed;
const handleMigrationSecretV2 = async () => { const handleMigrationSecretV2 = async () => {
try {
handlePopUpToggle("migrationInfo"); handlePopUpToggle("migrationInfo");
await migrateProjectToV3.mutateAsync({ projectId: currentProject?.id || "" }); await migrateProjectToV3.mutateAsync({ projectId: currentProject?.id || "" });
refetch(); refetch();
@@ -73,12 +72,6 @@ export const SecretV2MigrationSection = () => {
text: "Project upgrade started", text: "Project upgrade started",
type: "success" type: "success"
}); });
} catch {
createNotification({
text: "Failed to upgrade project",
type: "error"
});
}
}; };
const isAdmin = hasProjectRole(ProjectMembershipRole.Admin); const isAdmin = hasProjectRole(ProjectMembershipRole.Admin);
@@ -65,7 +65,6 @@ const Content = ({ accessRequest, onComplete, projectSlug }: ContentProps) => {
}); });
const onSubmit = async (form: FormData) => { const onSubmit = async (form: FormData) => {
try {
const request = await update.mutateAsync({ const request = await update.mutateAsync({
requestId: accessRequest.id, requestId: accessRequest.id,
projectSlug, projectSlug,
@@ -80,13 +79,6 @@ const Content = ({ accessRequest, onComplete, projectSlug }: ContentProps) => {
text: "Access request updated successfully." text: "Access request updated successfully."
}); });
onComplete(request); onComplete(request);
} catch (e) {
console.error(e);
createNotification({
type: "error",
text: "Failed to update access request"
});
}
}; };
return ( return (
@@ -178,8 +178,7 @@ export const ReviewAccessRequestModal = ({
text: `The request has been ${status}`, text: `The request has been ${status}`,
type: status === "approved" ? "success" : "info" type: status === "approved" ? "success" : "info"
}); });
} catch (error) { } catch {
console.error(error);
setIsLoading(null); setIsLoading(null);
return; return;
} }
@@ -237,7 +237,6 @@ const Form = ({
}: TFormSchema) => { }: TFormSchema) => {
if (!projectId) return; if (!projectId) return;
try {
const bypassers = [...userBypassers, ...groupBypassers]; const bypassers = [...userBypassers, ...groupBypassers];
if (data.policyType === PolicyType.ChangePolicy) { if (data.policyType === PolicyType.ChangePolicy) {
@@ -272,13 +271,6 @@ const Form = ({
text: "Successfully created policy" text: "Successfully created policy"
}); });
onToggle(false); onToggle(false);
} catch (err) {
console.log(err);
createNotification({
type: "error",
text: "Failed to create policy"
});
}
}; };
const handleUpdatePolicy = async ({ const handleUpdatePolicy = async ({
@@ -293,7 +285,6 @@ const Form = ({
if (!projectId || !projectSlug) return; if (!projectId || !projectSlug) return;
if (!editValues?.id) return; if (!editValues?.id) return;
try {
const bypassers = [...userBypassers, ...groupBypassers]; const bypassers = [...userBypassers, ...groupBypassers];
if (data.policyType === PolicyType.ChangePolicy) { if (data.policyType === PolicyType.ChangePolicy) {
@@ -330,13 +321,6 @@ const Form = ({
text: "Successfully updated policy" text: "Successfully updated policy"
}); });
onToggle(false); onToggle(false);
} catch (err) {
console.log(err);
createNotification({
type: "error",
text: "failed to update policy"
});
}
}; };
const handleFormSubmit = async (data: TFormSchema) => { const handleFormSubmit = async (data: TFormSchema) => {
@@ -32,7 +32,6 @@ export const RemoveApprovalPolicyModal = ({
const { currentProject } = useProject(); const { currentProject } = useProject();
const handleDeletePolicy = async () => { const handleDeletePolicy = async () => {
try {
if (policyType === PolicyType.ChangePolicy) { if (policyType === PolicyType.ChangePolicy) {
await deleteSecretApprovalPolicy({ await deleteSecretApprovalPolicy({
projectId: currentProject.id, projectId: currentProject.id,
@@ -49,12 +48,6 @@ export const RemoveApprovalPolicyModal = ({
text: "Successfully deleted policy" text: "Successfully deleted policy"
}); });
onOpenChange(false); onOpenChange(false);
} catch {
createNotification({
type: "error",
text: "Failed to delete policy"
});
}
}; };
const deleteSecretApprovalData = useGetSecretApprovalRequestCount({ const deleteSecretApprovalData = useGetSecretApprovalRequestCount({
@@ -59,7 +59,6 @@ export const SecretApprovalRequestAction = ({
}; };
const handleSecretApprovalRequestMerge = async () => { const handleSecretApprovalRequestMerge = async () => {
try {
await performSecretApprovalMerge({ await performSecretApprovalMerge({
id: approvalRequestId, id: approvalRequestId,
projectId, projectId,
@@ -69,17 +68,9 @@ export const SecretApprovalRequestAction = ({
type: "success", type: "success",
text: "Successfully merged the request" text: "Successfully merged the request"
}); });
} catch (err) {
console.log(err);
createNotification({
type: "error",
text: "Failed to update the request status"
});
}
}; };
const handleSecretApprovalStatusChange = async (reqState: "open" | "close") => { const handleSecretApprovalStatusChange = async (reqState: "open" | "close") => {
try {
await updateSecretStatusChange({ await updateSecretStatusChange({
id: approvalRequestId, id: approvalRequestId,
status: reqState, status: reqState,
@@ -89,13 +80,6 @@ export const SecretApprovalRequestAction = ({
type: "success", type: "success",
text: "Successfully updated the request" text: "Successfully updated the request"
}); });
} catch (err) {
console.log(err);
createNotification({
type: "error",
text: "Failed to update the request status"
});
}
}; };
const isSoftEnforcement = enforcementLevel === EnforcementLevel.Soft; const isSoftEnforcement = enforcementLevel === EnforcementLevel.Soft;
@@ -174,7 +174,6 @@ export const SecretApprovalRequestChanges = ({ approvalRequestId, onGoBack }: Pr
); );
const handleSecretApprovalStatusUpdate = async (status: ApprovalStatus, comment: string) => { const handleSecretApprovalStatusUpdate = async (status: ApprovalStatus, comment: string) => {
try {
await updateSecretApprovalRequestStatus({ await updateSecretApprovalRequestStatus({
id: approvalRequestId, id: approvalRequestId,
status, status,
@@ -184,13 +183,6 @@ export const SecretApprovalRequestChanges = ({ approvalRequestId, onGoBack }: Pr
type: "success", type: "success",
text: `Successfully ${status} the request` text: `Successfully ${status} the request`
}); });
} catch (err) {
console.log(err);
createNotification({
type: "error",
text: "Failed to update the request status"
});
}
handlePopUpToggle("reviewChanges", false); handlePopUpToggle("reviewChanges", false);
reset({ reset({
@@ -338,7 +338,6 @@ const Page = () => {
const isProtectedBranch = Boolean(boardPolicy); const isProtectedBranch = Boolean(boardPolicy);
const handleCreateCommit = async (changes: PendingChanges, message: string) => { const handleCreateCommit = async (changes: PendingChanges, message: string) => {
try {
await createCommit({ await createCommit({
projectId, projectId,
environment, environment,
@@ -370,13 +369,6 @@ const Page = () => {
: "Changes saved successfully", : "Changes saved successfully",
type: "success" type: "success"
}); });
} catch (error) {
createNotification({
text: "Failed to save changes",
type: "error"
});
console.error(error);
}
}; };
const { const {
@@ -209,7 +209,6 @@ export const ActionBar = ({
const isOrgAdmin = hasOrgRole(OrgMembershipRole.Admin); const isOrgAdmin = hasOrgRole(OrgMembershipRole.Admin);
const handleFolderCreate = async (folderName: string, description: string | null) => { const handleFolderCreate = async (folderName: string, description: string | null) => {
try {
if (isBatchMode) { if (isBatchMode) {
const folderId = `${folderName}`; const folderId = `${folderName}`;
const pendingFolderCreate: PendingFolderCreate = { const pendingFolderCreate: PendingFolderCreate = {
@@ -244,13 +243,6 @@ export const ActionBar = ({
type: "success", type: "success",
text: "Successfully created folder" text: "Successfully created folder"
}); });
} catch (error) {
console.log(error);
createNotification({
type: "error",
text: "Failed to create folder"
});
}
}; };
const handleSecretDownload = async () => { const handleSecretDownload = async () => {
@@ -323,7 +315,6 @@ export const ActionBar = ({
const handleSecretBulkDelete = async () => { const handleSecretBulkDelete = async () => {
const bulkDeletedSecrets = Object.values(selectedSecrets); const bulkDeletedSecrets = Object.values(selectedSecrets);
try {
await deleteBatchSecretV3({ await deleteBatchSecretV3({
secretPath, secretPath,
projectId, projectId,
@@ -336,13 +327,6 @@ export const ActionBar = ({
type: "success", type: "success",
text: "Successfully deleted secrets" text: "Successfully deleted secrets"
}); });
} catch (error) {
console.log(error);
createNotification({
type: "error",
text: "Failed to delete secrets"
});
}
}; };
const handleSecretsMove = async ({ const handleSecretsMove = async ({
@@ -678,7 +662,6 @@ export const ActionBar = ({
}; };
const handleVaultImport = async (vaultPath: string, namespace: string) => { const handleVaultImport = async (vaultPath: string, namespace: string) => {
try {
const result = await importVaultSecrets({ const result = await importVaultSecrets({
projectId, projectId,
environment, environment,
@@ -698,17 +681,6 @@ export const ActionBar = ({
text: "Successfully imported secrets from HashiCorp Vault" text: "Successfully imported secrets from HashiCorp Vault"
}); });
} }
} catch (err) {
console.error("Vault import error:", err);
const error = err as AxiosError<{ message?: string }>;
const errorMessage =
error.response?.data?.message || "Failed to import secrets from Vault. Please try again.";
createNotification({
type: "error",
text: errorMessage
});
}
}; };
const isTableFiltered = const isTableFiltered =
@@ -4,7 +4,6 @@ import ms from "ms";
import { z } from "zod"; import { z } from "zod";
import { TtlFormLabel } from "@app/components/features"; import { TtlFormLabel } from "@app/components/features";
import { createNotification } from "@app/components/notifications";
import { import {
Accordion, Accordion,
AccordionContent, AccordionContent,
@@ -111,7 +110,6 @@ export const AwsElastiCacheInputForm = ({
if (createDynamicSecret.isPending) return; if (createDynamicSecret.isPending) return;
const isDefaultUsernameTemplate = usernameTemplate === "{{randomUsername}}"; const isDefaultUsernameTemplate = usernameTemplate === "{{randomUsername}}";
try {
await createDynamicSecret.mutateAsync({ await createDynamicSecret.mutateAsync({
provider: { type: DynamicSecretProviders.AwsElastiCache, inputs: provider }, provider: { type: DynamicSecretProviders.AwsElastiCache, inputs: provider },
maxTTL, maxTTL,
@@ -124,12 +122,6 @@ export const AwsElastiCacheInputForm = ({
!usernameTemplate || isDefaultUsernameTemplate ? undefined : usernameTemplate !usernameTemplate || isDefaultUsernameTemplate ? undefined : usernameTemplate
}); });
onCompleted(); onCompleted();
} catch {
createNotification({
type: "error",
text: "Failed to create dynamic secret"
});
}
}; };
return ( return (
@@ -4,7 +4,6 @@ import ms from "ms";
import { z } from "zod"; import { z } from "zod";
import { TtlFormLabel } from "@app/components/features"; import { TtlFormLabel } from "@app/components/features";
import { createNotification } from "@app/components/notifications";
import { import {
Button, Button,
FilterableSelect, FilterableSelect,
@@ -166,7 +165,6 @@ export const AwsIamInputForm = ({
// wait till previous request is finished // wait till previous request is finished
if (createDynamicSecret.isPending) return; if (createDynamicSecret.isPending) return;
try {
const isDefaultUsernameTemplate = usernameTemplate === "{{randomUsername}}"; const isDefaultUsernameTemplate = usernameTemplate === "{{randomUsername}}";
await createDynamicSecret.mutateAsync({ await createDynamicSecret.mutateAsync({
provider: { type: DynamicSecretProviders.AwsIam, inputs: provider }, provider: { type: DynamicSecretProviders.AwsIam, inputs: provider },
@@ -180,12 +178,6 @@ export const AwsIamInputForm = ({
!usernameTemplate || isDefaultUsernameTemplate ? undefined : usernameTemplate !usernameTemplate || isDefaultUsernameTemplate ? undefined : usernameTemplate
}); });
onCompleted(); onCompleted();
} catch {
createNotification({
type: "error",
text: "Failed to create dynamic secret"
});
}
}; };
return ( return (
@@ -6,7 +6,6 @@ import ms from "ms";
import { z } from "zod"; import { z } from "zod";
import { TtlFormLabel } from "@app/components/features"; import { TtlFormLabel } from "@app/components/features";
import { createNotification } from "@app/components/notifications";
import { Button, FilterableSelect, FormControl, Input } from "@app/components/v2"; import { Button, FilterableSelect, FormControl, Input } from "@app/components/v2";
import { import {
DropdownMenu, DropdownMenu,
@@ -112,7 +111,6 @@ export const AzureEntraIdInputForm = ({
}: TForm) => { }: TForm) => {
// wait till previous request is finished // wait till previous request is finished
if (createDynamicSecret.isPending) return; if (createDynamicSecret.isPending) return;
try {
selectedUsers.map(async (user: { id: string; name: string; email: string }) => { selectedUsers.map(async (user: { id: string; name: string; email: string }) => {
await createDynamicSecret.mutateAsync({ await createDynamicSecret.mutateAsync({
provider: { provider: {
@@ -134,12 +132,6 @@ export const AzureEntraIdInputForm = ({
}); });
}); });
onCompleted(); onCompleted();
} catch {
createNotification({
type: "error",
text: "Failed to create dynamic secret"
});
}
}; };
return ( return (
@@ -5,7 +5,6 @@ import ms from "ms";
import { z } from "zod"; import { z } from "zod";
import { TtlFormLabel } from "@app/components/features"; import { TtlFormLabel } from "@app/components/features";
import { createNotification } from "@app/components/notifications";
import { OrgPermissionCan } from "@app/components/permissions"; import { OrgPermissionCan } from "@app/components/permissions";
import { import {
Accordion, Accordion,
@@ -171,7 +170,6 @@ export const AzureSqlDatabaseInputForm = ({
if (createDynamicSecret.isPending) return; if (createDynamicSecret.isPending) return;
const isDefaultUsernameTemplate = usernameTemplate === "{{randomUsername}}"; const isDefaultUsernameTemplate = usernameTemplate === "{{randomUsername}}";
try {
await createDynamicSecret.mutateAsync({ await createDynamicSecret.mutateAsync({
provider: { provider: {
type: DynamicSecretProviders.AzureSqlDatabase, type: DynamicSecretProviders.AzureSqlDatabase,
@@ -188,12 +186,6 @@ export const AzureSqlDatabaseInputForm = ({
!usernameTemplate || isDefaultUsernameTemplate ? undefined : usernameTemplate !usernameTemplate || isDefaultUsernameTemplate ? undefined : usernameTemplate
}); });
onCompleted(); onCompleted();
} catch {
createNotification({
type: "error",
text: "Failed to create dynamic secret"
});
}
}; };
return ( return (
@@ -4,7 +4,6 @@ import ms from "ms";
import { z } from "zod"; import { z } from "zod";
import { TtlFormLabel } from "@app/components/features"; import { TtlFormLabel } from "@app/components/features";
import { createNotification } from "@app/components/notifications";
import { import {
Accordion, Accordion,
AccordionContent, AccordionContent,
@@ -112,7 +111,6 @@ export const CassandraInputForm = ({
if (createDynamicSecret.isPending) return; if (createDynamicSecret.isPending) return;
const isDefaultUsernameTemplate = usernameTemplate === "{{randomUsername}}"; const isDefaultUsernameTemplate = usernameTemplate === "{{randomUsername}}";
try {
await createDynamicSecret.mutateAsync({ await createDynamicSecret.mutateAsync({
provider: { type: DynamicSecretProviders.Cassandra, inputs: provider }, provider: { type: DynamicSecretProviders.Cassandra, inputs: provider },
maxTTL, maxTTL,
@@ -125,12 +123,6 @@ export const CassandraInputForm = ({
!usernameTemplate || isDefaultUsernameTemplate ? undefined : usernameTemplate !usernameTemplate || isDefaultUsernameTemplate ? undefined : usernameTemplate
}); });
onCompleted(); onCompleted();
} catch {
createNotification({
type: "error",
text: "Failed to create dynamic secret"
});
}
}; };
return ( return (
@@ -7,7 +7,6 @@ import ms from "ms";
import { z } from "zod"; import { z } from "zod";
import { TtlFormLabel } from "@app/components/features"; import { TtlFormLabel } from "@app/components/features";
import { createNotification } from "@app/components/notifications";
import { import {
Accordion, Accordion,
AccordionContent, AccordionContent,
@@ -386,7 +385,6 @@ export const CouchbaseInputForm = ({
const { useAdvancedBuckets, ...finalProvider } = transformedProvider; const { useAdvancedBuckets, ...finalProvider } = transformedProvider;
try {
await createDynamicSecret.mutateAsync({ await createDynamicSecret.mutateAsync({
provider: { type: DynamicSecretProviders.Couchbase, inputs: finalProvider }, provider: { type: DynamicSecretProviders.Couchbase, inputs: finalProvider },
maxTTL, maxTTL,
@@ -399,12 +397,6 @@ export const CouchbaseInputForm = ({
!usernameTemplate || isDefaultUsernameTemplate ? undefined : usernameTemplate !usernameTemplate || isDefaultUsernameTemplate ? undefined : usernameTemplate
}); });
onCompleted(); onCompleted();
} catch {
createNotification({
type: "error",
text: "Failed to create dynamic secret"
});
}
}; };
return ( return (
@@ -6,7 +6,6 @@ import ms from "ms";
import { z } from "zod"; import { z } from "zod";
import { TtlFormLabel } from "@app/components/features"; import { TtlFormLabel } from "@app/components/features";
import { createNotification } from "@app/components/notifications";
import { import {
Button, Button,
FilterableSelect, FilterableSelect,
@@ -131,7 +130,6 @@ export const ElasticSearchInputForm = ({
// wait till previous request is finished // wait till previous request is finished
if (createDynamicSecret.isPending) return; if (createDynamicSecret.isPending) return;
const isDefaultUsernameTemplate = usernameTemplate === "{{randomUsername}}"; const isDefaultUsernameTemplate = usernameTemplate === "{{randomUsername}}";
try {
await createDynamicSecret.mutateAsync({ await createDynamicSecret.mutateAsync({
provider: { type: DynamicSecretProviders.ElasticSearch, inputs: provider }, provider: { type: DynamicSecretProviders.ElasticSearch, inputs: provider },
maxTTL, maxTTL,
@@ -144,12 +142,6 @@ export const ElasticSearchInputForm = ({
!usernameTemplate || isDefaultUsernameTemplate ? undefined : usernameTemplate !usernameTemplate || isDefaultUsernameTemplate ? undefined : usernameTemplate
}); });
onCompleted(); onCompleted();
} catch {
createNotification({
type: "error",
text: "Failed to create dynamic secret"
});
}
}; };
const selectedAuthType = watch("provider.auth.type"); const selectedAuthType = watch("provider.auth.type");
@@ -4,7 +4,6 @@ import ms from "ms";
import { z } from "zod"; import { z } from "zod";
import { TtlFormLabel } from "@app/components/features"; import { TtlFormLabel } from "@app/components/features";
import { createNotification } from "@app/components/notifications";
import { Button, FilterableSelect, FormControl, Input } from "@app/components/v2"; import { Button, FilterableSelect, FormControl, Input } from "@app/components/v2";
import { useCreateDynamicSecret } from "@app/hooks/api"; import { useCreateDynamicSecret } from "@app/hooks/api";
import { DynamicSecretProviders } from "@app/hooks/api/dynamicSecret/types"; import { DynamicSecretProviders } from "@app/hooks/api/dynamicSecret/types";
@@ -83,7 +82,6 @@ export const GcpIamInputForm = ({
}: TForm) => { }: TForm) => {
// wait till previous request is finished // wait till previous request is finished
if (createDynamicSecret.isPending) return; if (createDynamicSecret.isPending) return;
try {
await createDynamicSecret.mutateAsync({ await createDynamicSecret.mutateAsync({
provider: { provider: {
type: DynamicSecretProviders.GcpIam, type: DynamicSecretProviders.GcpIam,
@@ -99,12 +97,6 @@ export const GcpIamInputForm = ({
environmentSlug: environment.slug environmentSlug: environment.slug
}); });
onCompleted(); onCompleted();
} catch {
createNotification({
type: "error",
text: "Failed to create dynamic secret"
});
}
}; };
return ( return (
@@ -4,7 +4,6 @@ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { zodResolver } from "@hookform/resolvers/zod"; import { zodResolver } from "@hookform/resolvers/zod";
import { z } from "zod"; import { z } from "zod";
import { createNotification } from "@app/components/notifications";
import { import {
Button, Button,
FilterableSelect, FilterableSelect,
@@ -71,7 +70,6 @@ export const GithubInputForm = ({
const handleCreateDynamicSecret = async ({ name, provider, environment }: TForm) => { const handleCreateDynamicSecret = async ({ name, provider, environment }: TForm) => {
if (createDynamicSecret.isPending) return; if (createDynamicSecret.isPending) return;
try {
await createDynamicSecret.mutateAsync({ await createDynamicSecret.mutateAsync({
provider: { provider: {
type: DynamicSecretProviders.Github, type: DynamicSecretProviders.Github,
@@ -86,12 +84,6 @@ export const GithubInputForm = ({
environmentSlug: environment.slug environmentSlug: environment.slug
}); });
onCompleted(); onCompleted();
} catch {
createNotification({
type: "error",
text: "Failed to create dynamic secret"
});
}
}; };
return ( return (
@@ -283,7 +283,6 @@ export const KubernetesInputForm = ({
// wait till previous request is finished // wait till previous request is finished
if (createDynamicSecret.isPending) return; if (createDynamicSecret.isPending) return;
try {
const isDefaultUsernameTemplate = usernameTemplate === "{{randomUsername}}"; const isDefaultUsernameTemplate = usernameTemplate === "{{randomUsername}}";
await createDynamicSecret.mutateAsync({ await createDynamicSecret.mutateAsync({
provider: { provider: {
@@ -304,12 +303,6 @@ export const KubernetesInputForm = ({
}); });
onCompleted(); onCompleted();
} catch {
createNotification({
type: "error",
text: "Failed to create dynamic secret"
});
}
}; };
return ( return (
@@ -4,7 +4,6 @@ import ms from "ms";
import { z } from "zod"; import { z } from "zod";
import { TtlFormLabel } from "@app/components/features"; import { TtlFormLabel } from "@app/components/features";
import { createNotification } from "@app/components/notifications";
import { import {
Button, Button,
FilterableSelect, FilterableSelect,
@@ -139,7 +138,6 @@ export const LdapInputForm = ({
if (createDynamicSecret.isPending) return; if (createDynamicSecret.isPending) return;
const isDefaultUsernameTemplate = usernameTemplate === "{{randomUsername}}"; const isDefaultUsernameTemplate = usernameTemplate === "{{randomUsername}}";
try {
await createDynamicSecret.mutateAsync({ await createDynamicSecret.mutateAsync({
provider: { type: DynamicSecretProviders.Ldap, inputs: provider }, provider: { type: DynamicSecretProviders.Ldap, inputs: provider },
maxTTL, maxTTL,
@@ -152,12 +150,6 @@ export const LdapInputForm = ({
environmentSlug: environment.slug environmentSlug: environment.slug
}); });
onCompleted(); onCompleted();
} catch {
createNotification({
type: "error",
text: "Failed to create dynamic secret"
});
}
}; };
return ( return (
@@ -6,7 +6,6 @@ import ms from "ms";
import { z } from "zod"; import { z } from "zod";
import { TtlFormLabel } from "@app/components/features"; import { TtlFormLabel } from "@app/components/features";
import { createNotification } from "@app/components/notifications";
import { import {
Accordion, Accordion,
AccordionContent, AccordionContent,
@@ -143,7 +142,6 @@ export const MongoAtlasInputForm = ({
if (createDynamicSecret.isPending) return; if (createDynamicSecret.isPending) return;
const isDefaultUsernameTemplate = usernameTemplate === "{{randomUsername}}"; const isDefaultUsernameTemplate = usernameTemplate === "{{randomUsername}}";
try {
await createDynamicSecret.mutateAsync({ await createDynamicSecret.mutateAsync({
provider: { type: DynamicSecretProviders.MongoAtlas, inputs: provider }, provider: { type: DynamicSecretProviders.MongoAtlas, inputs: provider },
maxTTL, maxTTL,
@@ -156,12 +154,6 @@ export const MongoAtlasInputForm = ({
!usernameTemplate || isDefaultUsernameTemplate ? undefined : usernameTemplate !usernameTemplate || isDefaultUsernameTemplate ? undefined : usernameTemplate
}); });
onCompleted(); onCompleted();
} catch {
createNotification({
type: "error",
text: "Failed to create dynamic secret"
});
}
}; };
return ( return (
@@ -6,7 +6,6 @@ import ms from "ms";
import { z } from "zod"; import { z } from "zod";
import { TtlFormLabel } from "@app/components/features"; import { TtlFormLabel } from "@app/components/features";
import { createNotification } from "@app/components/notifications";
import { import {
Button, Button,
FilterableSelect, FilterableSelect,
@@ -113,7 +112,6 @@ export const MongoDBDatabaseInputForm = ({
if (createDynamicSecret.isPending) return; if (createDynamicSecret.isPending) return;
const isDefaultUsernameTemplate = usernameTemplate === "{{randomUsername}}"; const isDefaultUsernameTemplate = usernameTemplate === "{{randomUsername}}";
try {
await createDynamicSecret.mutateAsync({ await createDynamicSecret.mutateAsync({
provider: { provider: {
type: DynamicSecretProviders.MongoDB, type: DynamicSecretProviders.MongoDB,
@@ -133,12 +131,6 @@ export const MongoDBDatabaseInputForm = ({
!usernameTemplate || isDefaultUsernameTemplate ? undefined : usernameTemplate !usernameTemplate || isDefaultUsernameTemplate ? undefined : usernameTemplate
}); });
onCompleted(); onCompleted();
} catch {
createNotification({
type: "error",
text: "Failed to create dynamic secret"
});
}
}; };
return ( return (
@@ -6,7 +6,6 @@ import ms from "ms";
import { z } from "zod"; import { z } from "zod";
import { TtlFormLabel } from "@app/components/features"; import { TtlFormLabel } from "@app/components/features";
import { createNotification } from "@app/components/notifications";
import { import {
Button, Button,
FilterableSelect, FilterableSelect,
@@ -121,7 +120,6 @@ export const RabbitMqInputForm = ({
if (createDynamicSecret.isPending) return; if (createDynamicSecret.isPending) return;
const isDefaultUsernameTemplate = usernameTemplate === "{{randomUsername}}"; const isDefaultUsernameTemplate = usernameTemplate === "{{randomUsername}}";
try {
await createDynamicSecret.mutateAsync({ await createDynamicSecret.mutateAsync({
provider: { type: DynamicSecretProviders.RabbitMq, inputs: provider }, provider: { type: DynamicSecretProviders.RabbitMq, inputs: provider },
maxTTL, maxTTL,
@@ -134,12 +132,6 @@ export const RabbitMqInputForm = ({
!usernameTemplate || isDefaultUsernameTemplate ? undefined : usernameTemplate !usernameTemplate || isDefaultUsernameTemplate ? undefined : usernameTemplate
}); });
onCompleted(); onCompleted();
} catch {
createNotification({
type: "error",
text: "Failed to create dynamic secret"
});
}
}; };
const selectedTags = watch("provider.tags"); const selectedTags = watch("provider.tags");
@@ -4,7 +4,6 @@ import ms from "ms";
import { z } from "zod"; import { z } from "zod";
import { TtlFormLabel } from "@app/components/features"; import { TtlFormLabel } from "@app/components/features";
import { createNotification } from "@app/components/notifications";
import { import {
Accordion, Accordion,
AccordionContent, AccordionContent,
@@ -104,7 +103,6 @@ export const RedisInputForm = ({
}: TForm) => { }: TForm) => {
// wait till previous request is finished // wait till previous request is finished
if (createDynamicSecret.isPending) return; if (createDynamicSecret.isPending) return;
try {
const isDefaultUsernameTemplate = usernameTemplate === "{{randomUsername}}"; const isDefaultUsernameTemplate = usernameTemplate === "{{randomUsername}}";
await createDynamicSecret.mutateAsync({ await createDynamicSecret.mutateAsync({
provider: { type: DynamicSecretProviders.Redis, inputs: provider }, provider: { type: DynamicSecretProviders.Redis, inputs: provider },
@@ -118,12 +116,6 @@ export const RedisInputForm = ({
!usernameTemplate || isDefaultUsernameTemplate ? undefined : usernameTemplate !usernameTemplate || isDefaultUsernameTemplate ? undefined : usernameTemplate
}); });
onCompleted(); onCompleted();
} catch {
createNotification({
type: "error",
text: "Failed to create dynamic secret"
});
}
}; };
return ( return (
@@ -4,7 +4,6 @@ import ms from "ms";
import { z } from "zod"; import { z } from "zod";
import { TtlFormLabel } from "@app/components/features"; import { TtlFormLabel } from "@app/components/features";
import { createNotification } from "@app/components/notifications";
import { import {
Accordion, Accordion,
AccordionContent, AccordionContent,
@@ -105,7 +104,6 @@ sp_droplogin '{{username}}';`
}: TForm) => { }: TForm) => {
// wait till previous request is finished // wait till previous request is finished
if (createDynamicSecret.isPending) return; if (createDynamicSecret.isPending) return;
try {
const isDefaultUsernameTemplate = usernameTemplate === "{{randomUsername}}"; const isDefaultUsernameTemplate = usernameTemplate === "{{randomUsername}}";
await createDynamicSecret.mutateAsync({ await createDynamicSecret.mutateAsync({
provider: { type: DynamicSecretProviders.SapAse, inputs: provider }, provider: { type: DynamicSecretProviders.SapAse, inputs: provider },
@@ -119,12 +117,6 @@ sp_droplogin '{{username}}';`
!usernameTemplate || isDefaultUsernameTemplate ? undefined : usernameTemplate !usernameTemplate || isDefaultUsernameTemplate ? undefined : usernameTemplate
}); });
onCompleted(); onCompleted();
} catch {
createNotification({
type: "error",
text: "Failed to create dynamic secret"
});
}
}; };
return ( return (
@@ -4,7 +4,6 @@ import ms from "ms";
import { z } from "zod"; import { z } from "zod";
import { TtlFormLabel } from "@app/components/features"; import { TtlFormLabel } from "@app/components/features";
import { createNotification } from "@app/components/notifications";
import { import {
Accordion, Accordion,
AccordionContent, AccordionContent,
@@ -105,7 +104,6 @@ DROP USER {{username}};`,
}: TForm) => { }: TForm) => {
// wait till previous request is finished // wait till previous request is finished
if (createDynamicSecret.isPending) return; if (createDynamicSecret.isPending) return;
try {
const isDefaultUsernameTemplate = usernameTemplate === "{{randomUsername}}"; const isDefaultUsernameTemplate = usernameTemplate === "{{randomUsername}}";
await createDynamicSecret.mutateAsync({ await createDynamicSecret.mutateAsync({
provider: { type: DynamicSecretProviders.SapHana, inputs: provider }, provider: { type: DynamicSecretProviders.SapHana, inputs: provider },
@@ -119,12 +117,6 @@ DROP USER {{username}};`,
environmentSlug: environment.slug environmentSlug: environment.slug
}); });
onCompleted(); onCompleted();
} catch {
createNotification({
type: "error",
text: "Failed to create dynamic secret"
});
}
}; };
return ( return (
@@ -4,7 +4,6 @@ import ms from "ms";
import { z } from "zod"; import { z } from "zod";
import { TtlFormLabel } from "@app/components/features"; import { TtlFormLabel } from "@app/components/features";
import { createNotification } from "@app/components/notifications";
import { import {
Accordion, Accordion,
AccordionContent, AccordionContent,
@@ -102,7 +101,6 @@ export const SnowflakeInputForm = ({
}: TForm) => { }: TForm) => {
// wait till previous request is finished // wait till previous request is finished
if (createDynamicSecret.isPending) return; if (createDynamicSecret.isPending) return;
try {
const isDefaultUsernameTemplate = usernameTemplate === "{{randomUsername}}"; const isDefaultUsernameTemplate = usernameTemplate === "{{randomUsername}}";
await createDynamicSecret.mutateAsync({ await createDynamicSecret.mutateAsync({
provider: { type: DynamicSecretProviders.Snowflake, inputs: provider }, provider: { type: DynamicSecretProviders.Snowflake, inputs: provider },
@@ -116,12 +114,6 @@ export const SnowflakeInputForm = ({
!usernameTemplate || isDefaultUsernameTemplate ? undefined : usernameTemplate !usernameTemplate || isDefaultUsernameTemplate ? undefined : usernameTemplate
}); });
onCompleted(); onCompleted();
} catch (err) {
createNotification({
type: "error",
text: err instanceof Error ? err.message : "Failed to create dynamic secret"
});
}
}; };
return ( return (
@@ -5,7 +5,6 @@ import ms from "ms";
import { z } from "zod"; import { z } from "zod";
import { TtlFormLabel } from "@app/components/features"; import { TtlFormLabel } from "@app/components/features";
import { createNotification } from "@app/components/notifications";
import { OrgPermissionCan } from "@app/components/permissions"; import { OrgPermissionCan } from "@app/components/permissions";
import { import {
Accordion, Accordion,
@@ -215,7 +214,6 @@ export const SqlDatabaseInputForm = ({
if (createDynamicSecret.isPending) return; if (createDynamicSecret.isPending) return;
const isDefaultUsernameTemplate = usernameTemplate === "{{randomUsername}}"; const isDefaultUsernameTemplate = usernameTemplate === "{{randomUsername}}";
try {
await createDynamicSecret.mutateAsync({ await createDynamicSecret.mutateAsync({
provider: { type: DynamicSecretProviders.SqlDatabase, inputs: provider }, provider: { type: DynamicSecretProviders.SqlDatabase, inputs: provider },
maxTTL, maxTTL,
@@ -229,12 +227,6 @@ export const SqlDatabaseInputForm = ({
!usernameTemplate || isDefaultUsernameTemplate ? undefined : usernameTemplate !usernameTemplate || isDefaultUsernameTemplate ? undefined : usernameTemplate
}); });
onCompleted(); onCompleted();
} catch {
createNotification({
type: "error",
text: "Failed to create dynamic secret"
});
}
}; };
const handleDatabaseChange = (type: SqlProviders) => { const handleDatabaseChange = (type: SqlProviders) => {
@@ -2,7 +2,6 @@ import { Controller, useForm } from "react-hook-form";
import { zodResolver } from "@hookform/resolvers/zod"; import { zodResolver } from "@hookform/resolvers/zod";
import { z } from "zod"; import { z } from "zod";
import { createNotification } from "@app/components/notifications";
import { import {
Button, Button,
FilterableSelect, FilterableSelect,
@@ -100,7 +99,6 @@ export const TotpInputForm = ({
const handleCreateDynamicSecret = async ({ name, provider, environment }: TForm) => { const handleCreateDynamicSecret = async ({ name, provider, environment }: TForm) => {
// wait till previous request is finished // wait till previous request is finished
if (createDynamicSecret.isPending) return; if (createDynamicSecret.isPending) return;
try {
await createDynamicSecret.mutateAsync({ await createDynamicSecret.mutateAsync({
provider: { type: DynamicSecretProviders.Totp, inputs: provider }, provider: { type: DynamicSecretProviders.Totp, inputs: provider },
maxTTL: "24h", maxTTL: "24h",
@@ -111,12 +109,6 @@ export const TotpInputForm = ({
environmentSlug: environment.slug environmentSlug: environment.slug
}); });
onCompleted(); onCompleted();
} catch (err) {
createNotification({
type: "error",
text: err instanceof Error ? err.message : "Failed to create dynamic secret"
});
}
}; };
return ( return (
@@ -5,7 +5,6 @@ import ms from "ms";
import { z } from "zod"; import { z } from "zod";
import { TtlFormLabel } from "@app/components/features"; import { TtlFormLabel } from "@app/components/features";
import { createNotification } from "@app/components/notifications";
import { OrgPermissionCan } from "@app/components/permissions"; import { OrgPermissionCan } from "@app/components/permissions";
import { import {
Accordion, Accordion,
@@ -145,7 +144,6 @@ GRANT CREATE ON SCHEMA public TO {{username}};`,
usernameTemplate usernameTemplate
}: TForm) => { }: TForm) => {
if (createDynamicSecret.isPending) return; if (createDynamicSecret.isPending) return;
try {
const isDefaultUsernameTemplate = usernameTemplate === "{{randomUsername}}"; const isDefaultUsernameTemplate = usernameTemplate === "{{randomUsername}}";
await createDynamicSecret.mutateAsync({ await createDynamicSecret.mutateAsync({
provider: { type: DynamicSecretProviders.Vertica, inputs: provider }, provider: { type: DynamicSecretProviders.Vertica, inputs: provider },
@@ -159,12 +157,6 @@ GRANT CREATE ON SCHEMA public TO {{username}};`,
!usernameTemplate || isDefaultUsernameTemplate ? undefined : usernameTemplate !usernameTemplate || isDefaultUsernameTemplate ? undefined : usernameTemplate
}); });
onCompleted(); onCompleted();
} catch {
createNotification({
type: "error",
text: "Failed to create dynamic secret"
});
}
}; };
return ( return (
@@ -101,11 +101,6 @@ export const CreateSecretImportForm = ({
text: "You do not have access to the selected environment/path", text: "You do not have access to the selected environment/path",
type: "error" type: "error"
}); });
} else {
createNotification({
type: "error",
text: "Failed to link secrets"
});
} }
} }
}; };
@@ -441,7 +441,6 @@ export const CreateKubernetesDynamicSecretLease = ({
const handleDynamicSecretLeaseCreate = async ({ ttl, namespace }: TKubernetesForm) => { const handleDynamicSecretLeaseCreate = async ({ ttl, namespace }: TKubernetesForm) => {
if (createDynamicSecretLease.isPending) return; if (createDynamicSecretLease.isPending) return;
try {
await createDynamicSecretLease.mutateAsync({ await createDynamicSecretLease.mutateAsync({
environmentSlug: environment, environmentSlug: environment,
projectSlug, projectSlug,
@@ -458,13 +457,6 @@ export const CreateKubernetesDynamicSecretLease = ({
type: "success", type: "success",
text: "Successfully leased dynamic secret" text: "Successfully leased dynamic secret"
}); });
} catch (error) {
console.log(error);
createNotification({
type: "error",
text: "Failed to lease dynamic secret"
});
}
}; };
const handleLeaseRegeneration = async (data: { ttl?: string }) => { const handleLeaseRegeneration = async (data: { ttl?: string }) => {
@@ -590,7 +582,6 @@ export const CreateDynamicSecretLease = ({
const handleDynamicSecretLeaseCreate = async ({ ttl }: TForm) => { const handleDynamicSecretLeaseCreate = async ({ ttl }: TForm) => {
if (createDynamicSecretLease.isPending) return; if (createDynamicSecretLease.isPending) return;
try {
await createDynamicSecretLease.mutateAsync({ await createDynamicSecretLease.mutateAsync({
environmentSlug: environment, environmentSlug: environment,
projectSlug, projectSlug,
@@ -606,13 +597,6 @@ export const CreateDynamicSecretLease = ({
}); });
setIsPreloading.off(); setIsPreloading.off();
} catch (error) {
console.log(error);
createNotification({
type: "error",
text: "Failed to lease dynamic secret"
});
}
}; };
const handleLeaseRegeneration = async (data: { ttl?: string }) => { const handleLeaseRegeneration = async (data: { ttl?: string }) => {
@@ -69,7 +69,6 @@ export const DynamicSecretLease = ({
const deleteDynamicSecretLease = useRevokeDynamicSecretLease(); const deleteDynamicSecretLease = useRevokeDynamicSecretLease();
const handleDynamicSecretDeleteLease = async () => { const handleDynamicSecretDeleteLease = async () => {
try {
const { leaseId, isForced } = popUp.deleteSecret.data as { const { leaseId, isForced } = popUp.deleteSecret.data as {
leaseId: string; leaseId: string;
isForced?: boolean; isForced?: boolean;
@@ -87,13 +86,6 @@ export const DynamicSecretLease = ({
type: "success", type: "success",
text: "Successfully deleted lease" text: "Successfully deleted lease"
}); });
} catch (error) {
console.log(error);
createNotification({
type: "error",
text: "Failed to delete lease"
});
}
}; };
const canRenew = !DYNAMIC_SECRETS_WITHOUT_RENEWAL.includes(dynamicSecret.type); const canRenew = !DYNAMIC_SECRETS_WITHOUT_RENEWAL.includes(dynamicSecret.type);
@@ -54,7 +54,6 @@ export const DynamicSecretListView = ({
const deleteDynamicSecret = useDeleteDynamicSecret(); const deleteDynamicSecret = useDeleteDynamicSecret();
const handleDynamicSecretDelete = async () => { const handleDynamicSecretDelete = async () => {
try {
const { name, isForced } = popUp.deleteDynamicSecret.data as TDynamicSecret & { const { name, isForced } = popUp.deleteDynamicSecret.data as TDynamicSecret & {
isForced?: boolean; isForced?: boolean;
}; };
@@ -70,13 +69,6 @@ export const DynamicSecretListView = ({
type: "success", type: "success",
text: "Successfully deleted dynamic secret" text: "Successfully deleted dynamic secret"
}); });
} catch (error) {
console.log(error);
createNotification({
type: "error",
text: "Failed to delete dynamic secret"
});
}
}; };
return ( return (
@@ -101,7 +101,6 @@ export const EditDynamicSecretAwsElastiCacheProviderForm = ({
// wait till previous request is finished // wait till previous request is finished
if (updateDynamicSecret.isPending) return; if (updateDynamicSecret.isPending) return;
const isDefaultUsernameTemplate = usernameTemplate === "{{randomUsername}}"; const isDefaultUsernameTemplate = usernameTemplate === "{{randomUsername}}";
try {
await updateDynamicSecret.mutateAsync({ await updateDynamicSecret.mutateAsync({
name: dynamicSecret.name, name: dynamicSecret.name,
path: secretPath, path: secretPath,
@@ -120,12 +119,6 @@ export const EditDynamicSecretAwsElastiCacheProviderForm = ({
type: "success", type: "success",
text: "Successfully updated dynamic secret" text: "Successfully updated dynamic secret"
}); });
} catch {
createNotification({
type: "error",
text: "Failed to update dynamic secret"
});
}
}; };
return ( return (
@@ -141,7 +141,6 @@ export const EditDynamicSecretAwsIamForm = ({
// wait till previous request is finished // wait till previous request is finished
if (updateDynamicSecret.isPending) return; if (updateDynamicSecret.isPending) return;
const isDefaultUsernameTemplate = usernameTemplate === "{{randomUsername}}"; const isDefaultUsernameTemplate = usernameTemplate === "{{randomUsername}}";
try {
await updateDynamicSecret.mutateAsync({ await updateDynamicSecret.mutateAsync({
name: dynamicSecret.name, name: dynamicSecret.name,
path: secretPath, path: secretPath,
@@ -160,12 +159,6 @@ export const EditDynamicSecretAwsIamForm = ({
type: "success", type: "success",
text: "Successfully updated dynamic secret" text: "Successfully updated dynamic secret"
}); });
} catch {
createNotification({
type: "error",
text: "Failed to update dynamic secret"
});
}
}; };
return ( return (
@@ -76,7 +76,6 @@ export const EditDynamicSecretAzureEntraIdForm = ({
const handleUpdateDynamicSecret = async ({ maxTTL, defaultTTL, newName, inputs }: TForm) => { const handleUpdateDynamicSecret = async ({ maxTTL, defaultTTL, newName, inputs }: TForm) => {
// wait till previous request is finished // wait till previous request is finished
if (updateDynamicSecret.isPending) return; if (updateDynamicSecret.isPending) return;
try {
await updateDynamicSecret.mutateAsync({ await updateDynamicSecret.mutateAsync({
name: dynamicSecret.name, name: dynamicSecret.name,
path: secretPath, path: secretPath,
@@ -94,12 +93,6 @@ export const EditDynamicSecretAzureEntraIdForm = ({
type: "success", type: "success",
text: "Successfully updated dynamic secret" text: "Successfully updated dynamic secret"
}); });
} catch {
createNotification({
type: "error",
text: "Failed to update dynamic secret"
});
}
}; };
return ( return (
@@ -162,7 +162,6 @@ export const EditDynamicSecretAzureSqlDatabaseForm = ({
}: TForm) => { }: TForm) => {
if (updateDynamicSecret.isPending) return; if (updateDynamicSecret.isPending) return;
try {
const isDefaultUsernameTemplate = usernameTemplate === "{{randomUsername}}"; const isDefaultUsernameTemplate = usernameTemplate === "{{randomUsername}}";
await updateDynamicSecret.mutateAsync({ await updateDynamicSecret.mutateAsync({
projectSlug, projectSlug,
@@ -183,12 +182,6 @@ export const EditDynamicSecretAzureSqlDatabaseForm = ({
type: "success", type: "success",
text: "Successfully updated dynamic secret" text: "Successfully updated dynamic secret"
}); });
} catch {
createNotification({
type: "error",
text: "Failed to update dynamic secret"
});
}
}; };
return ( return (
@@ -103,7 +103,6 @@ export const EditDynamicSecretCassandraForm = ({
// wait till previous request is finished // wait till previous request is finished
if (updateDynamicSecret.isPending) return; if (updateDynamicSecret.isPending) return;
const isDefaultUsernameTemplate = usernameTemplate === "{{randomUsername}}"; const isDefaultUsernameTemplate = usernameTemplate === "{{randomUsername}}";
try {
await updateDynamicSecret.mutateAsync({ await updateDynamicSecret.mutateAsync({
name: dynamicSecret.name, name: dynamicSecret.name,
path: secretPath, path: secretPath,
@@ -122,12 +121,6 @@ export const EditDynamicSecretCassandraForm = ({
type: "success", type: "success",
text: "Successfully updated dynamic secret" text: "Successfully updated dynamic secret"
}); });
} catch {
createNotification({
type: "error",
text: "Failed to update dynamic secret"
});
}
}; };
return ( return (
@@ -386,7 +386,6 @@ export const EditDynamicSecretCouchbaseForm = ({
})() })()
: transformedInputs; : transformedInputs;
try {
await updateDynamicSecret.mutateAsync({ await updateDynamicSecret.mutateAsync({
name: dynamicSecret.name, name: dynamicSecret.name,
path: secretPath, path: secretPath,
@@ -411,12 +410,6 @@ export const EditDynamicSecretCouchbaseForm = ({
}); });
onClose(); onClose();
} catch (err) {
createNotification({
type: "error",
text: `Failed to update dynamic secret: ${err}`
});
}
}; };
return ( return (
@@ -123,7 +123,6 @@ export const EditDynamicSecretElasticSearchForm = ({
// wait till previous request is finished // wait till previous request is finished
if (updateDynamicSecret.isPending) return; if (updateDynamicSecret.isPending) return;
const isDefaultUsernameTemplate = usernameTemplate === "{{randomUsername}}"; const isDefaultUsernameTemplate = usernameTemplate === "{{randomUsername}}";
try {
await updateDynamicSecret.mutateAsync({ await updateDynamicSecret.mutateAsync({
name: dynamicSecret.name, name: dynamicSecret.name,
path: secretPath, path: secretPath,
@@ -142,12 +141,6 @@ export const EditDynamicSecretElasticSearchForm = ({
type: "success", type: "success",
text: "Successfully updated dynamic secret" text: "Successfully updated dynamic secret"
}); });
} catch {
createNotification({
type: "error",
text: "Failed to update dynamic secret"
});
}
}; };
const selectedAuthType = watch("inputs.auth.type"); const selectedAuthType = watch("inputs.auth.type");
@@ -77,7 +77,6 @@ export const EditDynamicSecretGcpIamForm = ({
const handleUpdateDynamicSecret = async ({ inputs, maxTTL, defaultTTL, newName }: TForm) => { const handleUpdateDynamicSecret = async ({ inputs, maxTTL, defaultTTL, newName }: TForm) => {
// wait till previous request is finished // wait till previous request is finished
if (updateDynamicSecret.isPending) return; if (updateDynamicSecret.isPending) return;
try {
await updateDynamicSecret.mutateAsync({ await updateDynamicSecret.mutateAsync({
name: dynamicSecret.name, name: dynamicSecret.name,
path: secretPath, path: secretPath,
@@ -95,12 +94,6 @@ export const EditDynamicSecretGcpIamForm = ({
type: "success", type: "success",
text: "Successfully updated dynamic secret" text: "Successfully updated dynamic secret"
}); });
} catch {
createNotification({
type: "error",
text: "Failed to update dynamic secret"
});
}
}; };
return ( return (
@@ -61,7 +61,6 @@ export const EditDynamicSecretGithubForm = ({
const handleUpdateDynamicSecret = async ({ inputs, newName }: TForm) => { const handleUpdateDynamicSecret = async ({ inputs, newName }: TForm) => {
if (updateDynamicSecret.isPending) return; if (updateDynamicSecret.isPending) return;
try {
await updateDynamicSecret.mutateAsync({ await updateDynamicSecret.mutateAsync({
name: dynamicSecret.name, name: dynamicSecret.name,
path: secretPath, path: secretPath,
@@ -77,12 +76,6 @@ export const EditDynamicSecretGithubForm = ({
type: "success", type: "success",
text: "Successfully updated dynamic secret" text: "Successfully updated dynamic secret"
}); });
} catch {
createNotification({
type: "error",
text: "Failed to update dynamic secret"
});
}
}; };
return ( return (
@@ -189,7 +189,6 @@ export const EditDynamicSecretKubernetesForm = ({
// wait till previous request is finished // wait till previous request is finished
if (updateDynamicSecret.isPending) return; if (updateDynamicSecret.isPending) return;
const isDefaultUsernameTemplate = formData.usernameTemplate === "{{randomUsername}}"; const isDefaultUsernameTemplate = formData.usernameTemplate === "{{randomUsername}}";
try {
await updateDynamicSecret.mutateAsync({ await updateDynamicSecret.mutateAsync({
name: dynamicSecret.name, name: dynamicSecret.name,
path: secretPath, path: secretPath,
@@ -204,9 +203,7 @@ export const EditDynamicSecretKubernetesForm = ({
defaultTTL: formData.defaultTTL, defaultTTL: formData.defaultTTL,
maxTTL: formData.maxTTL, maxTTL: formData.maxTTL,
usernameTemplate: usernameTemplate:
!formData.usernameTemplate || isDefaultUsernameTemplate !formData.usernameTemplate || isDefaultUsernameTemplate ? null : formData.usernameTemplate
? null
: formData.usernameTemplate
} }
}); });
@@ -215,12 +212,6 @@ export const EditDynamicSecretKubernetesForm = ({
type: "success", type: "success",
text: "Successfully updated dynamic secret" text: "Successfully updated dynamic secret"
}); });
} catch (err) {
createNotification({
type: "error",
text: err instanceof Error ? err.message : "Failed to update dynamic secret"
});
}
}; };
return ( return (
@@ -119,7 +119,6 @@ export const EditDynamicSecretLdapForm = ({
if (updateDynamicSecret.isPending) return; if (updateDynamicSecret.isPending) return;
const isDefaultUsernameTemplate = usernameTemplate === "{{randomUsername}}"; const isDefaultUsernameTemplate = usernameTemplate === "{{randomUsername}}";
try {
await updateDynamicSecret.mutateAsync({ await updateDynamicSecret.mutateAsync({
name: dynamicSecret.name, name: dynamicSecret.name,
path: secretPath, path: secretPath,
@@ -138,12 +137,6 @@ export const EditDynamicSecretLdapForm = ({
type: "success", type: "success",
text: "Successfully updated dynamic secret" text: "Successfully updated dynamic secret"
}); });
} catch {
createNotification({
type: "error",
text: "Failed to update dynamic secret"
});
}
}; };
return ( return (
@@ -142,7 +142,6 @@ export const EditDynamicSecretMongoAtlasForm = ({
if (updateDynamicSecret.isPending) return; if (updateDynamicSecret.isPending) return;
const isDefaultUsernameTemplate = usernameTemplate === "{{randomUsername}}"; const isDefaultUsernameTemplate = usernameTemplate === "{{randomUsername}}";
try {
await updateDynamicSecret.mutateAsync({ await updateDynamicSecret.mutateAsync({
name: dynamicSecret.name, name: dynamicSecret.name,
path: secretPath, path: secretPath,
@@ -161,12 +160,6 @@ export const EditDynamicSecretMongoAtlasForm = ({
type: "success", type: "success",
text: "Successfully updated dynamic secret" text: "Successfully updated dynamic secret"
}); });
} catch {
createNotification({
type: "error",
text: "Failed to update dynamic secret"
});
}
}; };
return ( return (
@@ -108,7 +108,6 @@ export const EditDynamicSecretMongoDBForm = ({
if (updateDynamicSecret.isPending) return; if (updateDynamicSecret.isPending) return;
const isDefaultUsernameTemplate = usernameTemplate === "{{randomUsername}}"; const isDefaultUsernameTemplate = usernameTemplate === "{{randomUsername}}";
try {
await updateDynamicSecret.mutateAsync({ await updateDynamicSecret.mutateAsync({
name: dynamicSecret.name, name: dynamicSecret.name,
path: secretPath, path: secretPath,
@@ -122,8 +121,7 @@ export const EditDynamicSecretMongoDBForm = ({
port: inputs?.port ? inputs.port : undefined, port: inputs?.port ? inputs.port : undefined,
roles: inputs?.roles?.map((el) => el.roleName) roles: inputs?.roles?.map((el) => el.roleName)
}, },
usernameTemplate: usernameTemplate: !usernameTemplate || isDefaultUsernameTemplate ? null : usernameTemplate,
!usernameTemplate || isDefaultUsernameTemplate ? null : usernameTemplate,
newName: newName === dynamicSecret.name ? undefined : newName newName: newName === dynamicSecret.name ? undefined : newName
} }
}); });
@@ -132,12 +130,6 @@ export const EditDynamicSecretMongoDBForm = ({
type: "success", type: "success",
text: "Successfully updated dynamic secret" text: "Successfully updated dynamic secret"
}); });
} catch {
createNotification({
type: "error",
text: "Failed to update dynamic secret"
});
}
}; };
return ( return (
@@ -100,7 +100,6 @@ export const EditDynamicSecretRabbitMqForm = ({
if (updateDynamicSecret.isPending) return; if (updateDynamicSecret.isPending) return;
const isDefaultUsernameTemplate = usernameTemplate === "{{randomUsername}}"; const isDefaultUsernameTemplate = usernameTemplate === "{{randomUsername}}";
try {
await updateDynamicSecret.mutateAsync({ await updateDynamicSecret.mutateAsync({
name: dynamicSecret.name, name: dynamicSecret.name,
path: secretPath, path: secretPath,
@@ -119,12 +118,6 @@ export const EditDynamicSecretRabbitMqForm = ({
type: "success", type: "success",
text: "Successfully updated dynamic secret" text: "Successfully updated dynamic secret"
}); });
} catch {
createNotification({
type: "error",
text: "Failed to update dynamic secret"
});
}
}; };
const selectedTags = watch("inputs.tags"); const selectedTags = watch("inputs.tags");
@@ -102,15 +102,13 @@ export const EditDynamicSecretRedisProviderForm = ({
// wait till previous request is finished // wait till previous request is finished
if (updateDynamicSecret.isPending) return; if (updateDynamicSecret.isPending) return;
const isDefaultUsernameTemplate = usernameTemplate === "{{randomUsername}}"; const isDefaultUsernameTemplate = usernameTemplate === "{{randomUsername}}";
try {
await updateDynamicSecret.mutateAsync({ await updateDynamicSecret.mutateAsync({
name: dynamicSecret.name, name: dynamicSecret.name,
path: secretPath, path: secretPath,
projectSlug, projectSlug,
environmentSlug: environment, environmentSlug: environment,
data: { data: {
usernameTemplate: usernameTemplate: !usernameTemplate || isDefaultUsernameTemplate ? null : usernameTemplate,
!usernameTemplate || isDefaultUsernameTemplate ? null : usernameTemplate,
maxTTL: maxTTL || undefined, maxTTL: maxTTL || undefined,
defaultTTL, defaultTTL,
inputs, inputs,
@@ -122,12 +120,6 @@ export const EditDynamicSecretRedisProviderForm = ({
type: "success", type: "success",
text: "Successfully updated dynamic secret" text: "Successfully updated dynamic secret"
}); });
} catch {
createNotification({
type: "error",
text: "Failed to update dynamic secret"
});
}
}; };
return ( return (
@@ -101,7 +101,6 @@ export const EditDynamicSecretSapAseForm = ({
if (updateDynamicSecret.isPending) return; if (updateDynamicSecret.isPending) return;
const isDefaultUsernameTemplate = usernameTemplate === "{{randomUsername}}"; const isDefaultUsernameTemplate = usernameTemplate === "{{randomUsername}}";
try {
await updateDynamicSecret.mutateAsync({ await updateDynamicSecret.mutateAsync({
name: dynamicSecret.name, name: dynamicSecret.name,
path: secretPath, path: secretPath,
@@ -120,12 +119,6 @@ export const EditDynamicSecretSapAseForm = ({
type: "success", type: "success",
text: "Successfully updated dynamic secret" text: "Successfully updated dynamic secret"
}); });
} catch {
createNotification({
type: "error",
text: "Failed to update dynamic secret"
});
}
}; };
return ( return (
@@ -101,7 +101,6 @@ export const EditDynamicSecretSapHanaForm = ({
if (updateDynamicSecret.isPending) return; if (updateDynamicSecret.isPending) return;
const isDefaultUsernameTemplate = usernameTemplate === "{{randomUsername}}"; const isDefaultUsernameTemplate = usernameTemplate === "{{randomUsername}}";
try {
await updateDynamicSecret.mutateAsync({ await updateDynamicSecret.mutateAsync({
name: dynamicSecret.name, name: dynamicSecret.name,
path: secretPath, path: secretPath,
@@ -120,12 +119,6 @@ export const EditDynamicSecretSapHanaForm = ({
type: "success", type: "success",
text: "Successfully updated dynamic secret" text: "Successfully updated dynamic secret"
}); });
} catch {
createNotification({
type: "error",
text: "Failed to update dynamic secret"
});
}
}; };
return ( return (
@@ -97,7 +97,6 @@ export const EditDynamicSecretSnowflakeForm = ({
}: TForm) => { }: TForm) => {
// wait till previous request is finished // wait till previous request is finished
if (updateDynamicSecret.isPending) return; if (updateDynamicSecret.isPending) return;
try {
const isDefaultUsernameTemplate = usernameTemplate === "{{randomUsername}}"; const isDefaultUsernameTemplate = usernameTemplate === "{{randomUsername}}";
await updateDynamicSecret.mutateAsync({ await updateDynamicSecret.mutateAsync({
name: dynamicSecret.name, name: dynamicSecret.name,
@@ -117,12 +116,6 @@ export const EditDynamicSecretSnowflakeForm = ({
type: "success", type: "success",
text: "Successfully updated dynamic secret" text: "Successfully updated dynamic secret"
}); });
} catch (err) {
createNotification({
type: "error",
text: err instanceof Error ? err.message : "Failed to update dynamic secret"
});
}
}; };
return ( return (
@@ -167,7 +167,6 @@ export const EditDynamicSecretSqlProviderForm = ({
}: TForm) => { }: TForm) => {
// wait till previous request is finished // wait till previous request is finished
if (updateDynamicSecret.isPending) return; if (updateDynamicSecret.isPending) return;
try {
const isDefaultUsernameTemplate = usernameTemplate === "{{randomUsername}}"; const isDefaultUsernameTemplate = usernameTemplate === "{{randomUsername}}";
await updateDynamicSecret.mutateAsync({ await updateDynamicSecret.mutateAsync({
name: dynamicSecret.name, name: dynamicSecret.name,
@@ -191,12 +190,6 @@ export const EditDynamicSecretSqlProviderForm = ({
type: "success", type: "success",
text: "Successfully updated dynamic secret" text: "Successfully updated dynamic secret"
}); });
} catch {
createNotification({
type: "error",
text: "Failed to update dynamic secret"
});
}
}; };
return ( return (
@@ -87,7 +87,6 @@ export const EditDynamicSecretTotpForm = ({
const handleUpdateDynamicSecret = async ({ inputs, newName }: TForm) => { const handleUpdateDynamicSecret = async ({ inputs, newName }: TForm) => {
// wait till previous request is finished // wait till previous request is finished
if (updateDynamicSecret.isPending) return; if (updateDynamicSecret.isPending) return;
try {
await updateDynamicSecret.mutateAsync({ await updateDynamicSecret.mutateAsync({
name: dynamicSecret.name, name: dynamicSecret.name,
path: secretPath, path: secretPath,
@@ -103,12 +102,6 @@ export const EditDynamicSecretTotpForm = ({
type: "success", type: "success",
text: "Successfully updated dynamic secret" text: "Successfully updated dynamic secret"
}); });
} catch (err) {
createNotification({
type: "error",
text: err instanceof Error ? err.message : "Failed to update dynamic secret"
});
}
}; };
return ( return (
@@ -146,7 +146,7 @@ export const EditDynamicSecretVerticaForm = ({
if (updateDynamicSecret.isPending) return; if (updateDynamicSecret.isPending) return;
const isDefaultUsernameTemplate = usernameTemplate === "{{randomUsername}}"; const isDefaultUsernameTemplate = usernameTemplate === "{{randomUsername}}";
try {
await updateDynamicSecret.mutateAsync({ await updateDynamicSecret.mutateAsync({
name: dynamicSecret.name, name: dynamicSecret.name,
path: secretPath, path: secretPath,
@@ -168,12 +168,6 @@ export const EditDynamicSecretVerticaForm = ({
type: "success", type: "success",
text: "Successfully updated dynamic secret" text: "Successfully updated dynamic secret"
}); });
} catch {
createNotification({
type: "error",
text: "Failed to update dynamic secret"
});
}
}; };
return ( return (
@@ -64,7 +64,6 @@ export const RenewDynamicSecretLease = ({
const handleDynamicSecretLeaseCreate = async ({ ttl }: TForm) => { const handleDynamicSecretLeaseCreate = async ({ ttl }: TForm) => {
if (renewDynamicSecretLease.isPending) return; if (renewDynamicSecretLease.isPending) return;
try {
await renewDynamicSecretLease.mutateAsync({ await renewDynamicSecretLease.mutateAsync({
environmentSlug: environment, environmentSlug: environment,
projectSlug, projectSlug,
@@ -78,13 +77,6 @@ export const RenewDynamicSecretLease = ({
type: "success", type: "success",
text: "Successfully renewed lease" text: "Successfully renewed lease"
}); });
} catch (error) {
console.log(error);
createNotification({
type: "error",
text: "Failed to renew lease"
});
}
}; };
return ( return (
@@ -69,7 +69,6 @@ export const FolderListView = ({
oldFolderName?: string, oldFolderName?: string,
oldFolderDescription?: string oldFolderDescription?: string
) => { ) => {
try {
const updateFolderData = popUp.updateFolder.data; const updateFolderData = popUp.updateFolder.data;
if (!updateFolderData) throw new Error("Update folder data is required"); if (!updateFolderData) throw new Error("Update folder data is required");
const { id: folderId, pendingAction, isPending } = updateFolderData as TSecretFolder; const { id: folderId, pendingAction, isPending } = updateFolderData as TSecretFolder;
@@ -129,13 +128,6 @@ export const FolderListView = ({
type: "success", type: "success",
text: "Successfully saved folder" text: "Successfully saved folder"
}); });
} catch (error) {
console.log(error);
createNotification({
type: "error",
text: "Failed to save folder"
});
}
}; };
const handleDeletePending = (id: string) => { const handleDeletePending = (id: string) => {
@@ -147,7 +139,6 @@ export const FolderListView = ({
}; };
const handleFolderDelete = async () => { const handleFolderDelete = async () => {
try {
const folderData = popUp.deleteFolder?.data as TSecretFolder; const folderData = popUp.deleteFolder?.data as TSecretFolder;
if (isBatchMode) { if (isBatchMode) {
@@ -182,13 +173,6 @@ export const FolderListView = ({
type: "success", type: "success",
text: "Successfully deleted folder" text: "Successfully deleted folder"
}); });
} catch (error) {
console.log(error);
createNotification({
type: "error",
text: "Failed to delete folder"
});
}
}; };
const handleFolderClick = (name: string, isPending?: boolean) => { const handleFolderClick = (name: string, isPending?: boolean) => {
@@ -118,7 +118,6 @@ export const SecretImportItem = ({
const handleResyncSecretReplication = async () => { const handleResyncSecretReplication = async () => {
if (resyncSecretReplication.isPending) return; if (resyncSecretReplication.isPending) return;
try {
await resyncSecretReplication.mutateAsync({ await resyncSecretReplication.mutateAsync({
id, id,
environment, environment,
@@ -129,13 +128,6 @@ export const SecretImportItem = ({
text: "Please refresh the dashboard to view changes", text: "Please refresh the dashboard to view changes",
type: "success" type: "success"
}); });
} catch (error) {
console.error(error);
createNotification({
text: "Failed to resync replication",
type: "error"
});
}
}; };
const handleRowClick = () => { const handleRowClick = () => {
@@ -147,7 +147,6 @@ export const SecretImportListView = ({
const handleSecretImportDelete = async () => { const handleSecretImportDelete = async () => {
const { id: secretImportId } = popUp.deleteSecretImport?.data as { id: string }; const { id: secretImportId } = popUp.deleteSecretImport?.data as { id: string };
try {
await deleteSecretImport({ await deleteSecretImport({
projectId, projectId,
environment, environment,
@@ -159,13 +158,6 @@ export const SecretImportListView = ({
type: "success", type: "success",
text: "Successfully removed secret link" text: "Successfully removed secret link"
}); });
} catch (err) {
console.error(err);
createNotification({
text: "Failed to remove secret link",
type: "error"
});
}
}; };
const handleSecretImportReorder = ({ over, active }: DragEndEvent) => { const handleSecretImportReorder = ({ over, active }: DragEndEvent) => {
@@ -199,7 +199,6 @@ export const CreateReminderForm = ({
// Form submission handler // Form submission handler
const handleFormSubmit = async (data: TReminderFormSchema) => { const handleFormSubmit = async (data: TReminderFormSchema) => {
try {
await createReminder({ await createReminder({
repeatDays: data.repeatDays, repeatDays: data.repeatDays,
message: data.message, message: data.message,
@@ -218,18 +217,10 @@ export const CreateReminderForm = ({
reset(); reset();
onOpenChange(); onOpenChange();
} catch (error) {
console.error("Failed to save reminder:", error);
createNotification({
type: "error",
text: "Failed to save reminder. Please try again."
});
}
}; };
// Delete reminder handler // Delete reminder handler
const handleDeleteReminder = async () => { const handleDeleteReminder = async () => {
try {
await deleteReminder({ reminderId: reminder?.id || "", secretId }); await deleteReminder({ reminderId: reminder?.id || "", secretId });
invalidateQueries(); invalidateQueries();
reset(); reset();
@@ -239,13 +230,6 @@ export const CreateReminderForm = ({
type: "success", type: "success",
text: "Successfully deleted reminder" text: "Successfully deleted reminder"
}); });
} catch (error) {
console.error("Failed to delete reminder:", error);
createNotification({
type: "error",
text: "Failed to delete reminder. Please try again."
});
}
}; };
// Handle reminder type change // Handle reminder type change
@@ -128,7 +128,6 @@ export const SnapshotView = ({
}); });
return; return;
} }
try {
await performRollback({ await performRollback({
projectId, projectId,
snapshotId: snapshotData.id, snapshotId: snapshotData.id,
@@ -140,13 +139,6 @@ export const SnapshotView = ({
type: "success" type: "success"
}); });
onGoBack(); onGoBack();
} catch (error) {
console.log(error);
createNotification({
text: "Failed to rollback secrets",
type: "error"
});
}
}; };
if (isSnapshotLoading) { if (isSnapshotLoading) {
@@ -1,7 +1,6 @@
import { useRef, useState } from "react"; import { useRef, useState } from "react";
import { AnimatePresence, motion } from "framer-motion"; import { AnimatePresence, motion } from "framer-motion";
import { createNotification } from "@app/components/notifications";
import { Modal, ModalContent, Step, Stepper } from "@app/components/v2"; import { Modal, ModalContent, Step, Stepper } from "@app/components/v2";
import { useCreateSecretRotation } from "@app/hooks/api"; import { useCreateSecretRotation } from "@app/hooks/api";
import { TSecretRotationProviderTemplate } from "@app/hooks/api/types"; import { TSecretRotationProviderTemplate } from "@app/hooks/api/types";
@@ -54,7 +53,6 @@ export const CreateRotationForm = ({
const handleFormSubmit = async () => { const handleFormSubmit = async () => {
if (!wizardData.current.input || !wizardData.current.output) return; if (!wizardData.current.input || !wizardData.current.output) return;
try {
await createSecretRotation({ await createSecretRotation({
workspaceId, workspaceId,
provider: provider.name, provider: provider.name,
@@ -68,13 +66,6 @@ export const CreateRotationForm = ({
setWizardStep(0); setWizardStep(0);
onToggle(false); onToggle(false);
wizardData.current = {}; wizardData.current = {};
} catch (error) {
console.log(error);
createNotification({
type: "error",
text: "Failed to create secret rotation"
});
}
}; };
return ( return (