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

refactor(edge/groups): migrate view to react [EE-4683] (#10592)

This commit is contained in:
Chaim Lev-Ari 2023-11-14 12:57:27 +02:00 committed by GitHub
parent 1f2f4525e3
commit 99b39da03d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 199 additions and 228 deletions

View file

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

View file

@ -0,0 +1,13 @@
import { columnHelper } from './helper';
import { name } from './name';
export const columns = [
name,
columnHelper.accessor((group) => group.TrustedEndpoints.length, {
header: 'Environments Count',
}),
columnHelper.accessor('Dynamic', {
header: 'Group Type',
cell: ({ getValue }) => (getValue() ? 'Dynamic' : 'Static'),
}),
];

View file

@ -0,0 +1,34 @@
import { CellContext } from '@tanstack/react-table';
import { Link } from '@@/Link';
import { EdgeGroupListItemResponse } from '../../queries/useEdgeGroups';
import { columnHelper } from './helper';
export const name = columnHelper.accessor('Name', {
header: 'Name',
cell: NameCell,
});
function NameCell({
renderValue,
row: { original: item },
}: CellContext<EdgeGroupListItemResponse, unknown>) {
const name = renderValue() || '';
if (typeof name !== 'string') {
return null;
}
return (
<>
<Link to=".edit" params={{ groupId: item.Id }} title={name}>
{name}
</Link>
{(item.HasEdgeJob || item.HasEdgeStack) && (
<span className="label label-info image-tag space-left">in use</span>
)}
</>
);
}