mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-07 12:27:28 +00:00
PIT: add envID to rollback endpoint
This commit is contained in:
@@ -440,7 +440,8 @@ export const registerPITRouter = async (server: FastifyZodProvider) => {
|
|||||||
body: z.object({
|
body: z.object({
|
||||||
folderId: z.string().trim(),
|
folderId: z.string().trim(),
|
||||||
deepRollback: z.boolean().default(false),
|
deepRollback: z.boolean().default(false),
|
||||||
message: z.string().trim().optional()
|
message: z.string().trim().optional(),
|
||||||
|
envId: z.string().trim()
|
||||||
}),
|
}),
|
||||||
response: {
|
response: {
|
||||||
200: z.object({
|
200: z.object({
|
||||||
@@ -467,8 +468,8 @@ export const registerPITRouter = async (server: FastifyZodProvider) => {
|
|||||||
|
|
||||||
if (req.body.deepRollback) {
|
if (req.body.deepRollback) {
|
||||||
await server.services.folderCommit.deepRollbackFolder(
|
await server.services.folderCommit.deepRollbackFolder(
|
||||||
latestCommit.id,
|
req.params.commitId,
|
||||||
req.body.folderId,
|
req.body.envId,
|
||||||
req.permission.id,
|
req.permission.id,
|
||||||
req.permission.type,
|
req.permission.type,
|
||||||
req.params.workspaceId
|
req.params.workspaceId
|
||||||
|
|||||||
@@ -112,14 +112,16 @@ const fetchRollback = async (
|
|||||||
commitId: string,
|
commitId: string,
|
||||||
projectId: string,
|
projectId: string,
|
||||||
deepRollback: boolean,
|
deepRollback: boolean,
|
||||||
message?: string
|
message?: string,
|
||||||
|
envId?: string
|
||||||
) => {
|
) => {
|
||||||
const { data } = await apiRequest.post<{ success: boolean }>(
|
const { data } = await apiRequest.post<{ success: boolean }>(
|
||||||
`/api/v1/pit/commits/${projectId}/${commitId}/rollback`,
|
`/api/v1/pit/commits/${projectId}/${commitId}/rollback`,
|
||||||
{
|
{
|
||||||
folderId,
|
folderId,
|
||||||
deepRollback,
|
deepRollback,
|
||||||
message
|
message,
|
||||||
|
envId
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
return data;
|
return data;
|
||||||
@@ -164,7 +166,8 @@ export const useCommitRollback = ({
|
|||||||
folderId,
|
folderId,
|
||||||
deepRollback,
|
deepRollback,
|
||||||
environment,
|
environment,
|
||||||
directory
|
directory,
|
||||||
|
envId
|
||||||
}: {
|
}: {
|
||||||
workspaceId: string;
|
workspaceId: string;
|
||||||
commitId: string;
|
commitId: string;
|
||||||
@@ -172,11 +175,12 @@ export const useCommitRollback = ({
|
|||||||
deepRollback: boolean;
|
deepRollback: boolean;
|
||||||
environment: string;
|
environment: string;
|
||||||
directory: string;
|
directory: string;
|
||||||
|
envId: string;
|
||||||
}) => {
|
}) => {
|
||||||
const queryClient = useQueryClient();
|
const queryClient = useQueryClient();
|
||||||
return useMutation({
|
return useMutation({
|
||||||
mutationFn: (message: string) =>
|
mutationFn: (message: string) =>
|
||||||
fetchRollback(folderId, commitId, workspaceId, deepRollback, message),
|
fetchRollback(folderId, commitId, workspaceId, deepRollback, message, envId),
|
||||||
onSuccess: () => {
|
onSuccess: () => {
|
||||||
queryClient.invalidateQueries({
|
queryClient.invalidateQueries({
|
||||||
queryKey: [
|
queryKey: [
|
||||||
|
|||||||
+2
-1
@@ -121,7 +121,8 @@ export const RollbackPreviewTab = (): JSX.Element => {
|
|||||||
folderId,
|
folderId,
|
||||||
deepRollback,
|
deepRollback,
|
||||||
environment: envSlug,
|
environment: envSlug,
|
||||||
directory: secretPath
|
directory: secretPath,
|
||||||
|
envId: currentWorkspace.environments.find((e) => e.slug === envSlug)?.id || ""
|
||||||
});
|
});
|
||||||
|
|
||||||
const { data: rollbackChangesNested, isLoading } = useGetRollbackPreview(
|
const { data: rollbackChangesNested, isLoading } = useGetRollbackPreview(
|
||||||
|
|||||||
Reference in New Issue
Block a user