PIT: hide restore button for last commit

This commit is contained in:
carlosmonastyrski
2025-05-25 11:52:28 -03:00
parent 14362dbe6a
commit b812761bdd
5 changed files with 16 additions and 10 deletions
@@ -85,6 +85,7 @@ const commitSchema = z.object({
envId: z.string(), envId: z.string(),
createdAt: z.union([z.string(), z.date()]), createdAt: z.union([z.string(), z.date()]),
updatedAt: z.union([z.string(), z.date()]), updatedAt: z.union([z.string(), z.date()]),
isLatest: z.boolean().default(false),
changes: z.array(commitChangeSchema).optional() changes: z.array(commitChangeSchema).optional()
}); });
@@ -1279,7 +1279,8 @@ export const folderCommitServiceFactory = ({
}); });
const changes = await folderCommitChangesDAL.findByCommitId(commitId, projectId); const changes = await folderCommitChangesDAL.findByCommitId(commitId, projectId);
const commit = await folderCommitDAL.findById(commitId, undefined, projectId); const commit = await folderCommitDAL.findById(commitId, undefined, projectId);
return { ...commit, changes }; const latestCommit = await folderCommitDAL.findLatestCommit(commit.folderId, projectId);
return { ...commit, changes, isLatest: commit.id === latestCommit?.id };
}; };
/** /**
@@ -325,6 +325,7 @@ export const secretV2BridgeServiceFactory = ({
userId: inputSecret.type === SecretType.Personal ? actorId : null, userId: inputSecret.type === SecretType.Personal ? actorId : null,
tagIds: inputSecret.tagIds, tagIds: inputSecret.tagIds,
references: nestedReferences, references: nestedReferences,
metadata: secretMetadata ? JSON.stringify(secretMetadata) : [],
secretMetadata secretMetadata
} }
], ],
@@ -529,7 +530,7 @@ export const secretV2BridgeServiceFactory = ({
skipMultilineEncoding: inputSecret.skipMultilineEncoding, skipMultilineEncoding: inputSecret.skipMultilineEncoding,
key: inputSecret.newSecretName || secretName, key: inputSecret.newSecretName || secretName,
tags: inputSecret.tagIds, tags: inputSecret.tagIds,
metadata: JSON.stringify(secretMetadata), metadata: secretMetadata ? JSON.stringify(secretMetadata) : [],
secretMetadata, secretMetadata,
...encryptedValue ...encryptedValue
} }
@@ -13,6 +13,7 @@ export type CommitHistoryItem = {
envId: string; envId: string;
createdAt: string; createdAt: string;
updatedAt: string; updatedAt: string;
isLatest: boolean;
}; };
export type TFolderCommitChanges = { export type TFolderCommitChanges = {
@@ -291,14 +291,16 @@ export const CommitDetailsTab = ({
className="animate-in fade-in-50 zoom-in-95 min-w-[200px] p-1" className="animate-in fade-in-50 zoom-in-95 min-w-[200px] p-1"
style={{ marginTop: "0" }} style={{ marginTop: "0" }}
> >
<DropdownMenuItem {!parsedCommitDetails.changes.isLatest && (
className="h-10 w-full cursor-pointer px-3 py-2 text-sm transition-colors hover:bg-mineshaft-700" <DropdownMenuItem
onClick={() => goToRollbackPreview()} className="h-10 w-full cursor-pointer px-3 py-2 text-sm transition-colors hover:bg-mineshaft-700"
> onClick={() => goToRollbackPreview()}
<div className="flex w-full items-center justify-start"> >
<span>Restore entire folder</span> <div className="flex w-full items-center justify-start">
</div> <span>Restore entire folder</span>
</DropdownMenuItem> </div>
</DropdownMenuItem>
)}
<DropdownMenuItem <DropdownMenuItem
className="h-10 w-full cursor-pointer px-3 py-2 text-sm transition-colors hover:bg-mineshaft-700" className="h-10 w-full cursor-pointer px-3 py-2 text-sm transition-colors hover:bg-mineshaft-700"