2025-03-03 11:29:58 +13:00
|
|
|
import { useCurrentStateAndParams } from '@uirouter/react';
|
|
|
|
|
2025-04-10 16:08:24 +12:00
|
|
|
import helm from '@/assets/ico/vendor/helm.svg?c';
|
2025-03-03 11:29:58 +13:00
|
|
|
import { PageHeader } from '@/react/components/PageHeader';
|
2025-04-10 16:08:24 +12:00
|
|
|
import { useEnvironmentId } from '@/react/hooks/useEnvironmentId';
|
2025-04-23 08:58:34 +12:00
|
|
|
import { Authorized } from '@/react/hooks/useUser';
|
2025-03-03 11:29:58 +13:00
|
|
|
|
2025-04-10 16:08:24 +12:00
|
|
|
import { WidgetTitle, WidgetBody, Widget, Loading } from '@@/Widget';
|
|
|
|
import { Card } from '@@/Card';
|
|
|
|
import { Alert } from '@@/Alert';
|
|
|
|
|
2025-04-23 08:58:34 +12:00
|
|
|
import { HelmRelease } from '../types';
|
|
|
|
|
2025-04-10 16:08:24 +12:00
|
|
|
import { HelmSummary } from './HelmSummary';
|
|
|
|
import { ReleaseTabs } from './ReleaseDetails/ReleaseTabs';
|
|
|
|
import { useHelmRelease } from './queries/useHelmRelease';
|
2025-04-22 09:52:52 +12:00
|
|
|
import { ChartActions } from './ChartActions/ChartActions';
|
2025-03-03 11:29:58 +13:00
|
|
|
|
|
|
|
export function HelmApplicationView() {
|
2025-04-10 16:08:24 +12:00
|
|
|
const environmentId = useEnvironmentId();
|
2025-03-03 11:29:58 +13:00
|
|
|
const { params } = useCurrentStateAndParams();
|
2025-03-13 12:20:16 +13:00
|
|
|
const { name, namespace } = params;
|
2025-03-03 11:29:58 +13:00
|
|
|
|
2025-04-23 08:58:34 +12:00
|
|
|
const helmReleaseQuery = useHelmRelease(environmentId, name, namespace, {
|
|
|
|
showResources: true,
|
|
|
|
});
|
|
|
|
|
2025-03-03 11:29:58 +13:00
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<PageHeader
|
|
|
|
title="Helm details"
|
|
|
|
breadcrumbs={[
|
|
|
|
{ label: 'Applications', link: 'kubernetes.applications' },
|
|
|
|
name,
|
|
|
|
]}
|
|
|
|
reload
|
|
|
|
/>
|
|
|
|
|
|
|
|
<div className="row">
|
|
|
|
<div className="col-sm-12">
|
2025-04-10 16:08:24 +12:00
|
|
|
<Widget>
|
2025-04-22 09:52:52 +12:00
|
|
|
{name && (
|
|
|
|
<WidgetTitle icon={helm} title={name}>
|
2025-04-23 08:58:34 +12:00
|
|
|
<Authorized authorizations="K8sApplicationsW">
|
|
|
|
<ChartActions
|
|
|
|
environmentId={environmentId}
|
|
|
|
releaseName={name}
|
|
|
|
namespace={namespace}
|
|
|
|
currentRevision={helmReleaseQuery.data?.version}
|
|
|
|
/>
|
|
|
|
</Authorized>
|
2025-04-22 09:52:52 +12:00
|
|
|
</WidgetTitle>
|
|
|
|
)}
|
|
|
|
<WidgetBody>
|
2025-04-10 16:08:24 +12:00
|
|
|
<HelmDetails
|
2025-04-23 08:58:34 +12:00
|
|
|
isLoading={helmReleaseQuery.isInitialLoading}
|
|
|
|
isError={helmReleaseQuery.isError}
|
|
|
|
release={helmReleaseQuery.data}
|
2025-04-10 16:08:24 +12:00
|
|
|
/>
|
|
|
|
</WidgetBody>
|
|
|
|
</Widget>
|
2025-03-03 11:29:58 +13:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
}
|
2025-04-10 16:08:24 +12:00
|
|
|
|
|
|
|
type HelmDetailsProps = {
|
2025-04-23 08:58:34 +12:00
|
|
|
isLoading: boolean;
|
|
|
|
isError: boolean;
|
|
|
|
release: HelmRelease | undefined;
|
2025-04-10 16:08:24 +12:00
|
|
|
};
|
|
|
|
|
2025-04-23 08:58:34 +12:00
|
|
|
function HelmDetails({ isLoading, isError, release: data }: HelmDetailsProps) {
|
|
|
|
if (isLoading) {
|
2025-04-10 16:08:24 +12:00
|
|
|
return <Loading />;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isError) {
|
|
|
|
return (
|
|
|
|
<Alert color="error" title="Failed to load Helm application details" />
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2025-04-23 08:58:34 +12:00
|
|
|
if (!data) {
|
2025-04-10 16:08:24 +12:00
|
|
|
return <Alert color="error" title="No Helm application details found" />;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<>
|
2025-04-23 08:58:34 +12:00
|
|
|
<HelmSummary release={data} />
|
2025-04-10 16:08:24 +12:00
|
|
|
<div className="my-6 h-[1px] w-full bg-gray-5 th-dark:bg-gray-7 th-highcontrast:bg-white" />
|
|
|
|
<Card className="bg-inherit">
|
2025-04-23 08:58:34 +12:00
|
|
|
<ReleaseTabs release={data} />
|
2025-04-10 16:08:24 +12:00
|
|
|
</Card>
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
}
|