mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-07 09:28:06 +00:00
feat: completed v1 projects prefixed one with projects and switched in
frontend
This commit is contained in:
@@ -75,7 +75,7 @@ export const useUpdateProjectKms = (projectId: string) => {
|
||||
mutationFn: async (
|
||||
updatedData: { type: KmsType.Internal } | { type: KmsType.External; kmsId: string }
|
||||
) => {
|
||||
const { data } = await apiRequest.patch(`/api/v1/workspace/${projectId}/kms`, {
|
||||
const { data } = await apiRequest.patch(`/api/v1/projects/${projectId}/kms`, {
|
||||
kms: updatedData
|
||||
});
|
||||
|
||||
@@ -91,7 +91,7 @@ export const useLoadProjectKmsBackup = (projectId: string) => {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation({
|
||||
mutationFn: async (backup: string) => {
|
||||
const { data } = await apiRequest.post(`/api/v1/workspace/${projectId}/kms/backup`, {
|
||||
const { data } = await apiRequest.post(`/api/v1/projects/${projectId}/kms/backup`, {
|
||||
backup
|
||||
});
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ export const useGetActiveProjectKms = (projectId: string) => {
|
||||
name: string;
|
||||
isExternal: string;
|
||||
};
|
||||
}>(`/api/v1/workspace/${projectId}/kms`);
|
||||
}>(`/api/v1/projects/${projectId}/kms`);
|
||||
return secretManagerKmsKey;
|
||||
}
|
||||
});
|
||||
@@ -58,7 +58,7 @@ export const useGetActiveProjectKms = (projectId: string) => {
|
||||
export const fetchProjectKmsBackup = async (projectId: string) => {
|
||||
const { data } = await apiRequest.get<{
|
||||
secretManager: string;
|
||||
}>(`/api/v1/workspace/${projectId}/kms/backup`);
|
||||
}>(`/api/v1/projects/${projectId}/kms/backup`);
|
||||
|
||||
return data;
|
||||
};
|
||||
|
||||
@@ -14,25 +14,25 @@ import {
|
||||
} from "./types";
|
||||
|
||||
export const secretSnapshotKeys = {
|
||||
list: ({ workspaceId, environment, directory }: Omit<TGetSecretSnapshotsDTO, "limit">) =>
|
||||
[{ workspaceId, environment, directory }, "secret-snapshot"] as const,
|
||||
list: ({ projectId, environment, directory }: Omit<TGetSecretSnapshotsDTO, "limit">) =>
|
||||
[{ projectId, environment, directory }, "secret-snapshot"] as const,
|
||||
snapshotData: (snapshotId: string) => [{ snapshotId }, "secret-snapshot"] as const,
|
||||
count: ({ environment, workspaceId, directory }: Omit<TGetSecretSnapshotsDTO, "limit">) => [
|
||||
{ workspaceId, environment, directory },
|
||||
count: ({ environment, projectId, directory }: Omit<TGetSecretSnapshotsDTO, "limit">) => [
|
||||
{ projectId, environment, directory },
|
||||
"count",
|
||||
"secret-snapshot"
|
||||
]
|
||||
};
|
||||
|
||||
const fetchWorkspaceSnaphots = async ({
|
||||
workspaceId,
|
||||
projectId,
|
||||
environment,
|
||||
directory = "/",
|
||||
limit = 10,
|
||||
offset = 0
|
||||
}: TGetSecretSnapshotsDTO & { offset: number }) => {
|
||||
const res = await apiRequest.get<{ secretSnapshots: TSecretSnapshot[] }>(
|
||||
`/api/v1/workspace/${workspaceId}/secret-snapshots`,
|
||||
`/api/v1/projects/${projectId}/secret-snapshots`,
|
||||
{
|
||||
params: {
|
||||
limit,
|
||||
@@ -49,7 +49,7 @@ const fetchWorkspaceSnaphots = async ({
|
||||
export const useGetWorkspaceSnapshotList = (dto: TGetSecretSnapshotsDTO & { isPaused?: boolean }) =>
|
||||
useInfiniteQuery({
|
||||
initialPageParam: 0,
|
||||
enabled: Boolean(dto.workspaceId && dto.environment) && !dto.isPaused,
|
||||
enabled: Boolean(dto.projectId && dto.environment) && !dto.isPaused,
|
||||
queryKey: secretSnapshotKeys.list({ ...dto }),
|
||||
queryFn: ({ pageParam }) => fetchWorkspaceSnaphots({ ...dto, offset: pageParam }),
|
||||
getNextPageParam: (lastPage, pages) =>
|
||||
@@ -115,12 +115,12 @@ export const useGetSnapshotSecrets = ({ snapshotId }: TSnapshotDataProps) =>
|
||||
});
|
||||
|
||||
const fetchWorkspaceSecretSnaphotCount = async (
|
||||
workspaceId: string,
|
||||
projectId: string,
|
||||
environment: string,
|
||||
directory = "/"
|
||||
) => {
|
||||
const res = await apiRequest.get<{ count: number }>(
|
||||
`/api/v1/workspace/${workspaceId}/secret-snapshots/count`,
|
||||
`/api/v1/projects/${projectId}/secret-snapshots/count`,
|
||||
{
|
||||
params: {
|
||||
environment,
|
||||
@@ -132,15 +132,15 @@ const fetchWorkspaceSecretSnaphotCount = async (
|
||||
};
|
||||
|
||||
export const useGetWsSnapshotCount = ({
|
||||
workspaceId,
|
||||
projectId,
|
||||
environment,
|
||||
directory,
|
||||
isPaused
|
||||
}: Omit<TGetSecretSnapshotsDTO, "limit"> & { isPaused?: boolean }) =>
|
||||
useQuery({
|
||||
enabled: Boolean(workspaceId && environment) && !isPaused,
|
||||
queryKey: secretSnapshotKeys.count({ workspaceId, environment, directory }),
|
||||
queryFn: () => fetchWorkspaceSecretSnaphotCount(workspaceId, environment, directory)
|
||||
enabled: Boolean(projectId && environment) && !isPaused,
|
||||
queryKey: secretSnapshotKeys.count({ projectId, environment, directory }),
|
||||
queryFn: () => fetchWorkspaceSecretSnaphotCount(projectId, environment, directory)
|
||||
});
|
||||
|
||||
export const usePerformSecretRollback = () => {
|
||||
@@ -151,22 +151,22 @@ export const usePerformSecretRollback = () => {
|
||||
const { data } = await apiRequest.post(`/api/v1/secret-snapshot/${snapshotId}/rollback`);
|
||||
return data;
|
||||
},
|
||||
onSuccess: (_, { workspaceId, environment, directory }) => {
|
||||
onSuccess: (_, { projectId, environment, directory }) => {
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: [{ workspaceId, environment, secretPath: directory }, "secrets"]
|
||||
queryKey: [{ projectId, environment, secretPath: directory }, "secrets"]
|
||||
});
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: ["secret-folders", { projectId: workspaceId, environment, path: directory }]
|
||||
queryKey: ["secret-folders", { projectId, environment, path: directory }]
|
||||
});
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: secretSnapshotKeys.list({ workspaceId, environment, directory })
|
||||
queryKey: secretSnapshotKeys.list({ projectId, environment, directory })
|
||||
});
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: secretSnapshotKeys.count({ workspaceId, environment, directory })
|
||||
queryKey: secretSnapshotKeys.count({ projectId, environment, directory })
|
||||
});
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: dashboardKeys.getDashboardSecrets({
|
||||
projectId: workspaceId,
|
||||
projectId,
|
||||
secretPath: directory ?? "/"
|
||||
})
|
||||
});
|
||||
|
||||
@@ -3,7 +3,7 @@ import { WorkspaceEnv } from "../types";
|
||||
|
||||
export type TSecretSnapshot = {
|
||||
id: string;
|
||||
workspace: string;
|
||||
projectId: string;
|
||||
secretVersions: string[];
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
@@ -22,7 +22,7 @@ export type TSnapshotDataProps = {
|
||||
};
|
||||
|
||||
export type TGetSecretSnapshotsDTO = {
|
||||
workspaceId: string;
|
||||
projectId: string;
|
||||
limit: number;
|
||||
environment: string;
|
||||
directory?: string;
|
||||
@@ -30,7 +30,7 @@ export type TGetSecretSnapshotsDTO = {
|
||||
|
||||
export type TSecretRollbackDTO = {
|
||||
snapshotId: string;
|
||||
workspaceId: string;
|
||||
projectId: string;
|
||||
environment: string;
|
||||
directory?: string;
|
||||
};
|
||||
|
||||
@@ -3,7 +3,7 @@ import { useMutation, useQueryClient } from "@tanstack/react-query";
|
||||
import { apiRequest } from "@app/config/request";
|
||||
|
||||
import { userKeys } from "../users/query-keys";
|
||||
import { workspaceKeys } from "./query-keys";
|
||||
import { workspaceKeys as projectKeys } from "./query-keys";
|
||||
import {
|
||||
TProjectSshConfig,
|
||||
TUpdateProjectSshConfigDTO,
|
||||
@@ -32,7 +32,7 @@ export const useAddGroupToWorkspace = () => {
|
||||
},
|
||||
onSuccess: (_, { projectId }) => {
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: workspaceKeys.getWorkspaceGroupMemberships(projectId)
|
||||
queryKey: projectKeys.getWorkspaceGroupMemberships(projectId)
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -52,10 +52,10 @@ export const useUpdateGroupWorkspaceRole = () => {
|
||||
},
|
||||
onSuccess: (_, { projectId, groupId }) => {
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: workspaceKeys.getWorkspaceGroupMemberships(projectId)
|
||||
queryKey: projectKeys.getWorkspaceGroupMemberships(projectId)
|
||||
});
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: workspaceKeys.getWorkspaceGroupMembershipDetails(projectId, groupId)
|
||||
queryKey: projectKeys.getWorkspaceGroupMembershipDetails(projectId, groupId)
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -79,7 +79,7 @@ export const useDeleteGroupFromWorkspace = () => {
|
||||
},
|
||||
onSuccess: (_, { projectId, username }) => {
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: workspaceKeys.getWorkspaceGroupMemberships(projectId)
|
||||
queryKey: projectKeys.getWorkspaceGroupMemberships(projectId)
|
||||
});
|
||||
|
||||
if (username) {
|
||||
@@ -96,20 +96,20 @@ export const useLeaveProject = () => {
|
||||
return apiRequest.delete(`/api/v1/workspace/${workspaceId}/leave`);
|
||||
},
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: workspaceKeys.getAllUserWorkspace() });
|
||||
queryClient.invalidateQueries({ queryKey: projectKeys.getAllUserWorkspace() });
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export const useMigrateProjectToV3 = () => {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation<object, object, { workspaceId: string }>({
|
||||
mutationFn: ({ workspaceId }) => {
|
||||
return apiRequest.post(`/api/v1/workspace/${workspaceId}/migrate-v3`);
|
||||
return useMutation<object, object, { projectId: string }>({
|
||||
mutationFn: ({ projectId }) => {
|
||||
return apiRequest.post(`/api/v1/projects/${projectId}/migrate-v3`);
|
||||
},
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: workspaceKeys.getAllUserWorkspace()
|
||||
queryKey: projectKeys.getAllUserWorkspace()
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -136,7 +136,7 @@ export const useUpdateProjectSshConfig = () => {
|
||||
},
|
||||
onSuccess: (_, { projectId }) => {
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: workspaceKeys.getProjectSshConfig(projectId)
|
||||
queryKey: projectKeys.getProjectSshConfig(projectId)
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user