mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-07 15:27:46 +00:00
feat(ui): updated api changes made
This commit is contained in:
@@ -21,8 +21,8 @@ export const useCreateDynamicSecret = () => {
|
|||||||
);
|
);
|
||||||
return data.dynamicSecret;
|
return data.dynamicSecret;
|
||||||
},
|
},
|
||||||
onSuccess: (_, { path, environment, projectSlug }) => {
|
onSuccess: (_, { path, environmentSlug, projectSlug }) => {
|
||||||
queryClient.invalidateQueries(dynamicSecretKeys.list({ path, projectSlug, environment }));
|
queryClient.invalidateQueries(dynamicSecretKeys.list({ path, projectSlug, environmentSlug }));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -33,13 +33,13 @@ export const useUpdateDynamicSecret = () => {
|
|||||||
return useMutation<{}, {}, TUpdateDynamicSecretDTO>({
|
return useMutation<{}, {}, TUpdateDynamicSecretDTO>({
|
||||||
mutationFn: async (dto) => {
|
mutationFn: async (dto) => {
|
||||||
const { data } = await apiRequest.patch<{ dynamicSecret: TDynamicSecret }>(
|
const { data } = await apiRequest.patch<{ dynamicSecret: TDynamicSecret }>(
|
||||||
`/api/v1/dynamic-secrets/${dto.slug}`,
|
`/api/v1/dynamic-secrets/${dto.name}`,
|
||||||
dto
|
dto
|
||||||
);
|
);
|
||||||
return data.dynamicSecret;
|
return data.dynamicSecret;
|
||||||
},
|
},
|
||||||
onSuccess: (_, { path, environment, projectSlug }) => {
|
onSuccess: (_, { path, environmentSlug, projectSlug }) => {
|
||||||
queryClient.invalidateQueries(dynamicSecretKeys.list({ path, projectSlug, environment }));
|
queryClient.invalidateQueries(dynamicSecretKeys.list({ path, projectSlug, environmentSlug }));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -50,13 +50,13 @@ export const useDeleteDynamicSecret = () => {
|
|||||||
return useMutation<{}, {}, TDeleteDynamicSecretDTO>({
|
return useMutation<{}, {}, TDeleteDynamicSecretDTO>({
|
||||||
mutationFn: async (dto) => {
|
mutationFn: async (dto) => {
|
||||||
const { data } = await apiRequest.delete<{ dynamicSecret: TDynamicSecret }>(
|
const { data } = await apiRequest.delete<{ dynamicSecret: TDynamicSecret }>(
|
||||||
`/api/v1/dynamic-secrets/${dto.slug}`,
|
`/api/v1/dynamic-secrets/${dto.name}`,
|
||||||
{ data: dto }
|
{ data: dto }
|
||||||
);
|
);
|
||||||
return data.dynamicSecret;
|
return data.dynamicSecret;
|
||||||
},
|
},
|
||||||
onSuccess: (_, { path, environment, projectSlug }) => {
|
onSuccess: (_, { path, environmentSlug, projectSlug }) => {
|
||||||
queryClient.invalidateQueries(dynamicSecretKeys.list({ path, projectSlug, environment }));
|
queryClient.invalidateQueries(dynamicSecretKeys.list({ path, projectSlug, environmentSlug }));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -7,25 +7,25 @@ import { TDetailsDynamicSecretDTO, TDynamicSecret, TListDynamicSecretDTO } from
|
|||||||
export const dynamicSecretKeys = {
|
export const dynamicSecretKeys = {
|
||||||
list: ({
|
list: ({
|
||||||
projectSlug,
|
projectSlug,
|
||||||
environment,
|
environmentSlug,
|
||||||
path
|
path
|
||||||
}: Pick<TListDynamicSecretDTO, "path" | "environment" | "projectSlug">) =>
|
}: Pick<TListDynamicSecretDTO, "path" | "environmentSlug" | "projectSlug">) =>
|
||||||
[{ projectSlug, environment, path }, "dynamic-secrets"] as const,
|
[{ projectSlug, environmentSlug, path }, "dynamic-secrets"] as const,
|
||||||
details: ({ path, environment, projectSlug, slug }: TDetailsDynamicSecretDTO) =>
|
details: ({ path, environmentSlug, projectSlug, name }: TDetailsDynamicSecretDTO) =>
|
||||||
[{ projectSlug, path, environment, slug }, "dynamic-secret-details"] as const
|
[{ 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({
|
return useQuery({
|
||||||
queryKey: dynamicSecretKeys.list({ path, environment, projectSlug }),
|
queryKey: dynamicSecretKeys.list({ path, environmentSlug, projectSlug }),
|
||||||
enabled: Boolean(projectSlug && environment && path),
|
enabled: Boolean(projectSlug && environmentSlug && path),
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
const { data } = await apiRequest.get<{ dynamicSecrets: TDynamicSecret[] }>(
|
const { data } = await apiRequest.get<{ dynamicSecrets: TDynamicSecret[] }>(
|
||||||
"/api/v1/dynamic-secrets",
|
"/api/v1/dynamic-secrets",
|
||||||
{
|
{
|
||||||
params: {
|
params: {
|
||||||
projectSlug,
|
projectSlug,
|
||||||
environment,
|
environmentSlug,
|
||||||
path
|
path
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -38,20 +38,20 @@ export const useGetDynamicSecrets = ({ projectSlug, environment, path }: TListDy
|
|||||||
|
|
||||||
export const useGetDynamicSecretDetails = ({
|
export const useGetDynamicSecretDetails = ({
|
||||||
projectSlug,
|
projectSlug,
|
||||||
environment,
|
environmentSlug,
|
||||||
path,
|
path,
|
||||||
slug
|
name
|
||||||
}: TDetailsDynamicSecretDTO) => {
|
}: TDetailsDynamicSecretDTO) => {
|
||||||
return useQuery({
|
return useQuery({
|
||||||
queryKey: dynamicSecretKeys.details({ path, environment, projectSlug, slug }),
|
queryKey: dynamicSecretKeys.details({ path, environmentSlug, projectSlug, name }),
|
||||||
enabled: Boolean(projectSlug && environment && path && slug),
|
enabled: Boolean(projectSlug && environmentSlug && path && name),
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
const { data } = await apiRequest.get<{
|
const { data } = await apiRequest.get<{
|
||||||
dynamicSecret: TDynamicSecret & { inputs: unknown };
|
dynamicSecret: TDynamicSecret & { inputs: unknown };
|
||||||
}>(`/api/v1/dynamic-secrets/${slug}`, {
|
}>(`/api/v1/dynamic-secrets/${name}`, {
|
||||||
params: {
|
params: {
|
||||||
projectSlug,
|
projectSlug,
|
||||||
environment,
|
environmentSlug,
|
||||||
path
|
path
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -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
|
// TODO(akhilmhdh): When we switch to monorepo all the server api ts will be in a shared repo
|
||||||
export type TDynamicSecret = {
|
export type TDynamicSecret = {
|
||||||
id: string;
|
id: string;
|
||||||
slug: string;
|
name: string;
|
||||||
type: DynamicSecretProviders;
|
type: DynamicSecretProviders;
|
||||||
createdAt: string;
|
createdAt: string;
|
||||||
updatedAt: string;
|
updatedAt: string;
|
||||||
@@ -45,17 +45,17 @@ export type TCreateDynamicSecretDTO = {
|
|||||||
defaultTTL: string;
|
defaultTTL: string;
|
||||||
maxTTL?: string;
|
maxTTL?: string;
|
||||||
path: string;
|
path: string;
|
||||||
environment: string;
|
environmentSlug: string;
|
||||||
slug: string;
|
name: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type TUpdateDynamicSecretDTO = {
|
export type TUpdateDynamicSecretDTO = {
|
||||||
slug: string;
|
name: string;
|
||||||
projectSlug: string;
|
projectSlug: string;
|
||||||
path: string;
|
path: string;
|
||||||
environment: string;
|
environmentSlug: string;
|
||||||
data: {
|
data: {
|
||||||
newSlug?: string;
|
newName?: string;
|
||||||
defaultTTL?: string;
|
defaultTTL?: string;
|
||||||
maxTTL?: string | null;
|
maxTTL?: string | null;
|
||||||
inputs?: unknown;
|
inputs?: unknown;
|
||||||
@@ -65,20 +65,20 @@ export type TUpdateDynamicSecretDTO = {
|
|||||||
export type TListDynamicSecretDTO = {
|
export type TListDynamicSecretDTO = {
|
||||||
projectSlug: string;
|
projectSlug: string;
|
||||||
path: string;
|
path: string;
|
||||||
environment: string;
|
environmentSlug: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type TDeleteDynamicSecretDTO = {
|
export type TDeleteDynamicSecretDTO = {
|
||||||
projectSlug: string;
|
projectSlug: string;
|
||||||
path: string;
|
path: string;
|
||||||
environment: string;
|
environmentSlug: string;
|
||||||
slug: string;
|
name: string;
|
||||||
isForced?: boolean;
|
isForced?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type TDetailsDynamicSecretDTO = {
|
export type TDetailsDynamicSecretDTO = {
|
||||||
projectSlug: string;
|
projectSlug: string;
|
||||||
path: string;
|
path: string;
|
||||||
environment: string;
|
environmentSlug: string;
|
||||||
slug: string;
|
name: string;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -25,9 +25,9 @@ export const useCreateDynamicSecretLease = () => {
|
|||||||
);
|
);
|
||||||
return data;
|
return data;
|
||||||
},
|
},
|
||||||
onSuccess: (_, { path, environment, projectSlug, slug }) => {
|
onSuccess: (_, { path, environmentSlug, projectSlug, dynamicSecretName }) => {
|
||||||
queryClient.invalidateQueries(
|
queryClient.invalidateQueries(
|
||||||
dynamicSecretLeaseKeys.list({ path, projectSlug, environment, slug })
|
dynamicSecretLeaseKeys.list({ path, projectSlug, environmentSlug, dynamicSecretName })
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -44,9 +44,9 @@ export const useRenewDynamicSecretLease = () => {
|
|||||||
);
|
);
|
||||||
return data.lease;
|
return data.lease;
|
||||||
},
|
},
|
||||||
onSuccess: (_, { path, environment, projectSlug, slug }) => {
|
onSuccess: (_, { path, environmentSlug, projectSlug, dynamicSecretName }) => {
|
||||||
queryClient.invalidateQueries(
|
queryClient.invalidateQueries(
|
||||||
dynamicSecretLeaseKeys.list({ path, projectSlug, environment, slug })
|
dynamicSecretLeaseKeys.list({ path, projectSlug, environmentSlug, dynamicSecretName })
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -63,9 +63,9 @@ export const useRevokeDynamicSecretLease = () => {
|
|||||||
);
|
);
|
||||||
return data.lease;
|
return data.lease;
|
||||||
},
|
},
|
||||||
onSuccess: (_, { path, environment, projectSlug, slug }) => {
|
onSuccess: (_, { path, environmentSlug, projectSlug, dynamicSecretName }) => {
|
||||||
queryClient.invalidateQueries(
|
queryClient.invalidateQueries(
|
||||||
dynamicSecretLeaseKeys.list({ path, projectSlug, environment, slug })
|
dynamicSecretLeaseKeys.list({ path, projectSlug, environmentSlug, dynamicSecretName })
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -5,27 +5,27 @@ import { apiRequest } from "@app/config/request";
|
|||||||
import { TDynamicSecretLease, TListDynamicSecretLeaseDTO } from "./types";
|
import { TDynamicSecretLease, TListDynamicSecretLeaseDTO } from "./types";
|
||||||
|
|
||||||
export const dynamicSecretLeaseKeys = {
|
export const dynamicSecretLeaseKeys = {
|
||||||
list: ({ projectSlug, environment, path, slug }: TListDynamicSecretLeaseDTO) =>
|
list: ({ projectSlug, environmentSlug, path, dynamicSecretName }: TListDynamicSecretLeaseDTO) =>
|
||||||
[{ projectSlug, environment, path, slug }, "dynamic-secret-leases"] as const
|
[{ projectSlug, environmentSlug, path, dynamicSecretName }, "dynamic-secret-leases"] as const
|
||||||
};
|
};
|
||||||
|
|
||||||
export const useGetDynamicSecretLeases = ({
|
export const useGetDynamicSecretLeases = ({
|
||||||
projectSlug,
|
projectSlug,
|
||||||
environment,
|
environmentSlug,
|
||||||
path,
|
path,
|
||||||
slug,
|
dynamicSecretName,
|
||||||
enabled = true
|
enabled = true
|
||||||
}: TListDynamicSecretLeaseDTO) => {
|
}: TListDynamicSecretLeaseDTO) => {
|
||||||
return useQuery({
|
return useQuery({
|
||||||
queryKey: dynamicSecretLeaseKeys.list({ path, environment, projectSlug, slug }),
|
queryKey: dynamicSecretLeaseKeys.list({ path, environmentSlug, projectSlug, dynamicSecretName }),
|
||||||
enabled: Boolean(projectSlug && environment && path && slug && enabled),
|
enabled: Boolean(projectSlug && environmentSlug && path && dynamicSecretName && enabled),
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
const { data } = await apiRequest.get<{ leases: TDynamicSecretLease[] }>(
|
const { data } = await apiRequest.get<{ leases: TDynamicSecretLease[] }>(
|
||||||
`/api/v1/dynamic-secrets/${slug}/leases`,
|
`/api/v1/dynamic-secrets/${dynamicSecretName}/leases`,
|
||||||
{
|
{
|
||||||
params: {
|
params: {
|
||||||
projectSlug,
|
projectSlug,
|
||||||
environment,
|
environmentSlug,
|
||||||
path
|
path
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,35 +14,35 @@ export type TDynamicSecretLease = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export type TCreateDynamicSecretLeaseDTO = {
|
export type TCreateDynamicSecretLeaseDTO = {
|
||||||
slug: string;
|
dynamicSecretName: string;
|
||||||
projectSlug: string;
|
projectSlug: string;
|
||||||
ttl?: string;
|
ttl?: string;
|
||||||
path: string;
|
path: string;
|
||||||
environment: string;
|
environmentSlug: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type TRenewDynamicSecretLeaseDTO = {
|
export type TRenewDynamicSecretLeaseDTO = {
|
||||||
leaseId: string;
|
leaseId: string;
|
||||||
slug: string;
|
dynamicSecretName: string;
|
||||||
ttl?: string;
|
ttl?: string;
|
||||||
projectSlug: string;
|
projectSlug: string;
|
||||||
path: string;
|
path: string;
|
||||||
environment: string;
|
environmentSlug: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type TListDynamicSecretLeaseDTO = {
|
export type TListDynamicSecretLeaseDTO = {
|
||||||
slug: string;
|
dynamicSecretName: string;
|
||||||
projectSlug: string;
|
projectSlug: string;
|
||||||
path: string;
|
path: string;
|
||||||
environment: string;
|
environmentSlug: string;
|
||||||
enabled?: boolean;
|
enabled?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type TRevokeDynamicSecretLeaseDTO = {
|
export type TRevokeDynamicSecretLeaseDTO = {
|
||||||
leaseId: string;
|
leaseId: string;
|
||||||
slug: string;
|
dynamicSecretName: string;
|
||||||
projectSlug: string;
|
projectSlug: string;
|
||||||
path: string;
|
path: string;
|
||||||
environment: string;
|
environmentSlug: string;
|
||||||
isForced?: boolean;
|
isForced?: boolean;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ export type SubscriptionPlan = {
|
|||||||
membersUsed: number;
|
membersUsed: number;
|
||||||
memberLimit: number;
|
memberLimit: number;
|
||||||
auditLogs: boolean;
|
auditLogs: boolean;
|
||||||
|
dynamicSecret: boolean;
|
||||||
auditLogsRetentionDays: number;
|
auditLogsRetentionDays: number;
|
||||||
customAlerts: boolean;
|
customAlerts: boolean;
|
||||||
customRateLimits: boolean;
|
customRateLimits: boolean;
|
||||||
@@ -21,14 +22,14 @@ export type SubscriptionPlan = {
|
|||||||
scim: boolean;
|
scim: boolean;
|
||||||
ldap: boolean;
|
ldap: boolean;
|
||||||
status:
|
status:
|
||||||
| "incomplete"
|
| "incomplete"
|
||||||
| "incomplete_expired"
|
| "incomplete_expired"
|
||||||
| "trialing"
|
| "trialing"
|
||||||
| "active"
|
| "active"
|
||||||
| "past_due"
|
| "past_due"
|
||||||
| "canceled"
|
| "canceled"
|
||||||
| "unpaid"
|
| "unpaid"
|
||||||
| null;
|
| null;
|
||||||
trial_end: number | null;
|
trial_end: number | null;
|
||||||
has_used_trial: boolean;
|
has_used_trial: boolean;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -141,7 +141,7 @@ export const SecretMainPage = () => {
|
|||||||
|
|
||||||
const { data: dynamicSecrets, isLoading: isDynamicSecretLoading } = useGetDynamicSecrets({
|
const { data: dynamicSecrets, isLoading: isDynamicSecretLoading } = useGetDynamicSecrets({
|
||||||
projectSlug,
|
projectSlug,
|
||||||
environment,
|
environmentSlug: environment,
|
||||||
path: secretPath
|
path: secretPath
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
+12
-12
@@ -54,7 +54,9 @@ const formSchema = z.object({
|
|||||||
if (valMs > 24 * 60 * 60 * 1000)
|
if (valMs > 24 * 60 * 60 * 1000)
|
||||||
ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be less than a day" });
|
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<typeof formSchema>;
|
type TForm = z.infer<typeof formSchema>;
|
||||||
|
|
||||||
@@ -92,18 +94,18 @@ export const SqlDatabaseInputForm = ({
|
|||||||
const { createNotification } = useNotificationContext();
|
const { createNotification } = useNotificationContext();
|
||||||
const createDynamicSecret = useCreateDynamicSecret();
|
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
|
// wait till previous request is finished
|
||||||
if (createDynamicSecret.isLoading) return;
|
if (createDynamicSecret.isLoading) return;
|
||||||
try {
|
try {
|
||||||
await createDynamicSecret.mutateAsync({
|
await createDynamicSecret.mutateAsync({
|
||||||
provider: { type: DynamicSecretProviders.SqlDatabase, inputs: provider },
|
provider: { type: DynamicSecretProviders.SqlDatabase, inputs: provider },
|
||||||
maxTTL,
|
maxTTL,
|
||||||
slug,
|
name,
|
||||||
path: secretPath,
|
path: secretPath,
|
||||||
defaultTTL,
|
defaultTTL,
|
||||||
projectSlug,
|
projectSlug,
|
||||||
environment
|
environmentSlug: environment
|
||||||
});
|
});
|
||||||
onCompleted();
|
onCompleted();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
@@ -122,7 +124,7 @@ export const SqlDatabaseInputForm = ({
|
|||||||
<Controller
|
<Controller
|
||||||
control={control}
|
control={control}
|
||||||
defaultValue=""
|
defaultValue=""
|
||||||
name="slug"
|
name="name"
|
||||||
render={({ field, fieldState: { error } }) => (
|
render={({ field, fieldState: { error } }) => (
|
||||||
<FormControl
|
<FormControl
|
||||||
label="Secret Name"
|
label="Secret Name"
|
||||||
@@ -168,9 +170,11 @@ export const SqlDatabaseInputForm = ({
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<div className="mb-4 border-b border-mineshaft-500 pb-2 text-mineshaft-200 pl-1 mt-4 font-medium">Configuration</div>
|
<div className="mb-4 mt-4 border-b border-mineshaft-500 pb-2 pl-1 font-medium text-mineshaft-200">
|
||||||
|
Configuration
|
||||||
|
</div>
|
||||||
<div className="flex flex-col">
|
<div className="flex flex-col">
|
||||||
<div className="text-sm text-mineshaft-400 pl-1 pb-0.5">Service</div>
|
<div className="pl-1 pb-0.5 text-sm text-mineshaft-400">Service</div>
|
||||||
<Controller
|
<Controller
|
||||||
control={control}
|
control={control}
|
||||||
name="provider.client"
|
name="provider.client"
|
||||||
@@ -279,11 +283,7 @@ export const SqlDatabaseInputForm = ({
|
|||||||
</FormControl>
|
</FormControl>
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
<Accordion
|
<Accordion type="single" collapsible className="mb-2 w-full bg-mineshaft-700">
|
||||||
type="single"
|
|
||||||
collapsible
|
|
||||||
className="w-full bg-mineshaft-700 mb-2"
|
|
||||||
>
|
|
||||||
<AccordionItem value="advance-statements">
|
<AccordionItem value="advance-statements">
|
||||||
<AccordionTrigger>Modify SQL Statements</AccordionTrigger>
|
<AccordionTrigger>Modify SQL Statements</AccordionTrigger>
|
||||||
<AccordionContent>
|
<AccordionContent>
|
||||||
|
|||||||
+4
-4
@@ -77,7 +77,7 @@ type TForm = z.infer<typeof formSchema>;
|
|||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
onClose: () => void;
|
onClose: () => void;
|
||||||
slug: string;
|
dynamicSecretName: string;
|
||||||
provider: DynamicSecretProviders;
|
provider: DynamicSecretProviders;
|
||||||
projectSlug: string;
|
projectSlug: string;
|
||||||
environment: string;
|
environment: string;
|
||||||
@@ -87,7 +87,7 @@ type Props = {
|
|||||||
export const CreateDynamicSecretLease = ({
|
export const CreateDynamicSecretLease = ({
|
||||||
onClose,
|
onClose,
|
||||||
projectSlug,
|
projectSlug,
|
||||||
slug,
|
dynamicSecretName,
|
||||||
provider,
|
provider,
|
||||||
secretPath,
|
secretPath,
|
||||||
environment
|
environment
|
||||||
@@ -110,11 +110,11 @@ export const CreateDynamicSecretLease = ({
|
|||||||
if (createDynamicSecretLease.isLoading) return;
|
if (createDynamicSecretLease.isLoading) return;
|
||||||
try {
|
try {
|
||||||
await createDynamicSecretLease.mutateAsync({
|
await createDynamicSecretLease.mutateAsync({
|
||||||
environment,
|
environmentSlug: environment,
|
||||||
projectSlug,
|
projectSlug,
|
||||||
path: secretPath,
|
path: secretPath,
|
||||||
ttl,
|
ttl,
|
||||||
slug
|
dynamicSecretName
|
||||||
});
|
});
|
||||||
createNotification({
|
createNotification({
|
||||||
type: "success",
|
type: "success",
|
||||||
|
|||||||
+7
-7
@@ -34,7 +34,7 @@ import { DynamicSecretLeaseStatus } from "@app/hooks/api/dynamicSecretLease/type
|
|||||||
import { RenewDynamicSecretLease } from "./RenewDynamicSecretLease";
|
import { RenewDynamicSecretLease } from "./RenewDynamicSecretLease";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
slug: string;
|
dynamicSecretName: string;
|
||||||
projectSlug: string;
|
projectSlug: string;
|
||||||
environment: string;
|
environment: string;
|
||||||
secretPath: string;
|
secretPath: string;
|
||||||
@@ -44,7 +44,7 @@ type Props = {
|
|||||||
|
|
||||||
export const DynamicSecretLease = ({
|
export const DynamicSecretLease = ({
|
||||||
projectSlug,
|
projectSlug,
|
||||||
slug,
|
dynamicSecretName,
|
||||||
environment,
|
environment,
|
||||||
secretPath,
|
secretPath,
|
||||||
onClickNewLease,
|
onClickNewLease,
|
||||||
@@ -56,9 +56,9 @@ export const DynamicSecretLease = ({
|
|||||||
] as const);
|
] as const);
|
||||||
const { data: leases, isLoading: isLeaseLoading } = useGetDynamicSecretLeases({
|
const { data: leases, isLoading: isLeaseLoading } = useGetDynamicSecretLeases({
|
||||||
projectSlug,
|
projectSlug,
|
||||||
environment,
|
environmentSlug: environment,
|
||||||
path: secretPath,
|
path: secretPath,
|
||||||
slug
|
dynamicSecretName
|
||||||
});
|
});
|
||||||
const { createNotification } = useNotificationContext();
|
const { createNotification } = useNotificationContext();
|
||||||
|
|
||||||
@@ -71,10 +71,10 @@ export const DynamicSecretLease = ({
|
|||||||
isForced?: boolean;
|
isForced?: boolean;
|
||||||
};
|
};
|
||||||
await deleteDynamicSecretLease.mutateAsync({
|
await deleteDynamicSecretLease.mutateAsync({
|
||||||
environment,
|
environmentSlug: environment,
|
||||||
projectSlug,
|
projectSlug,
|
||||||
path: secretPath,
|
path: secretPath,
|
||||||
slug,
|
dynamicSecretName,
|
||||||
leaseId,
|
leaseId,
|
||||||
isForced
|
isForced
|
||||||
});
|
});
|
||||||
@@ -226,7 +226,7 @@ export const DynamicSecretLease = ({
|
|||||||
onClose={() => handlePopUpClose("renewSecret")}
|
onClose={() => handlePopUpClose("renewSecret")}
|
||||||
projectSlug={projectSlug}
|
projectSlug={projectSlug}
|
||||||
leaseId={(popUp.renewSecret?.data as { leaseId: string })?.leaseId}
|
leaseId={(popUp.renewSecret?.data as { leaseId: string })?.leaseId}
|
||||||
slug={slug}
|
dynamicSecretName={dynamicSecretName}
|
||||||
secretPath={secretPath}
|
secretPath={secretPath}
|
||||||
environment={environment}
|
environment={environment}
|
||||||
/>
|
/>
|
||||||
|
|||||||
+11
-11
@@ -64,14 +64,14 @@ export const DynamicSecretListView = ({
|
|||||||
|
|
||||||
const handleDynamicSecretDelete = async () => {
|
const handleDynamicSecretDelete = async () => {
|
||||||
try {
|
try {
|
||||||
const { slug, isForced } = popUp.deleteDynamicSecret.data as TDynamicSecret & {
|
const { name, isForced } = popUp.deleteDynamicSecret.data as TDynamicSecret & {
|
||||||
isForced?: boolean;
|
isForced?: boolean;
|
||||||
};
|
};
|
||||||
await deleteDynamicSecret.mutateAsync({
|
await deleteDynamicSecret.mutateAsync({
|
||||||
environment,
|
environmentSlug: environment,
|
||||||
projectSlug,
|
projectSlug,
|
||||||
path: secretPath,
|
path: secretPath,
|
||||||
slug,
|
name,
|
||||||
isForced
|
isForced
|
||||||
});
|
});
|
||||||
handlePopUpClose("deleteDynamicSecret");
|
handlePopUpClose("deleteDynamicSecret");
|
||||||
@@ -93,8 +93,8 @@ export const DynamicSecretListView = ({
|
|||||||
{dynamicSecrets
|
{dynamicSecrets
|
||||||
.sort((a, b) =>
|
.sort((a, b) =>
|
||||||
sortDir === SortDir.ASC
|
sortDir === SortDir.ASC
|
||||||
? a.slug.toLowerCase().localeCompare(b.slug.toLowerCase())
|
? a.name.toLowerCase().localeCompare(b.name.toLowerCase())
|
||||||
: b.slug.toLowerCase().localeCompare(a.slug.toLowerCase())
|
: b.name.toLowerCase().localeCompare(a.name.toLowerCase())
|
||||||
)
|
)
|
||||||
.map((secret) => {
|
.map((secret) => {
|
||||||
const isRevocking = secret.status === DynamicSecretStatus.Deleting;
|
const isRevocking = secret.status === DynamicSecretStatus.Deleting;
|
||||||
@@ -124,11 +124,11 @@ export const DynamicSecretListView = ({
|
|||||||
<FontAwesomeIcon icon={faFingerprint} />
|
<FontAwesomeIcon icon={faFingerprint} />
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
className="flex flex-grow items-center px-4 py-3 uppercase"
|
className="flex flex-grow items-center px-4 py-3"
|
||||||
role="button"
|
role="button"
|
||||||
tabIndex={0}
|
tabIndex={0}
|
||||||
>
|
>
|
||||||
{secret.slug}{" "}
|
{secret.name}
|
||||||
<Tag className="ml-4 py-0 px-2 text-xs normal-case">
|
<Tag className="ml-4 py-0 px-2 text-xs normal-case">
|
||||||
{formatProviderName(secret.type)}
|
{formatProviderName(secret.type)}
|
||||||
</Tag>
|
</Tag>
|
||||||
@@ -234,7 +234,7 @@ export const DynamicSecretListView = ({
|
|||||||
onClose={() => handlePopUpClose("dynamicSecretLeases")}
|
onClose={() => handlePopUpClose("dynamicSecretLeases")}
|
||||||
projectSlug={projectSlug}
|
projectSlug={projectSlug}
|
||||||
key={secret.id}
|
key={secret.id}
|
||||||
slug={secret.slug}
|
dynamicSecretName={secret.name}
|
||||||
secretPath={secretPath}
|
secretPath={secretPath}
|
||||||
environment={environment}
|
environment={environment}
|
||||||
/>
|
/>
|
||||||
@@ -253,7 +253,7 @@ export const DynamicSecretListView = ({
|
|||||||
}
|
}
|
||||||
onClose={() => handlePopUpClose("createDynamicSecretLease")}
|
onClose={() => handlePopUpClose("createDynamicSecretLease")}
|
||||||
projectSlug={projectSlug}
|
projectSlug={projectSlug}
|
||||||
slug={(popUp.createDynamicSecretLease?.data as { slug: string })?.slug}
|
dynamicSecretName={(popUp.createDynamicSecretLease?.data as { name: string })?.name}
|
||||||
secretPath={secretPath}
|
secretPath={secretPath}
|
||||||
environment={environment}
|
environment={environment}
|
||||||
/>
|
/>
|
||||||
@@ -267,7 +267,7 @@ export const DynamicSecretListView = ({
|
|||||||
<EditDynamicSecretForm
|
<EditDynamicSecretForm
|
||||||
onClose={() => handlePopUpClose("updateDynamicSecret")}
|
onClose={() => handlePopUpClose("updateDynamicSecret")}
|
||||||
projectSlug={projectSlug}
|
projectSlug={projectSlug}
|
||||||
slug={(popUp.updateDynamicSecret?.data as TDynamicSecret)?.slug}
|
dynamicSecretName={(popUp.updateDynamicSecret?.data as TDynamicSecret)?.name}
|
||||||
secretPath={secretPath}
|
secretPath={secretPath}
|
||||||
environment={environment}
|
environment={environment}
|
||||||
/>
|
/>
|
||||||
@@ -275,7 +275,7 @@ export const DynamicSecretListView = ({
|
|||||||
</Modal>
|
</Modal>
|
||||||
<DeleteActionModal
|
<DeleteActionModal
|
||||||
isOpen={popUp.deleteDynamicSecret.isOpen}
|
isOpen={popUp.deleteDynamicSecret.isOpen}
|
||||||
deleteKey={(popUp.deleteDynamicSecret?.data as TDynamicSecret)?.slug}
|
deleteKey={(popUp.deleteDynamicSecret?.data as TDynamicSecret)?.name}
|
||||||
title={
|
title={
|
||||||
(popUp.deleteDynamicSecret?.data as { isForced?: boolean })?.isForced
|
(popUp.deleteDynamicSecret?.data as { isForced?: boolean })?.isForced
|
||||||
? "Do you want to force delete this dynamic secret?"
|
? "Do you want to force delete this dynamic secret?"
|
||||||
|
|||||||
+4
-4
@@ -8,14 +8,14 @@ import { EditDynamicSecretSqlProviderForm } from "./EditDynamicSecretSqlProvider
|
|||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
onClose: () => void;
|
onClose: () => void;
|
||||||
slug: string;
|
dynamicSecretName: string;
|
||||||
projectSlug: string;
|
projectSlug: string;
|
||||||
environment: string;
|
environment: string;
|
||||||
secretPath: string;
|
secretPath: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const EditDynamicSecretForm = ({
|
export const EditDynamicSecretForm = ({
|
||||||
slug,
|
dynamicSecretName,
|
||||||
environment,
|
environment,
|
||||||
projectSlug,
|
projectSlug,
|
||||||
onClose,
|
onClose,
|
||||||
@@ -24,8 +24,8 @@ export const EditDynamicSecretForm = ({
|
|||||||
const { data: dynamicSecretDetails, isLoading: isDynamicSecretLoading } =
|
const { data: dynamicSecretDetails, isLoading: isDynamicSecretLoading } =
|
||||||
useGetDynamicSecretDetails({
|
useGetDynamicSecretDetails({
|
||||||
projectSlug,
|
projectSlug,
|
||||||
environment,
|
environmentSlug: environment,
|
||||||
slug,
|
name: dynamicSecretName,
|
||||||
path: secretPath
|
path: secretPath
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
+12
-9
@@ -57,7 +57,10 @@ const formSchema = z.object({
|
|||||||
ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be less than a day" });
|
ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be less than a day" });
|
||||||
})
|
})
|
||||||
.nullable(),
|
.nullable(),
|
||||||
newSlug: z.string().toLowerCase().optional()
|
newName: z
|
||||||
|
.string()
|
||||||
|
.refine((val) => val.toLowerCase() === val, "Must be lowercase")
|
||||||
|
.optional()
|
||||||
});
|
});
|
||||||
type TForm = z.infer<typeof formSchema>;
|
type TForm = z.infer<typeof formSchema>;
|
||||||
|
|
||||||
@@ -85,7 +88,7 @@ export const EditDynamicSecretSqlProviderForm = ({
|
|||||||
values: {
|
values: {
|
||||||
defaultTTL: dynamicSecret.defaultTTL,
|
defaultTTL: dynamicSecret.defaultTTL,
|
||||||
maxTTL: dynamicSecret.maxTTL,
|
maxTTL: dynamicSecret.maxTTL,
|
||||||
newSlug: dynamicSecret.slug,
|
newName: dynamicSecret.name,
|
||||||
inputs: {
|
inputs: {
|
||||||
...(dynamicSecret.inputs as TForm["inputs"])
|
...(dynamicSecret.inputs as TForm["inputs"])
|
||||||
}
|
}
|
||||||
@@ -94,31 +97,31 @@ export const EditDynamicSecretSqlProviderForm = ({
|
|||||||
const { createNotification } = useNotificationContext();
|
const { createNotification } = useNotificationContext();
|
||||||
const updateDynamicSecret = useUpdateDynamicSecret();
|
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
|
// wait till previous request is finished
|
||||||
if (updateDynamicSecret.isLoading) return;
|
if (updateDynamicSecret.isLoading) return;
|
||||||
try {
|
try {
|
||||||
await updateDynamicSecret.mutateAsync({
|
await updateDynamicSecret.mutateAsync({
|
||||||
slug: dynamicSecret.slug,
|
name: dynamicSecret.name,
|
||||||
path: secretPath,
|
path: secretPath,
|
||||||
projectSlug,
|
projectSlug,
|
||||||
environment,
|
environmentSlug: environment,
|
||||||
data: {
|
data: {
|
||||||
maxTTL: maxTTL || undefined,
|
maxTTL: maxTTL || undefined,
|
||||||
defaultTTL,
|
defaultTTL,
|
||||||
inputs,
|
inputs,
|
||||||
newSlug: newSlug === dynamicSecret.slug ? undefined : newSlug
|
newName: newName === dynamicSecret.name ? undefined : newName
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
onClose();
|
onClose();
|
||||||
createNotification({
|
createNotification({
|
||||||
type: "success",
|
type: "success",
|
||||||
text: "Successfully updated dynamic secret"
|
text: "Successfully update dynamic secret"
|
||||||
});
|
});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
createNotification({
|
createNotification({
|
||||||
type: "error",
|
type: "error",
|
||||||
text: "Failed to create dynamic secret"
|
text: "Failed to update dynamic secret"
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -130,7 +133,7 @@ export const EditDynamicSecretSqlProviderForm = ({
|
|||||||
<div className="flex-grow">
|
<div className="flex-grow">
|
||||||
<Controller
|
<Controller
|
||||||
control={control}
|
control={control}
|
||||||
name="newSlug"
|
name="newName"
|
||||||
render={({ field, fieldState: { error } }) => (
|
render={({ field, fieldState: { error } }) => (
|
||||||
<FormControl
|
<FormControl
|
||||||
label="Secret Name"
|
label="Secret Name"
|
||||||
|
|||||||
+4
-4
@@ -24,7 +24,7 @@ type TForm = z.infer<typeof formSchema>;
|
|||||||
type Props = {
|
type Props = {
|
||||||
onClose: () => void;
|
onClose: () => void;
|
||||||
leaseId: string;
|
leaseId: string;
|
||||||
slug: string;
|
dynamicSecretName: string;
|
||||||
projectSlug: string;
|
projectSlug: string;
|
||||||
environment: string;
|
environment: string;
|
||||||
secretPath: string;
|
secretPath: string;
|
||||||
@@ -33,7 +33,7 @@ type Props = {
|
|||||||
export const RenewDynamicSecretLease = ({
|
export const RenewDynamicSecretLease = ({
|
||||||
onClose,
|
onClose,
|
||||||
projectSlug,
|
projectSlug,
|
||||||
slug,
|
dynamicSecretName,
|
||||||
leaseId,
|
leaseId,
|
||||||
secretPath,
|
secretPath,
|
||||||
environment
|
environment
|
||||||
@@ -56,11 +56,11 @@ export const RenewDynamicSecretLease = ({
|
|||||||
if (renewDynamicSecretLease.isLoading) return;
|
if (renewDynamicSecretLease.isLoading) return;
|
||||||
try {
|
try {
|
||||||
await renewDynamicSecretLease.mutateAsync({
|
await renewDynamicSecretLease.mutateAsync({
|
||||||
environment,
|
environmentSlug: environment,
|
||||||
projectSlug,
|
projectSlug,
|
||||||
path: secretPath,
|
path: secretPath,
|
||||||
ttl,
|
ttl,
|
||||||
slug,
|
dynamicSecretName,
|
||||||
leaseId
|
leaseId
|
||||||
});
|
});
|
||||||
onClose();
|
onClose();
|
||||||
|
|||||||
Reference in New Issue
Block a user