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,39 +64,32 @@ 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) {
await updateTrustedIp.mutateAsync({ await updateTrustedIp.mutateAsync({
projectId: currentProject.id, projectId: currentProject.id,
trustedIpId: (popUp?.trustedIp?.data as { trustedIpId: string })?.trustedIpId, trustedIpId: (popUp?.trustedIp?.data as { trustedIpId: string })?.trustedIpId,
ipAddress, ipAddress,
comment, comment,
isActive: true isActive: true
});
} else {
await addTrustedIp.mutateAsync({
projectId: currentProject.id,
ipAddress,
comment,
isActive: true
});
}
createNotification({
text: `Successfully ${popUp?.trustedIp?.data ? "updated" : "added"} trusted IP`,
type: "success"
}); });
} else {
reset(); await addTrustedIp.mutateAsync({
handlePopUpClose("trustedIp"); projectId: currentProject.id,
} catch { ipAddress,
createNotification({ comment,
text: `Failed to ${popUp?.trustedIp?.data ? "update" : "add"} trusted IP`, isActive: true
type: "error"
}); });
} }
createNotification({
text: `Successfully ${popUp?.trustedIp?.data ? "updated" : "added"} trusted IP`,
type: "success"
});
reset();
handlePopUpClose("trustedIp");
}; };
return ( return (
@@ -29,27 +29,19 @@ 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({
projectId: currentProject.id, projectId: currentProject.id,
trustedIpId trustedIpId
}); });
createNotification({ createNotification({
text: "Successfully deleted IP access range", text: "Successfully deleted IP access range",
type: "success" type: "success"
}); });
handlePopUpClose("deleteTrustedIp"); handlePopUpClose("deleteTrustedIp");
} catch (err) {
console.log(err);
createNotification({
text: "Failed to delete IP access range",
type: "error"
});
}
}; };
return ( return (
@@ -235,46 +235,32 @@ 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, isAutoSyncEnabled,
isAutoSyncEnabled, projectId: secretSync.projectId
projectId: secretSync.projectId });
});
createNotification({ createNotification({
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, projectId: secretSync.projectId
projectId: secretSync.projectId });
});
createNotification({ createNotification({
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,20 +65,13 @@ 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(); createNotification({
createNotification({ 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,28 +65,20 @@ 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, ...form
...form });
}); await queryClient.refetchQueries({
await queryClient.refetchQueries({ queryKey: accessApprovalKeys.getAccessApprovalPolicies(projectSlug)
queryKey: accessApprovalKeys.getAccessApprovalPolicies(projectSlug) });
});
createNotification({ createNotification({
type: "success", type: "success",
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,48 +237,40 @@ 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) {
await createSecretApprovalPolicy({ await createSecretApprovalPolicy({
...data, ...data,
approvers: [...userApprovers, ...groupApprovers], approvers: [...userApprovers, ...groupApprovers],
bypassers: bypassers.length > 0 ? bypassers : undefined, bypassers: bypassers.length > 0 ? bypassers : undefined,
environments: environments.map((env) => env.slug), environments: environments.map((env) => env.slug),
projectId: currentProject?.id || "" projectId: currentProject?.id || ""
});
} else {
await createAccessApprovalPolicy({
...data,
approvers: sequenceApprovers?.flatMap((approvers, index) =>
approvers.user
.map(
(el) => ({ ...el, sequence: index + 1 }) as Omit<Approver, "isOrgMembershipActive">
)
.concat(approvers.group.map((el) => ({ ...el, sequence: index + 1 })))
),
approvalsRequired: sequenceApprovers?.map((el, index) => ({
stepNumber: index + 1,
numberOfApprovals: el.approvals
})),
bypassers: bypassers.length > 0 ? bypassers : undefined,
environments: environments.map((env) => env.slug),
projectSlug
});
}
createNotification({
type: "success",
text: "Successfully created policy"
}); });
onToggle(false); } else {
} catch (err) { await createAccessApprovalPolicy({
console.log(err); ...data,
createNotification({ approvers: sequenceApprovers?.flatMap((approvers, index) =>
type: "error", approvers.user
text: "Failed to create policy" .map(
(el) => ({ ...el, sequence: index + 1 }) as Omit<Approver, "isOrgMembershipActive">
)
.concat(approvers.group.map((el) => ({ ...el, sequence: index + 1 })))
),
approvalsRequired: sequenceApprovers?.map((el, index) => ({
stepNumber: index + 1,
numberOfApprovals: el.approvals
})),
bypassers: bypassers.length > 0 ? bypassers : undefined,
environments: environments.map((env) => env.slug),
projectSlug
}); });
} }
createNotification({
type: "success",
text: "Successfully created policy"
});
onToggle(false);
}; };
const handleUpdatePolicy = async ({ const handleUpdatePolicy = async ({
@@ -293,50 +285,42 @@ 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) {
await updateSecretApprovalPolicy({ await updateSecretApprovalPolicy({
id: editValues?.id, id: editValues?.id,
...data, ...data,
approvers: [...userApprovers, ...groupApprovers], approvers: [...userApprovers, ...groupApprovers],
bypassers: bypassers.length > 0 ? bypassers : undefined, bypassers: bypassers.length > 0 ? bypassers : undefined,
projectId: currentProject?.id || "", projectId: currentProject?.id || "",
environments: environments.map((env) => env.slug) environments: environments.map((env) => env.slug)
});
} else {
await updateAccessApprovalPolicy({
id: editValues?.id,
...data,
approvers: sequenceApprovers?.flatMap((approvers, index) =>
approvers.user
.map(
(el) => ({ ...el, sequence: index + 1 }) as Omit<Approver, "isOrgMembershipActive">
)
.concat(approvers.group.map((el) => ({ ...el, sequence: index + 1 })))
),
approvalsRequired: sequenceApprovers?.map((el, index) => ({
stepNumber: index + 1,
numberOfApprovals: el.approvals
})),
bypassers: bypassers.length > 0 ? bypassers : undefined,
environments: environments.map((env) => env.slug),
projectSlug
});
}
createNotification({
type: "success",
text: "Successfully updated policy"
}); });
onToggle(false); } else {
} catch (err) { await updateAccessApprovalPolicy({
console.log(err); id: editValues?.id,
createNotification({ ...data,
type: "error", approvers: sequenceApprovers?.flatMap((approvers, index) =>
text: "failed to update policy" approvers.user
.map(
(el) => ({ ...el, sequence: index + 1 }) as Omit<Approver, "isOrgMembershipActive">
)
.concat(approvers.group.map((el) => ({ ...el, sequence: index + 1 })))
),
approvalsRequired: sequenceApprovers?.map((el, index) => ({
stepNumber: index + 1,
numberOfApprovals: el.approvals
})),
bypassers: bypassers.length > 0 ? bypassers : undefined,
environments: environments.map((env) => env.slug),
projectSlug
}); });
} }
createNotification({
type: "success",
text: "Successfully updated policy"
});
onToggle(false);
}; };
const handleFormSubmit = async (data: TFormSchema) => { const handleFormSubmit = async (data: TFormSchema) => {
@@ -32,29 +32,22 @@ 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, id: policyId
id: policyId
});
} else {
await deleteAccessApprovalPolicy({
projectSlug: currentProject.slug,
id: policyId
});
}
createNotification({
type: "success",
text: "Successfully deleted policy"
}); });
onOpenChange(false); } else {
} catch { await deleteAccessApprovalPolicy({
createNotification({ projectSlug: currentProject.slug,
type: "error", id: policyId
text: "Failed to delete policy"
}); });
} }
createNotification({
type: "success",
text: "Successfully deleted policy"
});
onOpenChange(false);
}; };
const deleteSecretApprovalData = useGetSecretApprovalRequestCount({ const deleteSecretApprovalData = useGetSecretApprovalRequestCount({
@@ -59,43 +59,27 @@ export const SecretApprovalRequestAction = ({
}; };
const handleSecretApprovalRequestMerge = async () => { const handleSecretApprovalRequestMerge = async () => {
try { await performSecretApprovalMerge({
await performSecretApprovalMerge({ id: approvalRequestId,
id: approvalRequestId, projectId,
projectId, bypassReason: byPassApproval ? bypassReason : undefined
bypassReason: byPassApproval ? bypassReason : undefined });
}); createNotification({
createNotification({ 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, projectId
projectId });
}); createNotification({
createNotification({ 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,23 +174,15 @@ 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, comment
comment });
}); createNotification({
createNotification({ 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,45 +338,37 @@ 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, secretPath,
secretPath, pendingChanges: changes,
pendingChanges: changes, message
message });
});
if (!isProtectedBranch) { if (!isProtectedBranch) {
pendingChanges.secrets.forEach((secret) => { pendingChanges.secrets.forEach((secret) => {
if (secret.type === "update" && secret.secretValue !== undefined) { if (secret.type === "update" && secret.secretValue !== undefined) {
queryClient.setQueryData( queryClient.setQueryData(
dashboardKeys.getSecretValue({ dashboardKeys.getSecretValue({
projectId, projectId,
environment, environment,
secretPath, secretPath,
secretKey: secret.newSecretName ?? secret.secretKey, secretKey: secret.newSecretName ?? secret.secretKey,
isOverride: false isOverride: false
}), }),
{ value: secret.secretValue } { value: secret.secretValue }
); );
} }
});
}
createNotification({
text: isProtectedBranch
? "Requested changes have been sent for review"
: "Changes saved successfully",
type: "success"
}); });
} catch (error) {
createNotification({
text: "Failed to save changes",
type: "error"
});
console.error(error);
} }
createNotification({
text: isProtectedBranch
? "Requested changes have been sent for review"
: "Changes saved successfully",
type: "success"
});
}; };
const { const {
@@ -209,48 +209,40 @@ 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 = { id: folderId,
id: folderId, resourceType: "folder",
resourceType: "folder", type: PendingAction.Create,
type: PendingAction.Create, folderName,
folderName, description: description || undefined,
description: description || undefined, parentPath: secretPath,
parentPath: secretPath, timestamp: Date.now()
timestamp: Date.now() };
};
addPendingChange(pendingFolderCreate, { addPendingChange(pendingFolderCreate, {
projectId,
environment,
secretPath
});
handlePopUpClose("addFolder");
return;
}
await createFolder({
name: folderName,
path: secretPath,
environment,
projectId, projectId,
description environment,
secretPath
}); });
handlePopUpClose("addFolder"); handlePopUpClose("addFolder");
createNotification({ return;
type: "success",
text: "Successfully created folder"
});
} catch (error) {
console.log(error);
createNotification({
type: "error",
text: "Failed to create folder"
});
} }
await createFolder({
name: folderName,
path: secretPath,
environment,
projectId,
description
});
handlePopUpClose("addFolder");
createNotification({
type: "success",
text: "Successfully created folder"
});
}; };
const handleSecretDownload = async () => { const handleSecretDownload = async () => {
@@ -323,26 +315,18 @@ 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, environment,
environment, secrets: bulkDeletedSecrets.map(({ key }) => ({ secretKey: key, type: SecretType.Shared }))
secrets: bulkDeletedSecrets.map(({ key }) => ({ secretKey: key, type: SecretType.Shared })) });
}); resetSelectedSecret();
resetSelectedSecret(); handlePopUpClose("bulkDeleteSecrets");
handlePopUpClose("bulkDeleteSecrets"); createNotification({
createNotification({ 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,35 +662,23 @@ 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, secretPath,
secretPath, vaultNamespace: namespace,
vaultNamespace: namespace, vaultSecretPath: vaultPath
vaultSecretPath: vaultPath });
});
if (result.status === VaultImportStatus.ApprovalRequired) {
createNotification({
type: "info",
text: "Secret change request created successfully. Awaiting approval."
});
} else {
createNotification({
type: "success",
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.";
if (result.status === VaultImportStatus.ApprovalRequired) {
createNotification({ createNotification({
type: "error", type: "info",
text: errorMessage text: "Secret change request created successfully. Awaiting approval."
});
} else {
createNotification({
type: "success",
text: "Successfully imported secrets from HashiCorp Vault"
}); });
} }
}; };
@@ -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,25 +110,18 @@ 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, name,
name, path: secretPath,
path: secretPath, defaultTTL,
defaultTTL, projectSlug,
projectSlug, environmentSlug: environment.slug,
environmentSlug: environment.slug, usernameTemplate:
usernameTemplate: !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,26 +165,19 @@ 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 }, maxTTL,
maxTTL, name,
name, path: secretPath,
path: secretPath, defaultTTL,
defaultTTL, projectSlug,
projectSlug, environmentSlug: environment.slug,
environmentSlug: environment.slug, usernameTemplate:
usernameTemplate: !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,34 +111,27 @@ 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: { type: DynamicSecretProviders.AzureEntraId,
type: DynamicSecretProviders.AzureEntraId, inputs: {
inputs: { userId: user.id,
userId: user.id, tenantId: provider.tenantId,
tenantId: provider.tenantId, email: user.email,
email: user.email, applicationId: provider.applicationId,
applicationId: provider.applicationId, clientSecret: provider.clientSecret
clientSecret: provider.clientSecret }
} },
}, maxTTL,
maxTTL, name: `${name}-${user.name}`,
name: `${name}-${user.name}`, path: secretPath,
path: secretPath, defaultTTL,
defaultTTL, projectSlug,
projectSlug, environmentSlug: environment.slug
environmentSlug: environment.slug
});
}); });
onCompleted(); });
} catch { onCompleted();
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,29 +170,22 @@ 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, inputs: { ...provider, masterDatabase: "master" }
inputs: { ...provider, masterDatabase: "master" } },
}, maxTTL,
maxTTL, name,
name, path: secretPath,
path: secretPath, defaultTTL,
defaultTTL, projectSlug,
projectSlug, environmentSlug: environment.slug,
environmentSlug: environment.slug, metadata,
metadata, usernameTemplate:
usernameTemplate: !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,25 +111,18 @@ 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, name,
name, path: secretPath,
path: secretPath, defaultTTL,
defaultTTL, projectSlug,
projectSlug, environmentSlug: environment.slug,
environmentSlug: environment.slug, usernameTemplate:
usernameTemplate: !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,25 +385,18 @@ 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, name,
name, path: secretPath,
path: secretPath, defaultTTL,
defaultTTL, projectSlug,
projectSlug, environmentSlug: environment.slug,
environmentSlug: environment.slug, usernameTemplate:
usernameTemplate: !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,25 +130,18 @@ 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, name,
name, path: secretPath,
path: secretPath, defaultTTL,
defaultTTL, projectSlug,
projectSlug, environmentSlug: environment.slug,
environmentSlug: environment.slug, usernameTemplate:
usernameTemplate: !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,28 +82,21 @@ 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, inputs: {
inputs: { ...provider
...provider }
} },
}, maxTTL,
maxTTL, name,
name, path: secretPath,
path: secretPath, defaultTTL,
defaultTTL, projectSlug,
projectSlug, 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,27 +70,20 @@ 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, inputs: {
inputs: { ...provider
...provider }
} },
}, defaultTTL: "1h", // Github is limited to 1 hour tokens
defaultTTL: "1h", // Github is limited to 1 hour tokens name,
name, path: secretPath,
path: secretPath, projectSlug,
projectSlug, environmentSlug: environment.slug
environmentSlug: environment.slug });
}); onCompleted();
onCompleted();
} catch {
createNotification({
type: "error",
text: "Failed to create dynamic secret"
});
}
}; };
return ( return (
@@ -283,33 +283,26 @@ 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: { type: DynamicSecretProviders.Kubernetes,
type: DynamicSecretProviders.Kubernetes, inputs: {
inputs: { ...provider,
...provider, url: provider.url || undefined
url: provider.url || undefined }
} },
}, maxTTL: rest.maxTTL,
maxTTL: rest.maxTTL, name: rest.name,
name: rest.name, path: secretPath,
path: secretPath, defaultTTL: rest.defaultTTL,
defaultTTL: rest.defaultTTL, projectSlug,
projectSlug, environmentSlug: rest.environment.slug,
environmentSlug: rest.environment.slug, usernameTemplate:
usernameTemplate: !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,
@@ -139,25 +138,18 @@ 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, name,
name, path: secretPath,
path: secretPath, defaultTTL,
defaultTTL, projectSlug,
projectSlug, usernameTemplate:
usernameTemplate: !usernameTemplate || isDefaultUsernameTemplate ? undefined : usernameTemplate,
!usernameTemplate || isDefaultUsernameTemplate ? undefined : usernameTemplate, 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,25 +142,18 @@ 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, name,
name, path: secretPath,
path: secretPath, defaultTTL,
defaultTTL, projectSlug,
projectSlug, environmentSlug: environment.slug,
environmentSlug: environment.slug, usernameTemplate:
usernameTemplate: !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,32 +112,25 @@ 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, inputs: {
inputs: { ...provider,
...provider, port: provider?.port ? provider.port : undefined,
port: provider?.port ? provider.port : undefined, roles: provider.roles.map((el) => el.roleName)
roles: provider.roles.map((el) => el.roleName) }
} },
}, maxTTL,
maxTTL, name,
name, path: secretPath,
path: secretPath, defaultTTL,
defaultTTL, projectSlug,
projectSlug, environmentSlug: environment.slug,
environmentSlug: environment.slug, usernameTemplate:
usernameTemplate: !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,25 +120,18 @@ 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, name,
name, path: secretPath,
path: secretPath, defaultTTL,
defaultTTL, projectSlug,
projectSlug, environmentSlug: environment.slug,
environmentSlug: environment.slug, usernameTemplate:
usernameTemplate: !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,26 +103,19 @@ 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 }, maxTTL,
maxTTL, name,
name, path: secretPath,
path: secretPath, defaultTTL,
defaultTTL, projectSlug,
projectSlug, environmentSlug: environment.slug,
environmentSlug: environment.slug, usernameTemplate:
usernameTemplate: !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,26 +104,19 @@ 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 }, maxTTL,
maxTTL, name,
name, path: secretPath,
path: secretPath, defaultTTL,
defaultTTL, projectSlug,
projectSlug, environmentSlug: environment.slug,
environmentSlug: environment.slug, usernameTemplate:
usernameTemplate: !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,26 +104,19 @@ 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 }, maxTTL,
maxTTL, name,
name, path: secretPath,
path: secretPath, defaultTTL,
defaultTTL, projectSlug,
projectSlug, usernameTemplate:
usernameTemplate: !usernameTemplate || isDefaultUsernameTemplate ? undefined : usernameTemplate,
!usernameTemplate || isDefaultUsernameTemplate ? undefined : usernameTemplate, 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,26 +101,19 @@ 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 }, maxTTL,
maxTTL, name,
name, path: secretPath,
path: secretPath, defaultTTL,
defaultTTL, projectSlug,
projectSlug, environmentSlug: environment.slug,
environmentSlug: environment.slug, usernameTemplate:
usernameTemplate: !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,26 +214,19 @@ 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, name,
name, path: secretPath,
path: secretPath, defaultTTL,
defaultTTL, projectSlug,
projectSlug, environmentSlug: environment.slug,
environmentSlug: environment.slug, metadata,
metadata, usernameTemplate:
usernameTemplate: !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,23 +99,16 @@ 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", name,
name, path: secretPath,
path: secretPath, defaultTTL: "1m",
defaultTTL: "1m", projectSlug,
projectSlug, 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,26 +144,19 @@ 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 }, maxTTL,
maxTTL, name,
name, path: secretPath,
path: secretPath, defaultTTL,
defaultTTL, projectSlug,
projectSlug, environmentSlug: environment.slug,
environmentSlug: environment.slug, usernameTemplate:
usernameTemplate: !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,30 +441,22 @@ 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, path: secretPath,
path: secretPath, ttl,
ttl, dynamicSecretName,
dynamicSecretName, config: {
config: { namespace: namespace || undefined
namespace: namespace || undefined },
}, provider
provider });
});
createNotification({ createNotification({
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,29 +582,21 @@ 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, path: secretPath,
path: secretPath, ttl,
ttl, dynamicSecretName,
dynamicSecretName, provider
provider });
});
createNotification({ createNotification({
type: "success", type: "success",
text: "Successfully leased dynamic secret" text: "Successfully leased dynamic secret"
}); });
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,31 +69,23 @@ 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; };
}; await deleteDynamicSecretLease.mutateAsync({
await deleteDynamicSecretLease.mutateAsync({ environmentSlug: environment,
environmentSlug: environment, projectSlug,
projectSlug, path: secretPath,
path: secretPath, dynamicSecretName,
dynamicSecretName, leaseId,
leaseId, isForced
isForced });
}); handlePopUpClose("deleteSecret");
handlePopUpClose("deleteSecret"); createNotification({
createNotification({ 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,29 +54,21 @@ 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; };
}; await deleteDynamicSecret.mutateAsync({
await deleteDynamicSecret.mutateAsync({ environmentSlug: environment,
environmentSlug: environment, projectSlug,
projectSlug, path: secretPath,
path: secretPath, name,
name, isForced
isForced });
}); handlePopUpClose("deleteDynamicSecret");
handlePopUpClose("deleteDynamicSecret"); createNotification({
createNotification({ 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,31 +101,24 @@ 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, projectSlug,
projectSlug, environmentSlug: environment,
environmentSlug: environment, data: {
data: { maxTTL: maxTTL || undefined,
maxTTL: maxTTL || undefined, defaultTTL,
defaultTTL, inputs,
inputs, newName: newName === dynamicSecret.name ? undefined : newName,
newName: newName === dynamicSecret.name ? undefined : newName, usernameTemplate: !usernameTemplate || isDefaultUsernameTemplate ? null : usernameTemplate
usernameTemplate: !usernameTemplate || isDefaultUsernameTemplate ? null : usernameTemplate }
} });
}); onClose();
onClose(); createNotification({
createNotification({ 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,31 +141,24 @@ 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, projectSlug,
projectSlug, environmentSlug: environment,
environmentSlug: environment, data: {
data: { maxTTL: maxTTL || undefined,
maxTTL: maxTTL || undefined, defaultTTL,
defaultTTL, inputs,
inputs, newName: newName === dynamicSecret.name ? undefined : newName,
newName: newName === dynamicSecret.name ? undefined : newName, usernameTemplate: !usernameTemplate || isDefaultUsernameTemplate ? null : usernameTemplate
usernameTemplate: !usernameTemplate || isDefaultUsernameTemplate ? null : usernameTemplate }
} });
}); onClose();
onClose(); createNotification({
createNotification({ 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,30 +76,23 @@ 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, projectSlug,
projectSlug, environmentSlug: environment,
environmentSlug: environment, data: {
data: { maxTTL: maxTTL || undefined,
maxTTL: maxTTL || undefined, defaultTTL,
defaultTTL, newName: newName === dynamicSecret.name ? undefined : newName,
newName: newName === dynamicSecret.name ? undefined : newName, inputs
inputs }
} });
}); onClose();
onClose(); createNotification({
createNotification({ 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,33 +162,26 @@ 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, environmentSlug: environment,
environmentSlug: environment, path: secretPath,
path: secretPath, name: dynamicSecret.name,
name: dynamicSecret.name, data: {
data: { maxTTL: maxTTL || undefined,
maxTTL: maxTTL || undefined, defaultTTL,
defaultTTL, inputs: inputs ? { ...inputs, masterDatabase: "master" } : undefined,
inputs: inputs ? { ...inputs, masterDatabase: "master" } : undefined, newName: newName === dynamicSecret.name ? undefined : newName,
newName: newName === dynamicSecret.name ? undefined : newName, metadata,
metadata, usernameTemplate: !usernameTemplate || isDefaultUsernameTemplate ? null : usernameTemplate
usernameTemplate: !usernameTemplate || isDefaultUsernameTemplate ? null : usernameTemplate }
} });
}); onClose();
onClose(); createNotification({
createNotification({ 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,31 +103,24 @@ 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, projectSlug,
projectSlug, environmentSlug: environment,
environmentSlug: environment, data: {
data: { maxTTL: maxTTL || undefined,
maxTTL: maxTTL || undefined, defaultTTL,
defaultTTL, inputs,
inputs, newName: newName === dynamicSecret.name ? undefined : newName,
newName: newName === dynamicSecret.name ? undefined : newName, usernameTemplate: !usernameTemplate || isDefaultUsernameTemplate ? null : usernameTemplate
usernameTemplate: !usernameTemplate || isDefaultUsernameTemplate ? null : usernameTemplate }
} });
}); onClose();
onClose(); createNotification({
createNotification({ 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,37 +386,30 @@ export const EditDynamicSecretCouchbaseForm = ({
})() })()
: transformedInputs; : transformedInputs;
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: { defaultTTL,
defaultTTL, maxTTL: maxTTL || undefined,
maxTTL: maxTTL || undefined, newName: newName === dynamicSecret.name ? undefined : newName,
newName: newName === dynamicSecret.name ? undefined : newName, metadata,
metadata, usernameTemplate:
usernameTemplate: !usernameTemplate || usernameTemplate === "{{randomUsername}}"
!usernameTemplate || usernameTemplate === "{{randomUsername}}" ? undefined
? undefined : usernameTemplate,
: usernameTemplate, inputs: finalInputs
inputs: finalInputs }
} });
});
createNotification({ createNotification({
type: "success", type: "success",
text: "Successfully updated dynamic secret" text: "Successfully updated dynamic secret"
}); });
onClose(); onClose();
} catch (err) {
createNotification({
type: "error",
text: `Failed to update dynamic secret: ${err}`
});
}
}; };
return ( return (
@@ -123,31 +123,24 @@ 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, projectSlug,
projectSlug, environmentSlug: environment,
environmentSlug: environment, data: {
data: { maxTTL: maxTTL || undefined,
maxTTL: maxTTL || undefined, defaultTTL,
defaultTTL, inputs,
inputs, newName: newName === dynamicSecret.name ? undefined : newName,
newName: newName === dynamicSecret.name ? undefined : newName, usernameTemplate: !usernameTemplate || isDefaultUsernameTemplate ? null : usernameTemplate
usernameTemplate: !usernameTemplate || isDefaultUsernameTemplate ? null : usernameTemplate }
} });
}); onClose();
onClose(); createNotification({
createNotification({ 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,30 +77,23 @@ 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, projectSlug,
projectSlug, environmentSlug: environment,
environmentSlug: environment, data: {
data: { maxTTL: maxTTL || undefined,
maxTTL: maxTTL || undefined, defaultTTL,
defaultTTL, inputs,
inputs, newName: newName === dynamicSecret.name ? undefined : newName
newName: newName === dynamicSecret.name ? undefined : newName }
} });
}); onClose();
onClose(); createNotification({
createNotification({ 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,28 +61,21 @@ 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, projectSlug,
projectSlug, environmentSlug: environment,
environmentSlug: environment, data: {
data: { inputs,
inputs, newName: newName === dynamicSecret.name ? undefined : newName
newName: newName === dynamicSecret.name ? undefined : newName }
} });
}); onClose();
onClose(); createNotification({
createNotification({ 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,38 +189,29 @@ 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, projectSlug,
projectSlug, environmentSlug: environment,
environmentSlug: environment, data: {
data: { inputs: {
inputs: { ...formData.inputs,
...formData.inputs, url: formData.inputs.url || undefined
url: formData.inputs.url || undefined },
}, newName: formData.newName === dynamicSecret.name ? undefined : formData.newName,
newName: formData.newName === dynamicSecret.name ? undefined : formData.newName, defaultTTL: formData.defaultTTL,
defaultTTL: formData.defaultTTL, maxTTL: formData.maxTTL,
maxTTL: formData.maxTTL, usernameTemplate:
usernameTemplate: !formData.usernameTemplate || isDefaultUsernameTemplate ? null : formData.usernameTemplate
!formData.usernameTemplate || isDefaultUsernameTemplate }
? null });
: formData.usernameTemplate
}
});
onClose(); onClose();
createNotification({ createNotification({
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,31 +119,24 @@ 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, projectSlug,
projectSlug, environmentSlug: environment,
environmentSlug: environment, data: {
data: { maxTTL: maxTTL || undefined,
maxTTL: maxTTL || undefined, defaultTTL,
defaultTTL, inputs,
inputs, newName: newName === dynamicSecret.name ? undefined : newName,
newName: newName === dynamicSecret.name ? undefined : newName, usernameTemplate: !usernameTemplate || isDefaultUsernameTemplate ? null : usernameTemplate
usernameTemplate: !usernameTemplate || isDefaultUsernameTemplate ? null : usernameTemplate }
} });
}); onClose();
onClose(); createNotification({
createNotification({ 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,31 +142,24 @@ 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, projectSlug,
projectSlug, environmentSlug: environment,
environmentSlug: environment, data: {
data: { maxTTL: maxTTL || undefined,
maxTTL: maxTTL || undefined, defaultTTL,
defaultTTL, inputs,
inputs, newName: newName === dynamicSecret.name ? undefined : newName,
newName: newName === dynamicSecret.name ? undefined : newName, usernameTemplate: !usernameTemplate || isDefaultUsernameTemplate ? null : usernameTemplate
usernameTemplate: !usernameTemplate || isDefaultUsernameTemplate ? null : usernameTemplate }
} });
}); onClose();
onClose(); createNotification({
createNotification({ 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,36 +108,28 @@ 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, projectSlug,
projectSlug, environmentSlug: environment,
environmentSlug: environment, data: {
data: { maxTTL: maxTTL || undefined,
maxTTL: maxTTL || undefined, defaultTTL,
defaultTTL, inputs: {
inputs: { ...inputs,
...inputs, 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 || isDefaultUsernameTemplate ? null : usernameTemplate,
usernameTemplate: newName: newName === dynamicSecret.name ? undefined : newName
!usernameTemplate || isDefaultUsernameTemplate ? null : usernameTemplate, }
newName: newName === dynamicSecret.name ? undefined : newName });
} onClose();
}); createNotification({
onClose(); type: "success",
createNotification({ text: "Successfully updated dynamic secret"
type: "success", });
text: "Successfully updated dynamic secret"
});
} catch {
createNotification({
type: "error",
text: "Failed to update dynamic secret"
});
}
}; };
return ( return (
@@ -100,31 +100,24 @@ 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, projectSlug,
projectSlug, environmentSlug: environment,
environmentSlug: environment, data: {
data: { maxTTL: maxTTL || undefined,
maxTTL: maxTTL || undefined, defaultTTL,
defaultTTL, inputs,
inputs, newName: newName === dynamicSecret.name ? undefined : newName,
newName: newName === dynamicSecret.name ? undefined : newName, usernameTemplate: !usernameTemplate || isDefaultUsernameTemplate ? null : usernameTemplate
usernameTemplate: !usernameTemplate || isDefaultUsernameTemplate ? null : usernameTemplate }
} });
}); onClose();
onClose(); createNotification({
createNotification({ 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,32 +102,24 @@ 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 || isDefaultUsernameTemplate ? null : usernameTemplate,
usernameTemplate: maxTTL: maxTTL || undefined,
!usernameTemplate || isDefaultUsernameTemplate ? null : usernameTemplate, defaultTTL,
maxTTL: maxTTL || undefined, inputs,
defaultTTL, newName: newName === dynamicSecret.name ? undefined : newName
inputs, }
newName: newName === dynamicSecret.name ? undefined : newName });
} onClose();
}); createNotification({
onClose(); type: "success",
createNotification({ text: "Successfully updated dynamic secret"
type: "success", });
text: "Successfully updated dynamic secret"
});
} catch {
createNotification({
type: "error",
text: "Failed to update dynamic secret"
});
}
}; };
return ( return (
@@ -101,31 +101,24 @@ 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, projectSlug,
projectSlug, environmentSlug: environment,
environmentSlug: environment, data: {
data: { maxTTL: maxTTL || undefined,
maxTTL: maxTTL || undefined, defaultTTL,
defaultTTL, inputs,
inputs, newName: newName === dynamicSecret.name ? undefined : newName,
newName: newName === dynamicSecret.name ? undefined : newName, usernameTemplate: !usernameTemplate || isDefaultUsernameTemplate ? null : usernameTemplate
usernameTemplate: !usernameTemplate || isDefaultUsernameTemplate ? null : usernameTemplate }
} });
}); onClose();
onClose(); createNotification({
createNotification({ 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,31 +101,24 @@ 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, projectSlug,
projectSlug, environmentSlug: environment,
environmentSlug: environment, data: {
data: { maxTTL: maxTTL || undefined,
maxTTL: maxTTL || undefined, defaultTTL,
defaultTTL, inputs,
inputs, newName: newName === dynamicSecret.name ? undefined : newName,
newName: newName === dynamicSecret.name ? undefined : newName, usernameTemplate: !usernameTemplate || isDefaultUsernameTemplate ? null : usernameTemplate
usernameTemplate: !usernameTemplate || isDefaultUsernameTemplate ? null : usernameTemplate }
} });
}); onClose();
onClose(); createNotification({
createNotification({ 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,32 +97,25 @@ 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, path: secretPath,
path: secretPath, projectSlug,
projectSlug, environmentSlug: environment,
environmentSlug: environment, data: {
data: { maxTTL: maxTTL || undefined,
maxTTL: maxTTL || undefined, defaultTTL,
defaultTTL, inputs,
inputs, newName: newName === dynamicSecret.name ? undefined : newName,
newName: newName === dynamicSecret.name ? undefined : newName, usernameTemplate: !usernameTemplate || isDefaultUsernameTemplate ? null : usernameTemplate
usernameTemplate: !usernameTemplate || isDefaultUsernameTemplate ? null : usernameTemplate }
} });
}); onClose();
onClose(); createNotification({
createNotification({ 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,36 +167,29 @@ 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, path: secretPath,
path: secretPath, projectSlug,
projectSlug, environmentSlug: environment,
environmentSlug: environment, data: {
data: { maxTTL: maxTTL || undefined,
maxTTL: maxTTL || undefined, defaultTTL,
defaultTTL, inputs: {
inputs: { ...inputs,
...inputs, gatewayId: isGatewayInActive ? null : inputs.gatewayId
gatewayId: isGatewayInActive ? null : inputs.gatewayId },
}, newName: newName === dynamicSecret.name ? undefined : newName,
newName: newName === dynamicSecret.name ? undefined : newName, metadata,
metadata, usernameTemplate: !usernameTemplate || isDefaultUsernameTemplate ? null : usernameTemplate
usernameTemplate: !usernameTemplate || isDefaultUsernameTemplate ? null : usernameTemplate }
} });
}); onClose();
onClose(); createNotification({
createNotification({ 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,28 +87,21 @@ 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, projectSlug,
projectSlug, environmentSlug: environment,
environmentSlug: environment, data: {
data: { inputs,
inputs, newName: newName === dynamicSecret.name ? undefined : newName
newName: newName === dynamicSecret.name ? undefined : newName }
} });
}); onClose();
onClose(); createNotification({
createNotification({ 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,34 +146,28 @@ 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,
projectSlug, projectSlug,
environmentSlug: environment, environmentSlug: environment,
data: { data: {
maxTTL: maxTTL || undefined, maxTTL: maxTTL || undefined,
defaultTTL, defaultTTL,
inputs: { inputs: {
...inputs, ...inputs,
gatewayId: isGatewayInActive ? null : inputs.gatewayId gatewayId: isGatewayInActive ? null : inputs.gatewayId
}, },
newName: newName === dynamicSecret.name ? undefined : newName, newName: newName === dynamicSecret.name ? undefined : newName,
usernameTemplate: !usernameTemplate || isDefaultUsernameTemplate ? null : usernameTemplate usernameTemplate: !usernameTemplate || isDefaultUsernameTemplate ? null : usernameTemplate
} }
}); });
onClose(); onClose();
createNotification({ createNotification({
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,27 +64,19 @@ 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, path: secretPath,
path: secretPath, ttl,
ttl, dynamicSecretName,
dynamicSecretName, leaseId
leaseId });
}); onClose();
onClose(); createNotification({
createNotification({ 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,73 +69,65 @@ 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;
if (isBatchMode) { if (isBatchMode) {
const isEditingPendingCreation = isPending && pendingAction === PendingAction.Create; const isEditingPendingCreation = isPending && pendingAction === PendingAction.Create;
if (isEditingPendingCreation) { if (isEditingPendingCreation) {
const updatedCreate: PendingFolderCreate = { const updatedCreate: PendingFolderCreate = {
id: folderId, id: folderId,
type: PendingAction.Create, type: PendingAction.Create,
folderName: newFolderName, folderName: newFolderName,
description: newFolderDescription || undefined, description: newFolderDescription || undefined,
parentPath: secretPath, parentPath: secretPath,
timestamp: Date.now(), timestamp: Date.now(),
resourceType: "folder" resourceType: "folder"
}; };
addPendingChange(updatedCreate, { addPendingChange(updatedCreate, {
projectId, projectId,
environment, environment,
secretPath secretPath
}); });
} else { } else {
const updateChange: PendingFolderUpdate = { const updateChange: PendingFolderUpdate = {
id: folderId, id: folderId,
type: PendingAction.Update, type: PendingAction.Update,
originalFolderName: oldFolderName || "", originalFolderName: oldFolderName || "",
folderName: newFolderName, folderName: newFolderName,
originalDescription: oldFolderDescription, originalDescription: oldFolderDescription,
description: newFolderDescription || undefined, description: newFolderDescription || undefined,
timestamp: Date.now(), timestamp: Date.now(),
resourceType: "folder" resourceType: "folder"
}; };
addPendingChange(updateChange, { addPendingChange(updateChange, {
projectId, projectId,
environment, environment,
secretPath secretPath
}); });
}
handlePopUpClose("updateFolder");
return;
} }
await updateFolder({
folderId,
name: newFolderName,
path: secretPath,
environment,
projectId,
description: newFolderDescription
});
handlePopUpClose("updateFolder"); handlePopUpClose("updateFolder");
createNotification({ return;
type: "success",
text: "Successfully saved folder"
});
} catch (error) {
console.log(error);
createNotification({
type: "error",
text: "Failed to save folder"
});
} }
await updateFolder({
folderId,
name: newFolderName,
path: secretPath,
environment,
projectId,
description: newFolderDescription
});
handlePopUpClose("updateFolder");
createNotification({
type: "success",
text: "Successfully saved folder"
});
}; };
const handleDeletePending = (id: string) => { const handleDeletePending = (id: string) => {
@@ -147,48 +139,40 @@ 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) {
const pendingFolderDelete: PendingFolderDelete = { const pendingFolderDelete: PendingFolderDelete = {
id: folderData.id, id: folderData.id,
folderName: folderData.name, folderName: folderData.name,
folderPath: secretPath, folderPath: secretPath,
resourceType: "folder", resourceType: "folder",
type: PendingAction.Delete, type: PendingAction.Delete,
timestamp: Date.now() timestamp: Date.now()
}; };
addPendingChange(pendingFolderDelete, { addPendingChange(pendingFolderDelete, {
projectId, projectId,
environment,
secretPath
});
handlePopUpClose("deleteFolder");
return;
}
await deleteFolder({
folderId: folderData.id,
path: secretPath,
environment, environment,
projectId secretPath
}); });
handlePopUpClose("deleteFolder"); handlePopUpClose("deleteFolder");
createNotification({ return;
type: "success",
text: "Successfully deleted folder"
});
} catch (error) {
console.log(error);
createNotification({
type: "error",
text: "Failed to delete folder"
});
} }
await deleteFolder({
folderId: folderData.id,
path: secretPath,
environment,
projectId
});
handlePopUpClose("deleteFolder");
createNotification({
type: "success",
text: "Successfully deleted folder"
});
}; };
const handleFolderClick = (name: string, isPending?: boolean) => { const handleFolderClick = (name: string, isPending?: boolean) => {
@@ -118,24 +118,16 @@ 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, path: secretPath,
path: secretPath, projectId: currentProject?.id || ""
projectId: currentProject?.id || "" });
}); createNotification({
createNotification({ 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,25 +147,17 @@ 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, path: secretPath,
path: secretPath, id: secretImportId
id: secretImportId });
}); handlePopUpClose("deleteSecretImport");
handlePopUpClose("deleteSecretImport"); createNotification({
createNotification({ 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,53 +199,37 @@ 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, recipients: data.recipients?.map((r) => r.value) || [],
recipients: data.recipients?.map((r) => r.value) || [], secretId,
secretId, nextReminderDate: data.nextReminderDate,
nextReminderDate: data.nextReminderDate, fromDate: data.fromDate
fromDate: data.fromDate });
});
invalidateQueries(); invalidateQueries();
createNotification({ createNotification({
type: "success", type: "success",
text: `Successfully ${isEditMode ? "updated" : "created"} secret reminder` text: `Successfully ${isEditMode ? "updated" : "created"} secret reminder`
}); });
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(); onOpenChange();
onOpenChange();
createNotification({ createNotification({
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,25 +128,17 @@ export const SnapshotView = ({
}); });
return; return;
} }
try { await performRollback({
await performRollback({ projectId,
projectId, snapshotId: snapshotData.id,
snapshotId: snapshotData.id, environment,
environment, directory: secretPath
directory: secretPath });
}); createNotification({
createNotification({ text: "Successfully rollback secrets",
text: "Successfully rollback secrets", 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,27 +53,19 @@ 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, customProvider,
customProvider, secretPath: wizardData.current.output.secretPath,
secretPath: wizardData.current.output.secretPath, environment: wizardData.current.output.environment,
environment: wizardData.current.output.environment, interval: wizardData.current.output.interval,
interval: wizardData.current.output.interval, inputs: wizardData.current.input,
inputs: wizardData.current.input, outputs: wizardData.current.output.secrets
outputs: wizardData.current.output.secrets });
}); 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 (