// columns.ts import AutoTooltip from '@/components/auto-tooltip'; import DropdownButtons from '@/components/drop-down-buttons'; import { SealColumnProps } from '@/components/seal-table/types'; import StatusTag from '@/components/status-tag'; import { tableSorter } from '@/config/settings'; import { StarFilled } from '@ant-design/icons'; import { useIntl } from '@umijs/max'; import { Tooltip } from 'antd'; import dayjs from 'dayjs'; import { useMemo } from 'react'; import { ClusterStatus, ClusterStatusLabelMap, ProviderLabelMap, clusterActionList } from '../config'; import { ClusterListItem } from '../config/types'; const setActionsItems = (row: ClusterListItem) => { return clusterActionList.filter((item) => { if (item.provider) { return item.provider === row.provider; } return true; }); }; const useClusterColumns = ( handleSelect: (val: string, record: ClusterListItem) => void ): SealColumnProps[] => { const intl = useIntl(); return useMemo(() => { return [ { title: intl.formatMessage({ id: 'common.table.name' }), dataIndex: 'name', sorter: tableSorter(1), span: 3, render: (text: string, record: ClusterListItem) => ( <> {text} {record.is_default && ( )} ) }, { title: intl.formatMessage({ id: 'clusters.table.provider' }), dataIndex: 'provider', sorter: tableSorter(2), span: 3, render: (value: string) => ( {ProviderLabelMap[value]} ) }, { title: 'GPUs', dataIndex: 'gpus', span: 2, sorter: tableSorter(3), render: (value: number) => {value} }, { title: intl.formatMessage({ id: 'clusters.table.deployments' }), dataIndex: 'models', sorter: tableSorter(4), span: 3, render: (value: number) => {value} }, { title: intl.formatMessage({ id: 'resources.nodes' }), dataIndex: 'workers', sorter: tableSorter(5), span: 3, render: (value: number, record: ClusterListItem) => ( {record.ready_workers} / {record.workers} ) }, { title: intl.formatMessage({ id: 'common.table.status' }), dataIndex: 'state', span: 3, render: (value: number) => ( ) }, { title: intl.formatMessage({ id: 'common.table.createTime' }), dataIndex: 'created_at', sorter: tableSorter(6), span: 4, render: (value: string) => ( {dayjs(value).format('YYYY-MM-DD HH:mm:ss')} ) }, { title: intl.formatMessage({ id: 'common.table.operation' }), dataIndex: 'operations', span: 3, render: (value: string, record: ClusterListItem) => ( handleSelect(val, record)} > ) } ]; }, [handleSelect]); }; export default useClusterColumns;