PIT: UI views

This commit is contained in:
carlosmonastyrski
2025-05-20 08:22:14 -03:00
parent 8bfd3913da
commit 6319f53802
47 changed files with 4134 additions and 196 deletions
@@ -39,6 +39,7 @@ import {
} from "@app/hooks/api";
import { useGetProjectSecretsDetails } from "@app/hooks/api/dashboard";
import { DashboardSecretsOrderBy } from "@app/hooks/api/dashboard/types";
import { useGetFolderCommitsCount } from "@app/hooks/api/folderCommits";
import { OrderByDirection } from "@app/hooks/api/generic/types";
import { ProjectType } from "@app/hooks/api/workspace/types";
import { hasSecretReadValueOrDescribePermission } from "@app/lib/fn/permission";
@@ -265,6 +266,17 @@ const Page = () => {
limit: 10
});
const {
data: { count: folderCommitsCount, folderId } = { count: 0, folderId: "" },
isPending: isFolderCommitsCountLoading,
isFetching: isFolderCommitsCountFetching
} = useGetFolderCommitsCount({
directory: secretPath,
workspaceId,
environment,
isPaused: !canDoReadRollback
});
const {
data: snapshotCount,
isPending: isSnapshotCountLoading,
@@ -276,6 +288,39 @@ const Page = () => {
isPaused: !canDoReadRollback
});
const isPITEnabled = true;
const changesCount = useMemo(() => {
return isPITEnabled ? folderCommitsCount : snapshotCount;
}, [folderCommitsCount, snapshotCount]);
const isChangesCountPending = useMemo(() => {
return isPITEnabled ? isFolderCommitsCountLoading || isSnapshotCountLoading : false;
}, [isFolderCommitsCountLoading, isSnapshotCountLoading]);
const isChangesCountFetching = useMemo(() => {
return isPITEnabled ? isFolderCommitsCountFetching || isSnapshotCountFetching : false;
}, [isFolderCommitsCountFetching, isSnapshotCountFetching]);
const handleOnClickRollbackMode = () => {
if (isPITEnabled) {
navigate({
to: `/${ProjectType.SecretManager}/$projectId/commits/$environment/$folderId` as const,
params: {
projectId: workspaceId,
folderId,
environment
},
search: (query) => ({
...query,
secretPath
})
});
} else {
handlePopUpToggle("snapshots", true);
}
};
const noAccessSecretCount = Math.max(
(page * perPage > totalCount ? totalCount % perPage : perPage) -
(imports?.length || 0) -
@@ -436,13 +481,14 @@ const Page = () => {
onVisibilityToggle={handleToggleVisibility}
onSearchChange={handleSearchChange}
onToggleTagFilter={handleTagToggle}
snapshotCount={snapshotCount || 0}
isSnapshotCountLoading={isSnapshotCountLoading && isSnapshotCountFetching}
snapshotCount={changesCount || 0}
isSnapshotCountLoading={isChangesCountPending && isChangesCountFetching}
onToggleRowType={handleToggleRowType}
onClickRollbackMode={() => handlePopUpToggle("snapshots", true)}
onClickRollbackMode={handleOnClickRollbackMode}
protectedBranchPolicyName={boardPolicy?.name}
importedBy={importedBy}
usedBySecretSyncs={usedBySecretSyncs}
isPITEnabled={isPITEnabled}
/>
<div className="thin-scrollbar mt-3 overflow-y-auto overflow-x-hidden rounded-md rounded-b-none bg-mineshaft-800 text-left text-sm text-bunker-300">
<div className="flex flex-col" id="dashboard">
@@ -606,7 +652,7 @@ const Page = () => {
secretPath={secretPath}
secrets={secrets}
folders={folders}
snapshotCount={snapshotCount}
snapshotCount={changesCount}
onGoBack={handleResetSnapshot}
onClickListSnapshot={() => handlePopUpToggle("snapshots", true)}
/>