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:
parent
1f2f4525e3
commit
99b39da03d
18 changed files with 199 additions and 228 deletions
5
app/react/edge/edge-groups/ListView/columns/helper.ts
Normal file
5
app/react/edge/edge-groups/ListView/columns/helper.ts
Normal file
|
@ -0,0 +1,5 @@
|
|||
import { createColumnHelper } from '@tanstack/react-table';
|
||||
|
||||
import { EdgeGroupListItemResponse } from '../../queries/useEdgeGroups';
|
||||
|
||||
export const columnHelper = createColumnHelper<EdgeGroupListItemResponse>();
|
13
app/react/edge/edge-groups/ListView/columns/index.ts
Normal file
13
app/react/edge/edge-groups/ListView/columns/index.ts
Normal 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'),
|
||||
}),
|
||||
];
|
34
app/react/edge/edge-groups/ListView/columns/name.tsx
Normal file
34
app/react/edge/edge-groups/ListView/columns/name.tsx
Normal 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>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue