import { useCurrentStateAndParams } from '@uirouter/react';
import { useQueryClient } from '@tanstack/react-query';
import helm from '@/assets/ico/vendor/helm.svg?c';
import { PageHeader } from '@/react/components/PageHeader';
import { useEnvironmentId } from '@/react/hooks/useEnvironmentId';
import { Authorized } from '@/react/hooks/useUser';
import { WidgetTitle, WidgetBody, Widget, Loading } from '@@/Widget';
import { Card } from '@@/Card';
import { Alert } from '@@/Alert';
import { HelmRelease } from '../types';
import { HelmSummary } from './HelmSummary';
import { ReleaseTabs } from './ReleaseDetails/ReleaseTabs';
import { useHelmRelease } from './queries/useHelmRelease';
import { ChartActions } from './ChartActions/ChartActions';
import { HelmRevisionList } from './HelmRevisionList';
import { HelmRevisionListSheet } from './HelmRevisionListSheet';
import { useHelmHistory } from './queries/useHelmHistory';
export function HelmApplicationView() {
const environmentId = useEnvironmentId();
const queryClient = useQueryClient();
const { params } = useCurrentStateAndParams();
const { name, namespace, revision } = params;
const helmHistoryQuery = useHelmHistory(environmentId, name, namespace);
const latestRevision = helmHistoryQuery.data?.[0]?.version;
const earlistRevision =
helmHistoryQuery.data?.[helmHistoryQuery.data.length - 1]?.version;
// when loading the page fresh, the revision is undefined, so use the latest revision
const selectedRevision = revision ? parseInt(revision, 10) : latestRevision;
const helmReleaseQuery = useHelmRelease(environmentId, name, namespace, {
showResources: true,
revision: selectedRevision,
});
return (
<>