mirror of
https://github.com/portainer/portainer.git
synced 2025-07-24 07:49:41 +02:00
chore(deps): upgrade react-table to v8 [EE-4837] (#8245)
This commit is contained in:
parent
f20d3e72b9
commit
757461d58b
140 changed files with 1805 additions and 2872 deletions
|
@ -1,76 +1,68 @@
|
|||
import { CellProps, Column } from 'react-table';
|
||||
|
||||
import { Tooltip } from '@@/Tip/Tooltip';
|
||||
|
||||
import { Service } from '../../types';
|
||||
import { columnHelper } from './helper';
|
||||
|
||||
export const ports: Column<Service> = {
|
||||
Header: () => (
|
||||
<>
|
||||
Ports
|
||||
<Tooltip message="The format of Ports is port[:nodePort]/protocol. Protocol is either TCP, UDP or SCTP." />
|
||||
</>
|
||||
),
|
||||
|
||||
id: 'ports',
|
||||
accessor: (row) => {
|
||||
const ports = row.Ports;
|
||||
return ports.map(
|
||||
(port) => `${port.Port}:${port.NodePort}/${port.Protocol}`
|
||||
);
|
||||
},
|
||||
Cell: ({ row }: CellProps<Service>) => {
|
||||
if (!row.original.Ports.length) {
|
||||
return '-';
|
||||
}
|
||||
|
||||
return (
|
||||
export const ports = columnHelper.accessor(
|
||||
(row) =>
|
||||
row.Ports.map((port) => `${port.Port}:${port.NodePort}/${port.Protocol}`),
|
||||
{
|
||||
header: () => (
|
||||
<>
|
||||
{row.original.Ports.map((port, index) => {
|
||||
if (port.NodePort !== 0) {
|
||||
Ports
|
||||
<Tooltip message="The format of Ports is port[:nodePort]/protocol. Protocol is either TCP, UDP or SCTP." />
|
||||
</>
|
||||
),
|
||||
id: 'ports',
|
||||
cell: ({ row }) => {
|
||||
if (!row.original.Ports.length) {
|
||||
return '-';
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
{row.original.Ports.map((port, index) => {
|
||||
if (port.NodePort !== 0) {
|
||||
return (
|
||||
<div key={index}>
|
||||
{port.Port}:{port.NodePort}/{port.Protocol}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div key={index}>
|
||||
{port.Port}:{port.NodePort}/{port.Protocol}
|
||||
{port.Port}/{port.Protocol}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
})}
|
||||
</>
|
||||
);
|
||||
},
|
||||
sortingFn: (rowA, rowB) => {
|
||||
const a = rowA.original.Ports;
|
||||
const b = rowB.original.Ports;
|
||||
|
||||
return (
|
||||
<div key={index}>
|
||||
{port.Port}/{port.Protocol}
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</>
|
||||
);
|
||||
},
|
||||
disableFilters: true,
|
||||
canHide: true,
|
||||
if (!a.length && !b.length) return 0;
|
||||
|
||||
sortType: (rowA, rowB) => {
|
||||
const a = rowA.original.Ports;
|
||||
const b = rowB.original.Ports;
|
||||
if (!a.length) return 1;
|
||||
if (!b.length) return -1;
|
||||
|
||||
if (!a.length && !b.length) return 0;
|
||||
// sort order based on first port
|
||||
const portA = a[0].Port;
|
||||
const portB = b[0].Port;
|
||||
|
||||
if (!a.length) return 1;
|
||||
if (!b.length) return -1;
|
||||
if (portA === portB) {
|
||||
// longer list of ports is considered "greater"
|
||||
if (a.length < b.length) return -1;
|
||||
if (a.length > b.length) return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// sort order based on first port
|
||||
const portA = a[0].Port;
|
||||
const portB = b[0].Port;
|
||||
// now do a regular number sort
|
||||
if (portA < portB) return -1;
|
||||
if (portA > portB) return 1;
|
||||
|
||||
if (portA === portB) {
|
||||
// longer list of ports is considered "greater"
|
||||
if (a.length < b.length) return -1;
|
||||
if (a.length > b.length) return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// now do a regular number sort
|
||||
if (portA < portB) return -1;
|
||||
if (portA > portB) return 1;
|
||||
|
||||
return 0;
|
||||
},
|
||||
};
|
||||
},
|
||||
}
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue