mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-07 13:27:46 +00:00
adjustment: updated to use project slug
This commit is contained in:
@@ -252,6 +252,7 @@ export const FOLDERS = {
|
|||||||
name: "The new name of the folder.",
|
name: "The new name of the folder.",
|
||||||
path: "The path of the folder to update.",
|
path: "The path of the folder to update.",
|
||||||
directory: "The new directory of the folder to update. (Deprecated in favor of path)",
|
directory: "The new directory of the folder to update. (Deprecated in favor of path)",
|
||||||
|
projectSlug: "The slug of the project where the folder is located.",
|
||||||
workspaceId: "The ID of the project where the folder is located."
|
workspaceId: "The ID of the project where the folder is located."
|
||||||
},
|
},
|
||||||
DELETE: {
|
DELETE: {
|
||||||
|
|||||||
@@ -538,8 +538,10 @@ export const registerRoutes = async (
|
|||||||
folderDAL,
|
folderDAL,
|
||||||
folderVersionDAL,
|
folderVersionDAL,
|
||||||
projectEnvDAL,
|
projectEnvDAL,
|
||||||
snapshotService
|
snapshotService,
|
||||||
|
projectDAL
|
||||||
});
|
});
|
||||||
|
|
||||||
const integrationAuthService = integrationAuthServiceFactory({
|
const integrationAuthService = integrationAuthServiceFactory({
|
||||||
integrationAuthDAL,
|
integrationAuthDAL,
|
||||||
integrationDAL,
|
integrationDAL,
|
||||||
|
|||||||
@@ -141,7 +141,7 @@ export const registerSecretFolderRouter = async (server: FastifyZodProvider) =>
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
body: z.object({
|
body: z.object({
|
||||||
workspaceId: z.string().trim().describe(FOLDERS.UPDATE.workspaceId),
|
projectSlug: z.string().trim().describe(FOLDERS.UPDATE.projectSlug),
|
||||||
folders: z
|
folders: z
|
||||||
.object({
|
.object({
|
||||||
id: z.string().describe(FOLDERS.UPDATE.folderId),
|
id: z.string().describe(FOLDERS.UPDATE.folderId),
|
||||||
@@ -160,20 +160,19 @@ export const registerSecretFolderRouter = async (server: FastifyZodProvider) =>
|
|||||||
},
|
},
|
||||||
onRequest: verifyAuth([AuthMode.JWT, AuthMode.API_KEY, AuthMode.SERVICE_TOKEN, AuthMode.IDENTITY_ACCESS_TOKEN]),
|
onRequest: verifyAuth([AuthMode.JWT, AuthMode.API_KEY, AuthMode.SERVICE_TOKEN, AuthMode.IDENTITY_ACCESS_TOKEN]),
|
||||||
handler: async (req) => {
|
handler: async (req) => {
|
||||||
const { newFolders, oldFolders } = await server.services.folder.updateManyFolders({
|
const { newFolders, oldFolders, projectId } = await server.services.folder.updateManyFolders({
|
||||||
folders: req.body.folders,
|
...req.body,
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorAuthMethod: req.permission.authMethod,
|
actorAuthMethod: req.permission.authMethod,
|
||||||
actorOrgId: req.permission.orgId,
|
actorOrgId: req.permission.orgId
|
||||||
projectId: req.body.workspaceId
|
|
||||||
});
|
});
|
||||||
|
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
req.body.folders.map(async (folder, ind) => {
|
req.body.folders.map(async (folder, ind) => {
|
||||||
await server.services.auditLog.createAuditLog({
|
await server.services.auditLog.createAuditLog({
|
||||||
...req.auditLogInfo,
|
...req.auditLogInfo,
|
||||||
projectId: req.body.workspaceId,
|
projectId,
|
||||||
event: {
|
event: {
|
||||||
type: EventType.UPDATE_FOLDER,
|
type: EventType.UPDATE_FOLDER,
|
||||||
metadata: {
|
metadata: {
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import { ProjectPermissionActions, ProjectPermissionSub } from "@app/ee/services
|
|||||||
import { TSecretSnapshotServiceFactory } from "@app/ee/services/secret-snapshot/secret-snapshot-service";
|
import { TSecretSnapshotServiceFactory } from "@app/ee/services/secret-snapshot/secret-snapshot-service";
|
||||||
import { BadRequestError } from "@app/lib/errors";
|
import { BadRequestError } from "@app/lib/errors";
|
||||||
|
|
||||||
|
import { TProjectDALFactory } from "../project/project-dal";
|
||||||
import { TProjectEnvDALFactory } from "../project-env/project-env-dal";
|
import { TProjectEnvDALFactory } from "../project-env/project-env-dal";
|
||||||
import { TSecretFolderDALFactory } from "./secret-folder-dal";
|
import { TSecretFolderDALFactory } from "./secret-folder-dal";
|
||||||
import {
|
import {
|
||||||
@@ -25,6 +26,7 @@ type TSecretFolderServiceFactoryDep = {
|
|||||||
folderDAL: TSecretFolderDALFactory;
|
folderDAL: TSecretFolderDALFactory;
|
||||||
projectEnvDAL: Pick<TProjectEnvDALFactory, "findOne">;
|
projectEnvDAL: Pick<TProjectEnvDALFactory, "findOne">;
|
||||||
folderVersionDAL: TSecretFolderVersionDALFactory;
|
folderVersionDAL: TSecretFolderVersionDALFactory;
|
||||||
|
projectDAL: Pick<TProjectDALFactory, "findProjectBySlug">;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type TSecretFolderServiceFactory = ReturnType<typeof secretFolderServiceFactory>;
|
export type TSecretFolderServiceFactory = ReturnType<typeof secretFolderServiceFactory>;
|
||||||
@@ -34,7 +36,8 @@ export const secretFolderServiceFactory = ({
|
|||||||
snapshotService,
|
snapshotService,
|
||||||
permissionService,
|
permissionService,
|
||||||
projectEnvDAL,
|
projectEnvDAL,
|
||||||
folderVersionDAL
|
folderVersionDAL,
|
||||||
|
projectDAL
|
||||||
}: TSecretFolderServiceFactoryDep) => {
|
}: TSecretFolderServiceFactoryDep) => {
|
||||||
const createFolder = async ({
|
const createFolder = async ({
|
||||||
projectId,
|
projectId,
|
||||||
@@ -125,11 +128,18 @@ export const secretFolderServiceFactory = ({
|
|||||||
const updateManyFolders = async ({
|
const updateManyFolders = async ({
|
||||||
actor,
|
actor,
|
||||||
actorId,
|
actorId,
|
||||||
projectId,
|
projectSlug,
|
||||||
actorAuthMethod,
|
actorAuthMethod,
|
||||||
actorOrgId,
|
actorOrgId,
|
||||||
folders
|
folders
|
||||||
}: TUpdateManyFoldersDTO) => {
|
}: TUpdateManyFoldersDTO) => {
|
||||||
|
const project = await projectDAL.findProjectBySlug(projectSlug, actorOrgId);
|
||||||
|
if (!project) {
|
||||||
|
throw new BadRequestError({ message: "Project not found" });
|
||||||
|
}
|
||||||
|
|
||||||
|
const projectId = project.id;
|
||||||
|
|
||||||
const { permission } = await permissionService.getProjectPermission(
|
const { permission } = await permissionService.getProjectPermission(
|
||||||
actor,
|
actor,
|
||||||
actorId,
|
actorId,
|
||||||
@@ -210,6 +220,7 @@ export const secretFolderServiceFactory = ({
|
|||||||
await Promise.all(result.map(async (res) => snapshotService.performSnapshot(res.newFolder.parentId as string)));
|
await Promise.all(result.map(async (res) => snapshotService.performSnapshot(res.newFolder.parentId as string)));
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
projectId,
|
||||||
newFolders: result.map((res) => res.newFolder),
|
newFolders: result.map((res) => res.newFolder),
|
||||||
oldFolders: result.map((res) => res.oldFolder)
|
oldFolders: result.map((res) => res.oldFolder)
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -14,13 +14,14 @@ export type TUpdateFolderDTO = {
|
|||||||
} & TProjectPermission;
|
} & TProjectPermission;
|
||||||
|
|
||||||
export type TUpdateManyFoldersDTO = {
|
export type TUpdateManyFoldersDTO = {
|
||||||
|
projectSlug: string;
|
||||||
folders: {
|
folders: {
|
||||||
environment: string;
|
environment: string;
|
||||||
path: string;
|
path: string;
|
||||||
id: string;
|
id: string;
|
||||||
name: string;
|
name: string;
|
||||||
}[];
|
}[];
|
||||||
} & TProjectPermission;
|
} & Omit<TProjectPermission, "projectId">;
|
||||||
|
|
||||||
export type TDeleteFolderDTO = {
|
export type TDeleteFolderDTO = {
|
||||||
environment: string;
|
environment: string;
|
||||||
|
|||||||
@@ -196,10 +196,10 @@ export const useUpdateFolderBatch = () => {
|
|||||||
const queryClient = useQueryClient();
|
const queryClient = useQueryClient();
|
||||||
|
|
||||||
return useMutation<{}, {}, TUpdateFolderBatchDTO>({
|
return useMutation<{}, {}, TUpdateFolderBatchDTO>({
|
||||||
mutationFn: async ({ projectId, folders }) => {
|
mutationFn: async ({ projectSlug, folders }) => {
|
||||||
const { data } = await apiRequest.patch("/api/v1/folders/batch", {
|
const { data } = await apiRequest.patch("/api/v1/folders/batch", {
|
||||||
folders,
|
projectSlug,
|
||||||
workspaceId: projectId
|
folders
|
||||||
});
|
});
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ export type TDeleteFolderDTO = {
|
|||||||
|
|
||||||
export type TUpdateFolderBatchDTO = {
|
export type TUpdateFolderBatchDTO = {
|
||||||
projectId: string;
|
projectId: string;
|
||||||
|
projectSlug: string;
|
||||||
folders: {
|
folders: {
|
||||||
name: string;
|
name: string;
|
||||||
environment: string;
|
environment: string;
|
||||||
|
|||||||
@@ -278,8 +278,9 @@ export const SecretOverviewPage = () => {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
await updateFolderBatch({
|
await updateFolderBatch({
|
||||||
projectId: workspaceId,
|
projectSlug,
|
||||||
folders: updatedFolders
|
folders: updatedFolders,
|
||||||
|
projectId: workspaceId
|
||||||
});
|
});
|
||||||
createNotification({
|
createNotification({
|
||||||
type: "success",
|
type: "success",
|
||||||
|
|||||||
Reference in New Issue
Block a user