1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-07-22 06:49:40 +02:00

feat(podman): support add podman envs in the wizard [r8s-20] (#12056)
Some checks failed
ci / build_images (map[arch:amd64 platform:linux version:]) (push) Has been cancelled
ci / build_images (map[arch:amd64 platform:windows version:1809]) (push) Has been cancelled
ci / build_images (map[arch:amd64 platform:windows version:ltsc2022]) (push) Has been cancelled
ci / build_images (map[arch:arm platform:linux version:]) (push) Has been cancelled
ci / build_images (map[arch:arm64 platform:linux version:]) (push) Has been cancelled
ci / build_images (map[arch:ppc64le platform:linux version:]) (push) Has been cancelled
/ triage (push) Has been cancelled
Lint / Run linters (push) Has been cancelled
Test / test-client (push) Has been cancelled
Test / test-server (map[arch:amd64 platform:linux]) (push) Has been cancelled
Test / test-server (map[arch:amd64 platform:windows version:1809]) (push) Has been cancelled
Test / test-server (map[arch:amd64 platform:windows version:ltsc2022]) (push) Has been cancelled
Test / test-server (map[arch:arm64 platform:linux]) (push) Has been cancelled
ci / build_manifests (push) Has been cancelled

This commit is contained in:
Ali 2024-09-25 11:55:07 +12:00 committed by GitHub
parent db616bc8a5
commit 32e94d4e4e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
108 changed files with 1921 additions and 272 deletions

View file

@ -1,58 +1,83 @@
import { ColumnDef } from '@tanstack/react-table';
import { List } from 'lucide-react';
import { useMemo } from 'react';
import { useCurrentStateAndParams } from '@uirouter/react';
import { useEnvironmentId } from '@/react/hooks/useEnvironmentId';
import { Datatable } from '@@/datatables';
import { createPersistedStore } from '@@/datatables/types';
import { useTableState } from '@@/datatables/useTableState';
import { useContainerTop } from '../queries/useContainerTop';
import { ContainerProcesses } from '../queries/types';
const tableKey = 'container-processes';
const store = createPersistedStore(tableKey);
export function ProcessesDatatable({
dataset,
headers,
}: {
dataset?: Array<Array<string | number>>;
headers?: Array<string>;
}) {
const tableState = useTableState(store, tableKey);
const rows = useMemo(() => {
if (!dataset || !headers) {
return [];
}
type ProcessRow = {
id: number;
};
return dataset.map((row, index) => ({
id: index,
...Object.fromEntries(
headers.map((header, index) => [header, row[index]])
),
}));
}, [dataset, headers]);
type ProcessesDatatableProps = {
rows: Array<ProcessRow>;
columns: Array<ColumnDef<ProcessRow>>;
};
const columns = useMemo(
() =>
headers
? headers.map(
(header) =>
({ header, accessorKey: header }) satisfies ColumnDef<{
[k: string]: string;
}>
)
: [],
[headers]
export function ProcessesDatatable() {
const {
params: { id: containerId },
} = useCurrentStateAndParams();
const environmentId = useEnvironmentId();
const topQuery = useContainerTop(
environmentId,
containerId,
(containerProcesses: ContainerProcesses) =>
parseContainerProcesses(containerProcesses)
);
const tableState = useTableState(store, tableKey);
return (
<Datatable
title="Processes"
titleIcon={List}
dataset={rows}
columns={columns}
dataset={topQuery.data?.rows ?? []}
columns={topQuery.data?.columns ?? []}
settingsManager={tableState}
disableSelect
isLoading={!dataset}
isLoading={topQuery.isLoading}
data-cy="docker-container-stats-processes-datatable"
/>
);
}
// transform the data from the API into the format expected by the datatable
function parseContainerProcesses(
containerProcesses: ContainerProcesses
): ProcessesDatatableProps {
const { Processes: processes, Titles: titles } = containerProcesses;
const rows = processes?.map((row, index) => {
// docker has the row data as an array of many strings
// podman has the row data as an array with a single string separated by one or many spaces
const processArray = row.length === 1 ? row[0].split(/\s+/) : row;
return {
id: index,
...Object.fromEntries(
titles.map((header, index) => [header, processArray[index]])
),
};
});
const columns = titles
? titles.map(
(header) =>
({ header, accessorKey: header }) satisfies ColumnDef<{
[k: string]: string;
}>
)
: [];
return {
rows,
columns,
};
}