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

refactor(docker/services): migrate service tasks to react [EE-4676] (#10328)

This commit is contained in:
Chaim Lev-Ari 2023-10-23 13:52:49 +03:00 committed by GitHub
parent 70455320be
commit 1fa63f6ab7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
24 changed files with 175 additions and 259 deletions

View file

@ -0,0 +1,32 @@
import { Node } from 'docker-types/generated/1.41';
import { CellContext } from '@tanstack/react-table';
import { useNodes } from '@/react/docker/proxy/queries/nodes/useNodes';
import { useEnvironmentId } from '@/react/hooks/useEnvironmentId';
import { DecoratedTask } from '../types';
import { columnHelper } from './helper';
export const node = columnHelper.accessor('NodeId', {
header: 'Node',
cell: Cell,
});
function Cell({ getValue }: CellContext<DecoratedTask, string>) {
const environmentId = useEnvironmentId();
const nodesQuery = useNodes(environmentId);
const nodes = nodesQuery.data || [];
return getNodeName(getValue(), nodes);
}
function getNodeName(nodeId: string, nodes: Array<Node>) {
const node = nodes.find((node) => node.ID === nodeId);
if (node?.Description?.Hostname) {
return node.Description.Hostname;
}
return '';
}