Files
helm-dashboard/frontend/src/components/revision/RevisionsList.tsx
yuri-sakharov 7572f00f7c Huge bump of versions + husky + fixed DropDown key issue and pointer (#628)
* Bump lint-staged

* Check

* Check

* Added husky

* Check

* Check

* Check

* Check

* Check

* Check

* Check

* Check

* Fix husky

* Used * instead **/* in lint-staged

* Bump tailwindcss and related

* Added @tailwindcss/vite and removed postcss

* Added lint into staged

* Bump @babel/core and updated .prettierignore

* Removed tailwind.config.cjs

* Added ThemeInit

* Added cursor-pointer to Help dropdown

* Bump react-router

* Removed @types/uuid and react-router-dom

* Bump diff2html, prettier, @typescript-eslint/eslint-plugin, @typescript-eslint/parser

* removed vite-plugin-html-config and @babel/core

* removed "@eslint/eslintrc" and "@eslint/js"

* Removed redundant link

* Returned plugins and source to index.css

* Set dark to false in tailwindcss

* Fixed storybook

* Fixed useGetLatestVersion with correct gcTime: 0 option

* Added eslint-plugin-prettier

* Removed spaces

* ClustersList.tsx improved and type fixes for another files

* Repository.tsx improved

* Huge fix of types

* Huge fix of types missed

* Fixed type of SingleValue

* Added cursor pointer
2025-11-29 16:49:51 +00:00

97 lines
3.3 KiB
TypeScript

import { BsArrowDownRight, BsArrowUpRight } from "react-icons/bs";
import { useParams } from "react-router";
import { compare } from "compare-versions";
import { ReleaseRevision } from "../../data/types";
import { getAge } from "../../timeUtils";
import StatusLabel from "../common/StatusLabel";
import useNavigateWithSearchParams from "../../hooks/useNavigateWithSearchParams";
import { DateTime } from "luxon";
type RevisionsListProps = {
releaseRevisions: ReleaseRevision[];
selectedRevision: number;
};
export default function RevisionsList({
releaseRevisions,
selectedRevision,
}: RevisionsListProps) {
const navigate = useNavigateWithSearchParams();
const { namespace, chart } = useParams();
const changeRelease = (newRevision: number) => {
navigate(`/${namespace}/${chart}/installed/revision/${newRevision}`);
};
return (
<>
{releaseRevisions?.map((release, idx) => {
const hasMultipleReleases =
releaseRevisions.length > 1 && idx < releaseRevisions.length - 1;
const prevRelease = hasMultipleReleases
? releaseRevisions[idx + 1]
: null;
const isRollback = release.description.startsWith("Rollback to ");
return (
<div
title={
isRollback ? `Rollback to ${Number(release.revision) - 1}` : ""
}
onClick={() => changeRelease(release.revision)}
key={release.revision}
className={`flex flex-col border border-gray-200 rounded-md mx-5 p-2 gap-4 cursor-pointer ${
release.revision === selectedRevision
? "border-revision-dark bg-white"
: "border-revision-light bg-body-background"
}`}
>
<div className="flex flex-wrap row justify-between">
<StatusLabel status={release.status} isRollback={isRollback} />
<span className="font-bold">#{release.revision}</span>
</div>
<div
className="self-end text-muted text-xs flex flex-wrap gap-1"
style={{
width: "100%",
display: "flex",
justifyContent: "space-between",
}}
>
<div
style={{
display: "flex",
justifyContent: "space-between",
}}
>
{prevRelease
? compare(prevRelease.chart_ver, release.chart_ver, "!=") && (
<>
<span className="line-through">
{prevRelease.chart_ver}
</span>
{compare(
prevRelease.chart_ver,
release.chart_ver,
">"
) ? (
<BsArrowDownRight />
) : (
<BsArrowUpRight />
)}
<span>{release.chart_ver}</span>
</>
)
: ""}
</div>
<span title={DateTime.fromISO(release.updated).toString()}>
AGE:{getAge(release, releaseRevisions[idx - 1])}
</span>
</div>
</div>
);
})}
</>
);
}