2022-02-14 14:44:55 +00:00
|
|
|
import { CellProps, Column } from 'react-table';
|
2022-01-23 19:48:04 +00:00
|
|
|
|
2022-10-23 06:53:25 +00:00
|
|
|
import { Environment } from '@/react/portainer/environments/types';
|
2022-06-17 16:18:42 +00:00
|
|
|
|
|
|
|
import { Link } from '@@/Link';
|
|
|
|
import { ExpandingCell } from '@@/datatables/ExpandingCell';
|
2022-05-23 07:57:22 +00:00
|
|
|
|
|
|
|
import { useRowContext } from './RowContext';
|
2022-01-23 19:48:04 +00:00
|
|
|
|
|
|
|
export const name: Column<Environment> = {
|
|
|
|
Header: 'Name',
|
|
|
|
accessor: (row) => row.Name,
|
|
|
|
id: 'name',
|
|
|
|
Cell: NameCell,
|
|
|
|
disableFilters: true,
|
|
|
|
Filter: () => null,
|
|
|
|
canHide: false,
|
|
|
|
sortType: 'string',
|
|
|
|
};
|
|
|
|
|
2022-02-14 14:44:55 +00:00
|
|
|
export function NameCell({ value: name, row }: CellProps<Environment>) {
|
|
|
|
const { isOpenAmtEnabled } = useRowContext();
|
|
|
|
const showExpandedRow = !!(
|
|
|
|
isOpenAmtEnabled &&
|
|
|
|
row.original.AMTDeviceGUID &&
|
|
|
|
row.original.AMTDeviceGUID.length > 0
|
|
|
|
);
|
2022-01-23 19:48:04 +00:00
|
|
|
return (
|
2022-02-14 14:44:55 +00:00
|
|
|
<ExpandingCell row={row} showExpandArrow={showExpandedRow}>
|
2022-01-23 19:48:04 +00:00
|
|
|
<Link
|
|
|
|
to="portainer.endpoints.endpoint"
|
|
|
|
params={{ id: row.original.Id }}
|
|
|
|
title={name}
|
|
|
|
>
|
|
|
|
{name}
|
|
|
|
</Link>
|
|
|
|
</ExpandingCell>
|
|
|
|
);
|
|
|
|
}
|