mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-14 11:29:42 +00:00
PIT: address PR suggestions
This commit is contained in:
@@ -53,11 +53,12 @@ const fetchFolderCommitsCount = async ({
|
||||
directory?: string;
|
||||
}) => {
|
||||
const res = await apiRequest.get<{ count: number; folderId: string }>(
|
||||
`/api/v1/pit/commits/count/${workspaceId}`,
|
||||
"/api/v1/pit/commits/count",
|
||||
{
|
||||
params: {
|
||||
environment,
|
||||
path: directory
|
||||
path: directory,
|
||||
workspaceId
|
||||
}
|
||||
}
|
||||
);
|
||||
@@ -69,10 +70,11 @@ const fetchFolderCommitHistory = async (
|
||||
environment: string,
|
||||
directory: string
|
||||
): Promise<CommitHistoryItem[]> => {
|
||||
const res = await apiRequest.get<CommitHistoryItem[]>(`/api/v1/pit/commits/${workspaceId}`, {
|
||||
const res = await apiRequest.get<CommitHistoryItem[]>("/api/v1/pit/commits", {
|
||||
params: {
|
||||
environment,
|
||||
path: directory
|
||||
path: directory,
|
||||
workspaceId
|
||||
}
|
||||
});
|
||||
return res.data;
|
||||
@@ -80,7 +82,12 @@ const fetchFolderCommitHistory = async (
|
||||
|
||||
export const fetchCommitDetails = async (workspaceId: string, commitId: string) => {
|
||||
const { data } = await apiRequest.get<CommitWithChanges>(
|
||||
`/api/v1/pit/commits/${workspaceId}/${commitId}/changes`
|
||||
`/api/v1/pit/commits/${commitId}/changes`,
|
||||
{
|
||||
params: {
|
||||
workspaceId
|
||||
}
|
||||
}
|
||||
);
|
||||
return data;
|
||||
};
|
||||
@@ -89,18 +96,19 @@ export const fetchRollbackPreview = async (
|
||||
folderId: string,
|
||||
commitId: string,
|
||||
envId: string,
|
||||
projectId: string,
|
||||
workspaceId: string,
|
||||
deepRollback: boolean,
|
||||
secretPath: string
|
||||
): Promise<RollbackPreview[]> => {
|
||||
const { data } = await apiRequest.get<RollbackPreview[]>(
|
||||
`/api/v1/pit/commits/${projectId}/${commitId}/compare`,
|
||||
`/api/v1/pit/commits/${commitId}/compare`,
|
||||
{
|
||||
params: {
|
||||
folderId,
|
||||
envId,
|
||||
deepRollback,
|
||||
secretPath
|
||||
secretPath,
|
||||
workspaceId
|
||||
}
|
||||
}
|
||||
);
|
||||
@@ -110,26 +118,30 @@ export const fetchRollbackPreview = async (
|
||||
const fetchRollback = async (
|
||||
folderId: string,
|
||||
commitId: string,
|
||||
projectId: string,
|
||||
workspaceId: string,
|
||||
deepRollback: boolean,
|
||||
message?: string,
|
||||
envId?: string
|
||||
) => {
|
||||
const { data } = await apiRequest.post<{ success: boolean }>(
|
||||
`/api/v1/pit/commits/${projectId}/${commitId}/rollback`,
|
||||
`/api/v1/pit/commits/${commitId}/rollback`,
|
||||
{
|
||||
folderId,
|
||||
deepRollback,
|
||||
message,
|
||||
envId
|
||||
envId,
|
||||
workspaceId
|
||||
}
|
||||
);
|
||||
return data;
|
||||
};
|
||||
|
||||
const fetchRevert = async (commitId: string, projectId: string) => {
|
||||
const fetchRevert = async (commitId: string, workspaceId: string) => {
|
||||
const { data } = await apiRequest.post<{ success: boolean; message: string }>(
|
||||
`/api/v1/pit/commits/${projectId}/${commitId}/revert`
|
||||
`/api/v1/pit/commits/${commitId}/revert`,
|
||||
{
|
||||
workspaceId
|
||||
}
|
||||
);
|
||||
return data;
|
||||
};
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { SecretVersions } from "../types";
|
||||
import { CommitType, SecretVersions } from "../types";
|
||||
|
||||
export type CommitHistoryItem = {
|
||||
id: string;
|
||||
@@ -18,7 +18,7 @@ export type CommitHistoryItem = {
|
||||
export type TFolderCommitChanges = {
|
||||
id: string;
|
||||
folderCommitId: string;
|
||||
changeType: "add" | "delete";
|
||||
changeType: CommitType;
|
||||
isUpdate: boolean;
|
||||
secretVersionId: string | null;
|
||||
folderVersionId: string | null;
|
||||
|
||||
+1
-1
@@ -1291,7 +1291,7 @@ const SecretsManagerPermissionSubjects = (enabled = false) => ({
|
||||
[ProjectPermissionSub.Tags]: enabled,
|
||||
[ProjectPermissionSub.Webhooks]: enabled,
|
||||
[ProjectPermissionSub.IpAllowList]: enabled,
|
||||
[ProjectPermissionSub.SecretRollback]: enabled,
|
||||
[ProjectPermissionSub.SecretRollback]: false,
|
||||
[ProjectPermissionSub.SecretRotation]: enabled,
|
||||
[ProjectPermissionSub.ServiceTokens]: enabled,
|
||||
[ProjectPermissionSub.Commits]: enabled
|
||||
|
||||
+34
-31
@@ -213,38 +213,35 @@ export const RollbackPreviewTab = (): JSX.Element => {
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
{deepRollback && nestedFolderChanges.length > 0 && (
|
||||
<>
|
||||
<div className="border-b border-mineshaft-600 bg-mineshaft-800 px-4 py-2">
|
||||
<span className="text-sm font-semibold text-white">
|
||||
Affected Child Folders
|
||||
</span>
|
||||
<span className="text-sm font-semibold text-white">Affected Child Folders</span>
|
||||
</div>
|
||||
{(nestedFolderChanges.map((folder) => (
|
||||
<div
|
||||
key={folder.folderId}
|
||||
className={`cursor-pointer border-b border-mineshaft-600 ${
|
||||
selectedFolderId === folder.folderId ? "bg-mineshaft-700" : ""
|
||||
}`}
|
||||
onClick={() => setSelectedFolderId(folder.folderId)}
|
||||
>
|
||||
<div className="flex items-center justify-between px-4 py-2">
|
||||
<div className="flex items-center">
|
||||
<FontAwesomeIcon icon={faFolder} className="mr-2 text-yellow-500" size="sm" />
|
||||
<span className="max-w-[150px] truncate text-sm font-medium text-white">
|
||||
{folder.folderPath || folder.folderName}
|
||||
</span>
|
||||
</div>
|
||||
{folder.changes.length > 0 && (
|
||||
<span className="rounded-full bg-mineshaft-600 px-2 py-0.5 text-xs text-gray-300">
|
||||
{folder.changes.length}
|
||||
</span>
|
||||
)}
|
||||
{nestedFolderChanges.map((folder) => (
|
||||
<div
|
||||
key={folder.folderId}
|
||||
className={`cursor-pointer border-b border-mineshaft-600 ${
|
||||
selectedFolderId === folder.folderId ? "bg-mineshaft-700" : ""
|
||||
}`}
|
||||
onClick={() => setSelectedFolderId(folder.folderId)}
|
||||
>
|
||||
<div className="flex items-center justify-between px-4 py-2">
|
||||
<div className="flex items-center">
|
||||
<FontAwesomeIcon icon={faFolder} className="mr-2 text-yellow-500" size="sm" />
|
||||
<span className="max-w-[150px] truncate text-sm font-medium text-white">
|
||||
{folder.folderPath || folder.folderName}
|
||||
</span>
|
||||
</div>
|
||||
{folder.changes.length > 0 && (
|
||||
<span className="rounded-full bg-mineshaft-600 px-2 py-0.5 text-xs text-gray-300">
|
||||
{folder.changes.length}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
))
|
||||
)}
|
||||
</div>
|
||||
))}
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
@@ -305,10 +302,10 @@ export const RollbackPreviewTab = (): JSX.Element => {
|
||||
description="This will restore all changes to how they appeared at the point in time of this commit. Any modifications made after this commit will be undone."
|
||||
/>
|
||||
|
||||
<div className="flex w-full border border-mineshaft-600">
|
||||
{renderSidebar()}
|
||||
{renderMainContent()}
|
||||
</div>
|
||||
<div className="flex w-full border border-mineshaft-600">
|
||||
{renderSidebar()}
|
||||
{renderMainContent()}
|
||||
</div>
|
||||
|
||||
<div className="border-x border-mineshaft-600 bg-mineshaft-800 px-6 py-3">
|
||||
<div className="flex items-center justify-end">
|
||||
@@ -353,7 +350,13 @@ export const RollbackPreviewTab = (): JSX.Element => {
|
||||
}}
|
||||
colorSchema="primary"
|
||||
className="px-6 py-2"
|
||||
isDisabled={message.length === 0 || !rollbackChangesNested || !rollbackChangesNested?.some((folder) => folder.changes.length > 0)}
|
||||
isDisabled={
|
||||
message.length === 0 ||
|
||||
!rollbackChangesNested ||
|
||||
!rollbackChangesNested?.some((folder) => {
|
||||
return folder.changes.length > 0;
|
||||
})
|
||||
}
|
||||
>
|
||||
Restore
|
||||
</Button>
|
||||
|
||||
Reference in New Issue
Block a user