From 8a7774f9acecbcf94334b3a75f57387c06abc1e5 Mon Sep 17 00:00:00 2001 From: Akhil Mohan Date: Tue, 26 Mar 2024 14:10:25 +0530 Subject: [PATCH] feat(ui): updated api changes made --- .../src/hooks/api/dynamicSecret/mutation.ts | 16 +++++----- .../src/hooks/api/dynamicSecret/queries.ts | 30 +++++++++---------- frontend/src/hooks/api/dynamicSecret/types.ts | 22 +++++++------- .../hooks/api/dynamicSecretLease/mutation.ts | 12 ++++---- .../hooks/api/dynamicSecretLease/queries.ts | 16 +++++----- .../src/hooks/api/dynamicSecretLease/types.ts | 16 +++++----- frontend/src/hooks/api/subscriptions/types.ts | 17 ++++++----- .../views/SecretMainPage/SecretMainPage.tsx | 2 +- .../SqlDatabaseInputForm.tsx | 24 +++++++-------- .../CreateDynamicSecretLease.tsx | 8 ++--- .../DynamicSecretLease.tsx | 14 ++++----- .../DynamicSecretListView.tsx | 22 +++++++------- .../EditDynamicSecretForm.tsx | 8 ++--- .../EditDynamicSecretSqlProviderForm.tsx | 21 +++++++------ .../RenewDynamicSecretLease.tsx | 8 ++--- 15 files changed, 120 insertions(+), 116 deletions(-) diff --git a/frontend/src/hooks/api/dynamicSecret/mutation.ts b/frontend/src/hooks/api/dynamicSecret/mutation.ts index 11021554d..5f41e38f5 100644 --- a/frontend/src/hooks/api/dynamicSecret/mutation.ts +++ b/frontend/src/hooks/api/dynamicSecret/mutation.ts @@ -21,8 +21,8 @@ export const useCreateDynamicSecret = () => { ); return data.dynamicSecret; }, - onSuccess: (_, { path, environment, projectSlug }) => { - queryClient.invalidateQueries(dynamicSecretKeys.list({ path, projectSlug, environment })); + onSuccess: (_, { path, environmentSlug, projectSlug }) => { + queryClient.invalidateQueries(dynamicSecretKeys.list({ path, projectSlug, environmentSlug })); } }); }; @@ -33,13 +33,13 @@ export const useUpdateDynamicSecret = () => { return useMutation<{}, {}, TUpdateDynamicSecretDTO>({ mutationFn: async (dto) => { const { data } = await apiRequest.patch<{ dynamicSecret: TDynamicSecret }>( - `/api/v1/dynamic-secrets/${dto.slug}`, + `/api/v1/dynamic-secrets/${dto.name}`, dto ); return data.dynamicSecret; }, - onSuccess: (_, { path, environment, projectSlug }) => { - queryClient.invalidateQueries(dynamicSecretKeys.list({ path, projectSlug, environment })); + onSuccess: (_, { path, environmentSlug, projectSlug }) => { + queryClient.invalidateQueries(dynamicSecretKeys.list({ path, projectSlug, environmentSlug })); } }); }; @@ -50,13 +50,13 @@ export const useDeleteDynamicSecret = () => { return useMutation<{}, {}, TDeleteDynamicSecretDTO>({ mutationFn: async (dto) => { const { data } = await apiRequest.delete<{ dynamicSecret: TDynamicSecret }>( - `/api/v1/dynamic-secrets/${dto.slug}`, + `/api/v1/dynamic-secrets/${dto.name}`, { data: dto } ); return data.dynamicSecret; }, - onSuccess: (_, { path, environment, projectSlug }) => { - queryClient.invalidateQueries(dynamicSecretKeys.list({ path, projectSlug, environment })); + onSuccess: (_, { path, environmentSlug, projectSlug }) => { + queryClient.invalidateQueries(dynamicSecretKeys.list({ path, projectSlug, environmentSlug })); } }); }; diff --git a/frontend/src/hooks/api/dynamicSecret/queries.ts b/frontend/src/hooks/api/dynamicSecret/queries.ts index 8c40f19a4..37f851bed 100644 --- a/frontend/src/hooks/api/dynamicSecret/queries.ts +++ b/frontend/src/hooks/api/dynamicSecret/queries.ts @@ -7,25 +7,25 @@ import { TDetailsDynamicSecretDTO, TDynamicSecret, TListDynamicSecretDTO } from export const dynamicSecretKeys = { list: ({ projectSlug, - environment, + environmentSlug, path - }: Pick) => - [{ projectSlug, environment, path }, "dynamic-secrets"] as const, - details: ({ path, environment, projectSlug, slug }: TDetailsDynamicSecretDTO) => - [{ projectSlug, path, environment, slug }, "dynamic-secret-details"] as const + }: Pick) => + [{ projectSlug, environmentSlug, path }, "dynamic-secrets"] as const, + details: ({ path, environmentSlug, projectSlug, name }: TDetailsDynamicSecretDTO) => + [{ projectSlug, path, environmentSlug, name }, "dynamic-secret-details"] as const }; -export const useGetDynamicSecrets = ({ projectSlug, environment, path }: TListDynamicSecretDTO) => { +export const useGetDynamicSecrets = ({ projectSlug, environmentSlug, path }: TListDynamicSecretDTO) => { return useQuery({ - queryKey: dynamicSecretKeys.list({ path, environment, projectSlug }), - enabled: Boolean(projectSlug && environment && path), + queryKey: dynamicSecretKeys.list({ path, environmentSlug, projectSlug }), + enabled: Boolean(projectSlug && environmentSlug && path), queryFn: async () => { const { data } = await apiRequest.get<{ dynamicSecrets: TDynamicSecret[] }>( "/api/v1/dynamic-secrets", { params: { projectSlug, - environment, + environmentSlug, path } } @@ -38,20 +38,20 @@ export const useGetDynamicSecrets = ({ projectSlug, environment, path }: TListDy export const useGetDynamicSecretDetails = ({ projectSlug, - environment, + environmentSlug, path, - slug + name }: TDetailsDynamicSecretDTO) => { return useQuery({ - queryKey: dynamicSecretKeys.details({ path, environment, projectSlug, slug }), - enabled: Boolean(projectSlug && environment && path && slug), + queryKey: dynamicSecretKeys.details({ path, environmentSlug, projectSlug, name }), + enabled: Boolean(projectSlug && environmentSlug && path && name), queryFn: async () => { const { data } = await apiRequest.get<{ dynamicSecret: TDynamicSecret & { inputs: unknown }; - }>(`/api/v1/dynamic-secrets/${slug}`, { + }>(`/api/v1/dynamic-secrets/${name}`, { params: { projectSlug, - environment, + environmentSlug, path } }); diff --git a/frontend/src/hooks/api/dynamicSecret/types.ts b/frontend/src/hooks/api/dynamicSecret/types.ts index 1f4586e5a..27d3a756c 100644 --- a/frontend/src/hooks/api/dynamicSecret/types.ts +++ b/frontend/src/hooks/api/dynamicSecret/types.ts @@ -5,7 +5,7 @@ export enum DynamicSecretStatus { // TODO(akhilmhdh): When we switch to monorepo all the server api ts will be in a shared repo export type TDynamicSecret = { id: string; - slug: string; + name: string; type: DynamicSecretProviders; createdAt: string; updatedAt: string; @@ -45,17 +45,17 @@ export type TCreateDynamicSecretDTO = { defaultTTL: string; maxTTL?: string; path: string; - environment: string; - slug: string; + environmentSlug: string; + name: string; }; export type TUpdateDynamicSecretDTO = { - slug: string; + name: string; projectSlug: string; path: string; - environment: string; + environmentSlug: string; data: { - newSlug?: string; + newName?: string; defaultTTL?: string; maxTTL?: string | null; inputs?: unknown; @@ -65,20 +65,20 @@ export type TUpdateDynamicSecretDTO = { export type TListDynamicSecretDTO = { projectSlug: string; path: string; - environment: string; + environmentSlug: string; }; export type TDeleteDynamicSecretDTO = { projectSlug: string; path: string; - environment: string; - slug: string; + environmentSlug: string; + name: string; isForced?: boolean; }; export type TDetailsDynamicSecretDTO = { projectSlug: string; path: string; - environment: string; - slug: string; + environmentSlug: string; + name: string; }; diff --git a/frontend/src/hooks/api/dynamicSecretLease/mutation.ts b/frontend/src/hooks/api/dynamicSecretLease/mutation.ts index 679f73910..3ed2b75d9 100644 --- a/frontend/src/hooks/api/dynamicSecretLease/mutation.ts +++ b/frontend/src/hooks/api/dynamicSecretLease/mutation.ts @@ -25,9 +25,9 @@ export const useCreateDynamicSecretLease = () => { ); return data; }, - onSuccess: (_, { path, environment, projectSlug, slug }) => { + onSuccess: (_, { path, environmentSlug, projectSlug, dynamicSecretName }) => { queryClient.invalidateQueries( - dynamicSecretLeaseKeys.list({ path, projectSlug, environment, slug }) + dynamicSecretLeaseKeys.list({ path, projectSlug, environmentSlug, dynamicSecretName }) ); } }); @@ -44,9 +44,9 @@ export const useRenewDynamicSecretLease = () => { ); return data.lease; }, - onSuccess: (_, { path, environment, projectSlug, slug }) => { + onSuccess: (_, { path, environmentSlug, projectSlug, dynamicSecretName }) => { queryClient.invalidateQueries( - dynamicSecretLeaseKeys.list({ path, projectSlug, environment, slug }) + dynamicSecretLeaseKeys.list({ path, projectSlug, environmentSlug, dynamicSecretName }) ); } }); @@ -63,9 +63,9 @@ export const useRevokeDynamicSecretLease = () => { ); return data.lease; }, - onSuccess: (_, { path, environment, projectSlug, slug }) => { + onSuccess: (_, { path, environmentSlug, projectSlug, dynamicSecretName }) => { queryClient.invalidateQueries( - dynamicSecretLeaseKeys.list({ path, projectSlug, environment, slug }) + dynamicSecretLeaseKeys.list({ path, projectSlug, environmentSlug, dynamicSecretName }) ); } }); diff --git a/frontend/src/hooks/api/dynamicSecretLease/queries.ts b/frontend/src/hooks/api/dynamicSecretLease/queries.ts index a9dd46a64..9084098d1 100644 --- a/frontend/src/hooks/api/dynamicSecretLease/queries.ts +++ b/frontend/src/hooks/api/dynamicSecretLease/queries.ts @@ -5,27 +5,27 @@ import { apiRequest } from "@app/config/request"; import { TDynamicSecretLease, TListDynamicSecretLeaseDTO } from "./types"; export const dynamicSecretLeaseKeys = { - list: ({ projectSlug, environment, path, slug }: TListDynamicSecretLeaseDTO) => - [{ projectSlug, environment, path, slug }, "dynamic-secret-leases"] as const + list: ({ projectSlug, environmentSlug, path, dynamicSecretName }: TListDynamicSecretLeaseDTO) => + [{ projectSlug, environmentSlug, path, dynamicSecretName }, "dynamic-secret-leases"] as const }; export const useGetDynamicSecretLeases = ({ projectSlug, - environment, + environmentSlug, path, - slug, + dynamicSecretName, enabled = true }: TListDynamicSecretLeaseDTO) => { return useQuery({ - queryKey: dynamicSecretLeaseKeys.list({ path, environment, projectSlug, slug }), - enabled: Boolean(projectSlug && environment && path && slug && enabled), + queryKey: dynamicSecretLeaseKeys.list({ path, environmentSlug, projectSlug, dynamicSecretName }), + enabled: Boolean(projectSlug && environmentSlug && path && dynamicSecretName && enabled), queryFn: async () => { const { data } = await apiRequest.get<{ leases: TDynamicSecretLease[] }>( - `/api/v1/dynamic-secrets/${slug}/leases`, + `/api/v1/dynamic-secrets/${dynamicSecretName}/leases`, { params: { projectSlug, - environment, + environmentSlug, path } } diff --git a/frontend/src/hooks/api/dynamicSecretLease/types.ts b/frontend/src/hooks/api/dynamicSecretLease/types.ts index d38cea088..76bedc8b3 100644 --- a/frontend/src/hooks/api/dynamicSecretLease/types.ts +++ b/frontend/src/hooks/api/dynamicSecretLease/types.ts @@ -14,35 +14,35 @@ export type TDynamicSecretLease = { }; export type TCreateDynamicSecretLeaseDTO = { - slug: string; + dynamicSecretName: string; projectSlug: string; ttl?: string; path: string; - environment: string; + environmentSlug: string; }; export type TRenewDynamicSecretLeaseDTO = { leaseId: string; - slug: string; + dynamicSecretName: string; ttl?: string; projectSlug: string; path: string; - environment: string; + environmentSlug: string; }; export type TListDynamicSecretLeaseDTO = { - slug: string; + dynamicSecretName: string; projectSlug: string; path: string; - environment: string; + environmentSlug: string; enabled?: boolean; }; export type TRevokeDynamicSecretLeaseDTO = { leaseId: string; - slug: string; + dynamicSecretName: string; projectSlug: string; path: string; - environment: string; + environmentSlug: string; isForced?: boolean; }; diff --git a/frontend/src/hooks/api/subscriptions/types.ts b/frontend/src/hooks/api/subscriptions/types.ts index 97b287084..978de8578 100644 --- a/frontend/src/hooks/api/subscriptions/types.ts +++ b/frontend/src/hooks/api/subscriptions/types.ts @@ -3,6 +3,7 @@ export type SubscriptionPlan = { membersUsed: number; memberLimit: number; auditLogs: boolean; + dynamicSecret: boolean; auditLogsRetentionDays: number; customAlerts: boolean; customRateLimits: boolean; @@ -21,14 +22,14 @@ export type SubscriptionPlan = { scim: boolean; ldap: boolean; status: - | "incomplete" - | "incomplete_expired" - | "trialing" - | "active" - | "past_due" - | "canceled" - | "unpaid" - | null; + | "incomplete" + | "incomplete_expired" + | "trialing" + | "active" + | "past_due" + | "canceled" + | "unpaid" + | null; trial_end: number | null; has_used_trial: boolean; }; diff --git a/frontend/src/views/SecretMainPage/SecretMainPage.tsx b/frontend/src/views/SecretMainPage/SecretMainPage.tsx index a697c8975..fcb077512 100644 --- a/frontend/src/views/SecretMainPage/SecretMainPage.tsx +++ b/frontend/src/views/SecretMainPage/SecretMainPage.tsx @@ -141,7 +141,7 @@ export const SecretMainPage = () => { const { data: dynamicSecrets, isLoading: isDynamicSecretLoading } = useGetDynamicSecrets({ projectSlug, - environment, + environmentSlug: environment, path: secretPath }); diff --git a/frontend/src/views/SecretMainPage/components/ActionBar/CreateDynamicSecretForm/SqlDatabaseInputForm.tsx b/frontend/src/views/SecretMainPage/components/ActionBar/CreateDynamicSecretForm/SqlDatabaseInputForm.tsx index 69f9c8aca..81dd8a116 100644 --- a/frontend/src/views/SecretMainPage/components/ActionBar/CreateDynamicSecretForm/SqlDatabaseInputForm.tsx +++ b/frontend/src/views/SecretMainPage/components/ActionBar/CreateDynamicSecretForm/SqlDatabaseInputForm.tsx @@ -54,7 +54,9 @@ const formSchema = z.object({ if (valMs > 24 * 60 * 60 * 1000) ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be less than a day" }); }), - slug: z.string().toLowerCase() + name: z + .string() + .refine((val) => val.toLowerCase() === val, "Must be lowercase") }); type TForm = z.infer; @@ -92,18 +94,18 @@ export const SqlDatabaseInputForm = ({ const { createNotification } = useNotificationContext(); const createDynamicSecret = useCreateDynamicSecret(); - const handleCreateDynamicSecret = async ({ slug, maxTTL, provider, defaultTTL }: TForm) => { + const handleCreateDynamicSecret = async ({ name, maxTTL, provider, defaultTTL }: TForm) => { // wait till previous request is finished if (createDynamicSecret.isLoading) return; try { await createDynamicSecret.mutateAsync({ provider: { type: DynamicSecretProviders.SqlDatabase, inputs: provider }, maxTTL, - slug, + name, path: secretPath, defaultTTL, projectSlug, - environment + environmentSlug: environment }); onCompleted(); } catch (err) { @@ -122,7 +124,7 @@ export const SqlDatabaseInputForm = ({ (
-
Configuration
+
+ Configuration +
-
Service
+
Service
)} /> - + Modify SQL Statements diff --git a/frontend/src/views/SecretMainPage/components/DynamicSecretListView/CreateDynamicSecretLease.tsx b/frontend/src/views/SecretMainPage/components/DynamicSecretListView/CreateDynamicSecretLease.tsx index 3cb6f7c4b..552b2fb1f 100644 --- a/frontend/src/views/SecretMainPage/components/DynamicSecretListView/CreateDynamicSecretLease.tsx +++ b/frontend/src/views/SecretMainPage/components/DynamicSecretListView/CreateDynamicSecretLease.tsx @@ -77,7 +77,7 @@ type TForm = z.infer; type Props = { onClose: () => void; - slug: string; + dynamicSecretName: string; provider: DynamicSecretProviders; projectSlug: string; environment: string; @@ -87,7 +87,7 @@ type Props = { export const CreateDynamicSecretLease = ({ onClose, projectSlug, - slug, + dynamicSecretName, provider, secretPath, environment @@ -110,11 +110,11 @@ export const CreateDynamicSecretLease = ({ if (createDynamicSecretLease.isLoading) return; try { await createDynamicSecretLease.mutateAsync({ - environment, + environmentSlug: environment, projectSlug, path: secretPath, ttl, - slug + dynamicSecretName }); createNotification({ type: "success", diff --git a/frontend/src/views/SecretMainPage/components/DynamicSecretListView/DynamicSecretLease.tsx b/frontend/src/views/SecretMainPage/components/DynamicSecretListView/DynamicSecretLease.tsx index b8422d1f3..ae17e4851 100644 --- a/frontend/src/views/SecretMainPage/components/DynamicSecretListView/DynamicSecretLease.tsx +++ b/frontend/src/views/SecretMainPage/components/DynamicSecretListView/DynamicSecretLease.tsx @@ -34,7 +34,7 @@ import { DynamicSecretLeaseStatus } from "@app/hooks/api/dynamicSecretLease/type import { RenewDynamicSecretLease } from "./RenewDynamicSecretLease"; type Props = { - slug: string; + dynamicSecretName: string; projectSlug: string; environment: string; secretPath: string; @@ -44,7 +44,7 @@ type Props = { export const DynamicSecretLease = ({ projectSlug, - slug, + dynamicSecretName, environment, secretPath, onClickNewLease, @@ -56,9 +56,9 @@ export const DynamicSecretLease = ({ ] as const); const { data: leases, isLoading: isLeaseLoading } = useGetDynamicSecretLeases({ projectSlug, - environment, + environmentSlug: environment, path: secretPath, - slug + dynamicSecretName }); const { createNotification } = useNotificationContext(); @@ -71,10 +71,10 @@ export const DynamicSecretLease = ({ isForced?: boolean; }; await deleteDynamicSecretLease.mutateAsync({ - environment, + environmentSlug: environment, projectSlug, path: secretPath, - slug, + dynamicSecretName, leaseId, isForced }); @@ -226,7 +226,7 @@ export const DynamicSecretLease = ({ onClose={() => handlePopUpClose("renewSecret")} projectSlug={projectSlug} leaseId={(popUp.renewSecret?.data as { leaseId: string })?.leaseId} - slug={slug} + dynamicSecretName={dynamicSecretName} secretPath={secretPath} environment={environment} /> diff --git a/frontend/src/views/SecretMainPage/components/DynamicSecretListView/DynamicSecretListView.tsx b/frontend/src/views/SecretMainPage/components/DynamicSecretListView/DynamicSecretListView.tsx index 8f5c51ba2..cfab8bfc2 100644 --- a/frontend/src/views/SecretMainPage/components/DynamicSecretListView/DynamicSecretListView.tsx +++ b/frontend/src/views/SecretMainPage/components/DynamicSecretListView/DynamicSecretListView.tsx @@ -64,14 +64,14 @@ export const DynamicSecretListView = ({ const handleDynamicSecretDelete = async () => { try { - const { slug, isForced } = popUp.deleteDynamicSecret.data as TDynamicSecret & { + const { name, isForced } = popUp.deleteDynamicSecret.data as TDynamicSecret & { isForced?: boolean; }; await deleteDynamicSecret.mutateAsync({ - environment, + environmentSlug: environment, projectSlug, path: secretPath, - slug, + name, isForced }); handlePopUpClose("deleteDynamicSecret"); @@ -93,8 +93,8 @@ export const DynamicSecretListView = ({ {dynamicSecrets .sort((a, b) => sortDir === SortDir.ASC - ? a.slug.toLowerCase().localeCompare(b.slug.toLowerCase()) - : b.slug.toLowerCase().localeCompare(a.slug.toLowerCase()) + ? a.name.toLowerCase().localeCompare(b.name.toLowerCase()) + : b.name.toLowerCase().localeCompare(a.name.toLowerCase()) ) .map((secret) => { const isRevocking = secret.status === DynamicSecretStatus.Deleting; @@ -124,11 +124,11 @@ export const DynamicSecretListView = ({
- {secret.slug}{" "} + {secret.name} {formatProviderName(secret.type)} @@ -234,7 +234,7 @@ export const DynamicSecretListView = ({ onClose={() => handlePopUpClose("dynamicSecretLeases")} projectSlug={projectSlug} key={secret.id} - slug={secret.slug} + dynamicSecretName={secret.name} secretPath={secretPath} environment={environment} /> @@ -253,7 +253,7 @@ export const DynamicSecretListView = ({ } onClose={() => handlePopUpClose("createDynamicSecretLease")} projectSlug={projectSlug} - slug={(popUp.createDynamicSecretLease?.data as { slug: string })?.slug} + dynamicSecretName={(popUp.createDynamicSecretLease?.data as { name: string })?.name} secretPath={secretPath} environment={environment} /> @@ -267,7 +267,7 @@ export const DynamicSecretListView = ({ handlePopUpClose("updateDynamicSecret")} projectSlug={projectSlug} - slug={(popUp.updateDynamicSecret?.data as TDynamicSecret)?.slug} + dynamicSecretName={(popUp.updateDynamicSecret?.data as TDynamicSecret)?.name} secretPath={secretPath} environment={environment} /> @@ -275,7 +275,7 @@ export const DynamicSecretListView = ({ void; - slug: string; + dynamicSecretName: string; projectSlug: string; environment: string; secretPath: string; }; export const EditDynamicSecretForm = ({ - slug, + dynamicSecretName, environment, projectSlug, onClose, @@ -24,8 +24,8 @@ export const EditDynamicSecretForm = ({ const { data: dynamicSecretDetails, isLoading: isDynamicSecretLoading } = useGetDynamicSecretDetails({ projectSlug, - environment, - slug, + environmentSlug: environment, + name: dynamicSecretName, path: secretPath }); diff --git a/frontend/src/views/SecretMainPage/components/DynamicSecretListView/EditDynamicSecretForm/EditDynamicSecretSqlProviderForm.tsx b/frontend/src/views/SecretMainPage/components/DynamicSecretListView/EditDynamicSecretForm/EditDynamicSecretSqlProviderForm.tsx index 552620f1f..7a91e0d3e 100644 --- a/frontend/src/views/SecretMainPage/components/DynamicSecretListView/EditDynamicSecretForm/EditDynamicSecretSqlProviderForm.tsx +++ b/frontend/src/views/SecretMainPage/components/DynamicSecretListView/EditDynamicSecretForm/EditDynamicSecretSqlProviderForm.tsx @@ -57,7 +57,10 @@ const formSchema = z.object({ ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be less than a day" }); }) .nullable(), - newSlug: z.string().toLowerCase().optional() + newName: z + .string() + .refine((val) => val.toLowerCase() === val, "Must be lowercase") + .optional() }); type TForm = z.infer; @@ -85,7 +88,7 @@ export const EditDynamicSecretSqlProviderForm = ({ values: { defaultTTL: dynamicSecret.defaultTTL, maxTTL: dynamicSecret.maxTTL, - newSlug: dynamicSecret.slug, + newName: dynamicSecret.name, inputs: { ...(dynamicSecret.inputs as TForm["inputs"]) } @@ -94,31 +97,31 @@ export const EditDynamicSecretSqlProviderForm = ({ const { createNotification } = useNotificationContext(); const updateDynamicSecret = useUpdateDynamicSecret(); - const handleUpdateDynamicSecret = async ({ inputs, maxTTL, defaultTTL, newSlug }: TForm) => { + const handleUpdateDynamicSecret = async ({ inputs, maxTTL, defaultTTL, newName }: TForm) => { // wait till previous request is finished if (updateDynamicSecret.isLoading) return; try { await updateDynamicSecret.mutateAsync({ - slug: dynamicSecret.slug, + name: dynamicSecret.name, path: secretPath, projectSlug, - environment, + environmentSlug: environment, data: { maxTTL: maxTTL || undefined, defaultTTL, inputs, - newSlug: newSlug === dynamicSecret.slug ? undefined : newSlug + newName: newName === dynamicSecret.name ? undefined : newName } }); onClose(); createNotification({ type: "success", - text: "Successfully updated dynamic secret" + text: "Successfully update dynamic secret" }); } catch (err) { createNotification({ type: "error", - text: "Failed to create dynamic secret" + text: "Failed to update dynamic secret" }); } }; @@ -130,7 +133,7 @@ export const EditDynamicSecretSqlProviderForm = ({
( ; type Props = { onClose: () => void; leaseId: string; - slug: string; + dynamicSecretName: string; projectSlug: string; environment: string; secretPath: string; @@ -33,7 +33,7 @@ type Props = { export const RenewDynamicSecretLease = ({ onClose, projectSlug, - slug, + dynamicSecretName, leaseId, secretPath, environment @@ -56,11 +56,11 @@ export const RenewDynamicSecretLease = ({ if (renewDynamicSecretLease.isLoading) return; try { await renewDynamicSecretLease.mutateAsync({ - environment, + environmentSlug: environment, projectSlug, path: secretPath, ttl, - slug, + dynamicSecretName, leaseId }); onClose();