1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-08-05 05:45:22 +02:00

feat(helm): update helm view [r8s-256] (#582)

Co-authored-by: Cara Ryan <cara.ryan@portainer.io>
Co-authored-by: James Player <james.player@portainer.io>
Co-authored-by: stevensbkang <skan070@gmail.com>
This commit is contained in:
Ali 2025-04-10 16:08:24 +12:00 committed by GitHub
parent 46eddbe7b9
commit 0ca9321db1
57 changed files with 2635 additions and 222 deletions

View file

@ -0,0 +1,46 @@
import { useState } from 'react';
import { CellContext } from '@tanstack/react-table';
import { FileText } from 'lucide-react';
import { Button } from '@@/buttons';
import { Icon } from '@@/Icon';
import { ResourceRow } from '../types';
import { DescribeModal } from '../DescribeModal';
import { columnHelper } from './helper';
export const actions = columnHelper.accessor((row) => row.status.label, {
header: 'Actions',
id: 'actions',
cell: Cell,
enableSorting: false,
});
function Cell({ row }: CellContext<ResourceRow, string>) {
const { describe } = row.original;
const [modalOpen, setModalOpen] = useState(false);
return (
<>
<Button
color="link"
data-cy="helm-resource-describe"
onClick={() => setModalOpen(true)}
className="pl-0 !ml-0"
>
<Icon icon={FileText} />
Describe
</Button>
{modalOpen && (
<DescribeModal
name={describe.name}
resourceType={describe.resourceType}
namespace={describe.namespace}
onDismiss={() => setModalOpen(false)}
/>
)}
</>
);
}

View file

@ -0,0 +1,5 @@
import { createColumnHelper } from '@tanstack/react-table';
import { ResourceRow } from '../types';
export const columnHelper = createColumnHelper<ResourceRow>();

View file

@ -0,0 +1,7 @@
import { name } from './name';
import { resourceType } from './resourceType';
import { status } from './status';
import { statusMessage } from './statusMessage';
import { actions } from './actions';
export const columns = [name, resourceType, status, statusMessage, actions];

View file

@ -0,0 +1,33 @@
import { CellContext } from '@tanstack/react-table';
import { Link } from '@@/Link';
import { ResourceRow } from '../types';
import { columnHelper } from './helper';
export const name = columnHelper.accessor((row) => row.name.label, {
header: 'Name',
cell: Cell,
id: 'name',
});
function Cell({ row }: CellContext<ResourceRow, string>) {
const { name } = row.original;
if (name.link && name.link.to) {
return (
<Link
to={name.link.to}
params={name.link.params}
title={name.label}
className="w-fit max-w-xs truncate xl:max-w-sm 2xl:max-w-md"
data-cy={`helm-resource-link-${name.label}`}
>
{name.label}
</Link>
);
}
return name.label;
}

View file

@ -0,0 +1,6 @@
import { columnHelper } from './helper';
export const resourceType = columnHelper.accessor((row) => row.resourceType, {
header: 'Resource type',
id: 'resourceType',
});

View file

@ -0,0 +1,18 @@
import { CellContext } from '@tanstack/react-table';
import { StatusBadge } from '@@/StatusBadge';
import { ResourceRow } from '../types';
import { columnHelper } from './helper';
export const status = columnHelper.accessor((row) => row.status.label, {
header: 'Status',
id: 'status',
cell: Cell,
});
function Cell({ row }: CellContext<ResourceRow, string>) {
const { status } = row.original;
return <StatusBadge color={status.type}>{status.label}</StatusBadge>;
}

View file

@ -0,0 +1,11 @@
import { columnHelper } from './helper';
export const statusMessage = columnHelper.accessor((row) => row.statusMessage, {
header: 'Status message',
id: 'statusMessage',
cell: ({ row }) => (
<div className="whitespace-pre-wrap">
<span>{row.original.statusMessage || '-'}</span>
</div>
),
});