import { AutoTooltip, DropdownButtons, icons } from '@gpustack/core-ui'; import { useIntl } from '@umijs/max'; import type { ColumnsType } from 'antd/lib/table'; import dayjs from 'dayjs'; import { useMemo } from 'react'; import { ListItem } from '../config/types'; const rowActionList = [ { label: 'common.button.edit', key: 'edit', locale: true, icon: icons.EditOutlined }, { label: 'common.button.delete', key: 'delete', locale: true, icon: icons.DeleteOutlined, props: { danger: true } } ]; interface ColumnsHookProps { handleSelect: (val: string, record: ListItem) => void; sortOrder: string[]; } const usePublicKeyColumns = ({ handleSelect, sortOrder }: ColumnsHookProps): ColumnsType => { const intl = useIntl(); return useMemo(() => { return [ { title: intl.formatMessage({ id: 'common.table.name' }), dataIndex: 'name', key: 'name', sorter: true, ellipsis: { showTitle: false }, render: (text: string, record: ListItem) => ( {record.displayName || text} ) }, { title: intl.formatMessage({ id: 'common.table.createTime' }), dataIndex: 'created_at', key: 'created_at', sorter: false, ellipsis: { showTitle: false }, render: (text: string) => ( {text ? dayjs(text).format('YYYY-MM-DD HH:mm:ss') : '-'} ) }, { title: intl.formatMessage({ id: 'common.table.operation' }), key: 'operation', dataIndex: 'operation', render: (_text, record) => ( handleSelect(val, record)} /> ) } ]; }, [handleSelect, sortOrder, intl]); }; export default usePublicKeyColumns;