mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-14 21:51:56 +00:00
Addressed PR suggestions
This commit is contained in:
@@ -4,13 +4,19 @@ export enum ReservedFolders {
|
||||
SecretReplication = "__reserve_replication_"
|
||||
}
|
||||
|
||||
export enum PendingAction {
|
||||
Create = "create",
|
||||
Update = "update",
|
||||
Delete = "delete"
|
||||
}
|
||||
|
||||
export type TSecretFolder = {
|
||||
id: string;
|
||||
name: string;
|
||||
description?: string;
|
||||
parentId?: string | null;
|
||||
isPending?: boolean;
|
||||
pendingAction?: string;
|
||||
pendingAction?: PendingAction;
|
||||
};
|
||||
|
||||
export type TSecretFolderWithPath = TSecretFolder & { path: string };
|
||||
|
||||
@@ -9,6 +9,7 @@ import {
|
||||
|
||||
import { commitKeys } from "../folderCommits/queries";
|
||||
import { secretApprovalRequestKeys } from "../secretApprovalRequest/queries";
|
||||
import { PendingAction } from "../secretFolders/types";
|
||||
import { secretSnapshotKeys } from "../secretSnapshots/queries";
|
||||
import { secretKeys } from "./queries";
|
||||
import {
|
||||
@@ -440,9 +441,20 @@ export const useCreateCommit = () => {
|
||||
>({
|
||||
mutationFn: async ({ workspaceId, environment, secretPath, pendingChanges, message }) => {
|
||||
const transformedSecretUpdates = pendingChanges.secrets
|
||||
.filter((change) => change.type === "update")
|
||||
.filter((change) => change.type === PendingAction.Update)
|
||||
.map((change: PendingSecretUpdate) => {
|
||||
const updatePayload: any = {
|
||||
const updatePayload: {
|
||||
secretKey: string;
|
||||
newSecretName?: string;
|
||||
secretValue?: string;
|
||||
secretComment?: string;
|
||||
skipMultilineEncoding?: boolean;
|
||||
tagIds?: string[];
|
||||
secretMetadata?: {
|
||||
key: string;
|
||||
value: string;
|
||||
}[];
|
||||
} = {
|
||||
secretKey: change.secretKey
|
||||
};
|
||||
|
||||
@@ -469,14 +481,14 @@ export const useCreateCommit = () => {
|
||||
return updatePayload;
|
||||
});
|
||||
const { data } = await apiRequest.post("/api/v1/pit/batch/commit", {
|
||||
workspaceId,
|
||||
projectId: workspaceId,
|
||||
environment,
|
||||
secretPath,
|
||||
changes: {
|
||||
secrets: {
|
||||
create:
|
||||
pendingChanges.secrets
|
||||
.filter((change) => change.type === "create")
|
||||
.filter((change) => change.type === PendingAction.Create)
|
||||
.map((change) => ({
|
||||
secretKey: change.secretKey,
|
||||
secretValue: change.secretValue,
|
||||
@@ -485,13 +497,22 @@ export const useCreateCommit = () => {
|
||||
tagIds: change.tags?.map((tag) => tag.id),
|
||||
secretMetadata: change.secretMetadata
|
||||
})) || [],
|
||||
update: transformedSecretUpdates,
|
||||
delete: pendingChanges.secrets.filter((change) => change.type === "delete") || []
|
||||
update: transformedSecretUpdates || [],
|
||||
delete:
|
||||
pendingChanges.secrets.filter((change) => change.type === PendingAction.Delete) || []
|
||||
},
|
||||
folders: {
|
||||
create: pendingChanges.folders.filter((change) => change.type === "create") || [],
|
||||
update: pendingChanges.folders.filter((change) => change.type === "update") || [],
|
||||
delete: pendingChanges.folders.filter((change) => change.type === "delete") || []
|
||||
create:
|
||||
pendingChanges.folders.filter((change) => change.type === PendingAction.Create) || [],
|
||||
update:
|
||||
pendingChanges.folders
|
||||
.filter((change) => change.type === PendingAction.Update)
|
||||
.map((change) => ({
|
||||
...change,
|
||||
description: change.description || null
|
||||
})) || [],
|
||||
delete:
|
||||
pendingChanges.folders.filter((change) => change.type === PendingAction.Delete) || []
|
||||
}
|
||||
},
|
||||
message
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { ProjectPermissionActions } from "@app/context";
|
||||
|
||||
import { PendingAction } from "../secretFolders/types";
|
||||
import type { WsTag } from "../tags/types";
|
||||
|
||||
export enum SecretType {
|
||||
@@ -67,7 +68,7 @@ export type SecretV3RawSanitized = {
|
||||
secretReminderRecipients?: SecretReminderRecipient[];
|
||||
rotationId?: string;
|
||||
isPending?: boolean;
|
||||
pendingAction?: "create" | "update" | "delete";
|
||||
pendingAction?: PendingAction;
|
||||
};
|
||||
|
||||
export type SecretV3Raw = {
|
||||
|
||||
Reference in New Issue
Block a user