1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-07-23 07:19:41 +02:00

fix(stacks): conditionally hide node and namespace stacks [EE-6949] (#11527)
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
ci / build_images (map[arch:s390x 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

Co-authored-by: testa113 <testa113>
This commit is contained in:
Ali 2024-04-19 17:33:22 +12:00 committed by GitHub
parent 7e9dd01265
commit 3ccbd40232
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 74 additions and 49 deletions

View file

@ -1,6 +1,9 @@
import { createColumnHelper } from '@tanstack/react-table';
import _ from 'lodash';
import { useMemo } from 'react';
import { humanize, truncate } from '@/portainer/filters/filters';
import { usePublicSettings } from '@/react/portainer/settings/queries';
import { Link } from '@@/Link';
import { ExternalBadge } from '@@/Badge/ExternalBadge';
@ -12,45 +15,59 @@ import { NamespaceApp } from './types';
const columnHelper = createColumnHelper<NamespaceApp>();
export const columns = [
columnHelper.accessor('Name', {
header: 'Name',
cell: ({ row: { original: item } }) => (
<>
<Link
to="kubernetes.applications.application"
params={{ name: item.Name, namespace: item.ResourcePool }}
data-cy={`application-link-${item.Name}`}
>
{item.Name}
</Link>
{isExternalApplication({ metadata: item.Metadata }) && (
<div className="ml-2">
<ExternalBadge />
</div>
)}
</>
),
}),
columnHelper.accessor('StackName', {
header: 'Stack',
cell: ({ getValue }) => getValue() || '-',
}),
columnHelper.accessor('Image', {
header: 'Image',
cell: ({ row: { original: item } }) => (
<>
{truncate(item.Image, 64)}
{item.Containers?.length > 1 && <>+ {item.Containers.length - 1}</>}
</>
),
}),
columnHelper.accessor('CPU', {
header: 'CPU',
cell: ({ getValue }) => cpuHumanValue(getValue()),
}),
columnHelper.accessor('Memory', {
header: 'Memory',
cell: ({ getValue }) => humanize(getValue()),
}),
];
export function useColumns() {
const hideStacksQuery = usePublicSettings<boolean>({
select: (settings) =>
settings.GlobalDeploymentOptions.hideStacksFunctionality,
});
return useMemo(
() =>
_.compact([
columnHelper.accessor('Name', {
header: 'Name',
cell: ({ row: { original: item } }) => (
<>
<Link
to="kubernetes.applications.application"
params={{ name: item.Name, namespace: item.ResourcePool }}
data-cy={`application-link-${item.Name}`}
>
{item.Name}
</Link>
{isExternalApplication({ metadata: item.Metadata }) && (
<div className="ml-2">
<ExternalBadge />
</div>
)}
</>
),
}),
!hideStacksQuery.data &&
columnHelper.accessor('StackName', {
header: 'Stack',
cell: ({ getValue }) => getValue() || '-',
}),
columnHelper.accessor('Image', {
header: 'Image',
cell: ({ row: { original: item } }) => (
<>
{truncate(item.Image, 64)}
{item.Containers?.length > 1 && (
<>+ {item.Containers.length - 1}</>
)}
</>
),
}),
columnHelper.accessor('CPU', {
header: 'CPU',
cell: ({ getValue }) => cpuHumanValue(getValue()),
}),
columnHelper.accessor('Memory', {
header: 'Memory',
cell: ({ getValue }) => humanize(getValue()),
}),
]),
[hideStacksQuery.data]
);
}