mirror of
https://github.com/portainer/portainer.git
synced 2025-07-31 19:35:21 +02:00
refactor(docker/services): migrate service tasks to react [EE-4676] (#10328)
This commit is contained in:
parent
70455320be
commit
1fa63f6ab7
24 changed files with 175 additions and 259 deletions
|
@ -0,0 +1,51 @@
|
|||
import { CellContext } from '@tanstack/react-table';
|
||||
|
||||
import { useCurrentEnvironment } from '@/react/hooks/useCurrentEnvironment';
|
||||
import { isAgentEnvironment } from '@/react/portainer/environments/utils';
|
||||
|
||||
import { Link } from '@@/Link';
|
||||
|
||||
import { DecoratedTask } from '../types';
|
||||
import { getTableMeta } from '../meta';
|
||||
|
||||
import { columnHelper } from './helper';
|
||||
|
||||
export const task = columnHelper.accessor('Id', {
|
||||
header: 'Id',
|
||||
cell: Cell,
|
||||
});
|
||||
|
||||
function Cell({
|
||||
getValue,
|
||||
row: { original: item },
|
||||
table: {
|
||||
options: { meta },
|
||||
},
|
||||
}: CellContext<DecoratedTask, string>) {
|
||||
const environmentQuery = useCurrentEnvironment();
|
||||
|
||||
if (!environmentQuery.data) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const { serviceName } = getTableMeta(meta);
|
||||
|
||||
const value = getValue();
|
||||
const isAgent = isAgentEnvironment(environmentQuery.data.Type);
|
||||
|
||||
const name = `${serviceName}${item.Slot ? `.${item.Slot}` : ''}.${value}`;
|
||||
|
||||
return isAgent && item.Container ? (
|
||||
<Link
|
||||
to="docker.containers.container"
|
||||
params={{ id: item.Container.Id, nodeName: item.Container.NodeName }}
|
||||
className="monospaced"
|
||||
>
|
||||
{name}
|
||||
</Link>
|
||||
) : (
|
||||
<Link to="docker.tasks.task" params={{ id: value }} className="monospaced">
|
||||
{name}
|
||||
</Link>
|
||||
);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue