mirror of https://github.com/portainer/portainer
fix(stacks): conditionally hide node and namespace stacks [EE-6949] (#11527)
Co-authored-by: testa113 <testa113>pull/11646/head
parent
7e9dd01265
commit
3ccbd40232
|
@ -1,5 +1,5 @@
|
||||||
import { Badge } from '@@/Badge';
|
import { Badge } from '@@/Badge';
|
||||||
|
|
||||||
export function ExternalBadge() {
|
export function ExternalBadge() {
|
||||||
return <Badge type="info">external</Badge>;
|
return <Badge type="info">External</Badge>;
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,6 @@ export function NodeApplicationsDatatable({
|
||||||
onRefresh: () => void;
|
onRefresh: () => void;
|
||||||
isLoading: boolean;
|
isLoading: boolean;
|
||||||
}) {
|
}) {
|
||||||
const columns = useColumns(true);
|
|
||||||
const tableState = useTableStateWithStorage<TableSettings>(
|
const tableState = useTableStateWithStorage<TableSettings>(
|
||||||
'kube-node-apps',
|
'kube-node-apps',
|
||||||
'Name',
|
'Name',
|
||||||
|
@ -34,6 +33,8 @@ export function NodeApplicationsDatatable({
|
||||||
);
|
);
|
||||||
useRepeater(tableState.autoRefreshRate, onRefresh);
|
useRepeater(tableState.autoRefreshRate, onRefresh);
|
||||||
|
|
||||||
|
const columns = useColumns();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Datatable
|
<Datatable
|
||||||
dataset={dataset}
|
dataset={dataset}
|
||||||
|
|
|
@ -1,19 +1,25 @@
|
||||||
import { useMemo } from 'react';
|
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
|
import { useMemo } from 'react';
|
||||||
|
|
||||||
import { humanize, truncate } from '@/portainer/filters/filters';
|
import { humanize, truncate } from '@/portainer/filters/filters';
|
||||||
|
import { usePublicSettings } from '@/react/portainer/settings/queries';
|
||||||
|
|
||||||
import { Link } from '@@/Link';
|
import { Link } from '@@/Link';
|
||||||
|
|
||||||
import { helper } from './columns.helper';
|
import { helper } from './columns.helper';
|
||||||
import { name } from './columns.name';
|
import { name } from './columns.name';
|
||||||
|
|
||||||
export function useColumns(areStacksVisible: boolean) {
|
export function useColumns() {
|
||||||
|
const hideStacksQuery = usePublicSettings<boolean>({
|
||||||
|
select: (settings) =>
|
||||||
|
settings.GlobalDeploymentOptions.hideStacksFunctionality,
|
||||||
|
});
|
||||||
|
|
||||||
return useMemo(
|
return useMemo(
|
||||||
() =>
|
() =>
|
||||||
_.compact([
|
_.compact([
|
||||||
name,
|
name,
|
||||||
areStacksVisible &&
|
!hideStacksQuery.data &&
|
||||||
helper.accessor('StackName', {
|
helper.accessor('StackName', {
|
||||||
header: 'Stack',
|
header: 'Stack',
|
||||||
cell: ({ getValue }) => getValue() || '-',
|
cell: ({ getValue }) => getValue() || '-',
|
||||||
|
@ -53,6 +59,6 @@ export function useColumns(areStacksVisible: boolean) {
|
||||||
cell: ({ getValue }) => humanize(getValue()),
|
cell: ({ getValue }) => humanize(getValue()),
|
||||||
}),
|
}),
|
||||||
]),
|
]),
|
||||||
[areStacksVisible]
|
[hideStacksQuery.data]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@ import {
|
||||||
} from '@@/datatables/types';
|
} from '@@/datatables/types';
|
||||||
|
|
||||||
import { NamespaceApp } from './types';
|
import { NamespaceApp } from './types';
|
||||||
import { columns } from './columns';
|
import { useColumns } from './columns';
|
||||||
|
|
||||||
interface TableSettings extends BasicTableSettings, RefreshableTableSettings {}
|
interface TableSettings extends BasicTableSettings, RefreshableTableSettings {}
|
||||||
|
|
||||||
|
@ -32,6 +32,7 @@ export function NamespaceAppsDatatable({
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
useRepeater(tableState.autoRefreshRate, onRefresh);
|
useRepeater(tableState.autoRefreshRate, onRefresh);
|
||||||
|
const columns = useColumns();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Datatable
|
<Datatable
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
import { createColumnHelper } from '@tanstack/react-table';
|
import { createColumnHelper } from '@tanstack/react-table';
|
||||||
|
import _ from 'lodash';
|
||||||
|
import { useMemo } from 'react';
|
||||||
|
|
||||||
import { humanize, truncate } from '@/portainer/filters/filters';
|
import { humanize, truncate } from '@/portainer/filters/filters';
|
||||||
|
import { usePublicSettings } from '@/react/portainer/settings/queries';
|
||||||
|
|
||||||
import { Link } from '@@/Link';
|
import { Link } from '@@/Link';
|
||||||
import { ExternalBadge } from '@@/Badge/ExternalBadge';
|
import { ExternalBadge } from '@@/Badge/ExternalBadge';
|
||||||
|
@ -12,7 +15,15 @@ import { NamespaceApp } from './types';
|
||||||
|
|
||||||
const columnHelper = createColumnHelper<NamespaceApp>();
|
const columnHelper = createColumnHelper<NamespaceApp>();
|
||||||
|
|
||||||
export const columns = [
|
export function useColumns() {
|
||||||
|
const hideStacksQuery = usePublicSettings<boolean>({
|
||||||
|
select: (settings) =>
|
||||||
|
settings.GlobalDeploymentOptions.hideStacksFunctionality,
|
||||||
|
});
|
||||||
|
|
||||||
|
return useMemo(
|
||||||
|
() =>
|
||||||
|
_.compact([
|
||||||
columnHelper.accessor('Name', {
|
columnHelper.accessor('Name', {
|
||||||
header: 'Name',
|
header: 'Name',
|
||||||
cell: ({ row: { original: item } }) => (
|
cell: ({ row: { original: item } }) => (
|
||||||
|
@ -32,6 +43,7 @@ export const columns = [
|
||||||
</>
|
</>
|
||||||
),
|
),
|
||||||
}),
|
}),
|
||||||
|
!hideStacksQuery.data &&
|
||||||
columnHelper.accessor('StackName', {
|
columnHelper.accessor('StackName', {
|
||||||
header: 'Stack',
|
header: 'Stack',
|
||||||
cell: ({ getValue }) => getValue() || '-',
|
cell: ({ getValue }) => getValue() || '-',
|
||||||
|
@ -41,7 +53,9 @@ export const columns = [
|
||||||
cell: ({ row: { original: item } }) => (
|
cell: ({ row: { original: item } }) => (
|
||||||
<>
|
<>
|
||||||
{truncate(item.Image, 64)}
|
{truncate(item.Image, 64)}
|
||||||
{item.Containers?.length > 1 && <>+ {item.Containers.length - 1}</>}
|
{item.Containers?.length > 1 && (
|
||||||
|
<>+ {item.Containers.length - 1}</>
|
||||||
|
)}
|
||||||
</>
|
</>
|
||||||
),
|
),
|
||||||
}),
|
}),
|
||||||
|
@ -53,4 +67,7 @@ export const columns = [
|
||||||
header: 'Memory',
|
header: 'Memory',
|
||||||
cell: ({ getValue }) => humanize(getValue()),
|
cell: ({ getValue }) => humanize(getValue()),
|
||||||
}),
|
}),
|
||||||
];
|
]),
|
||||||
|
[hideStacksQuery.data]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue