feat(gpu-service): add sliceable tag and horizontal scroll to instance types table

This commit is contained in:
jialin
2026-07-22 15:52:17 +08:00
parent 35d5681008
commit 1655549f31
3 changed files with 35 additions and 7 deletions
+4
View File
@@ -98,6 +98,10 @@ Compose layout with Ant components, not hand-written `display: flex`.
Drive spacing with the theme scale (`Flex`/`Space` `gap`, or `var(--ant-*)` spacing tokens), not scattered `px` literals. Drive spacing with the theme scale (`Flex`/`Space` `gap`, or `var(--ant-*)` spacing tokens), not scattered `px` literals.
## Tables
- **Horizontally scrollable table**: set `scroll={{ x: 'max-content' }}` **and** add `className="scroll-table"` on the `Table`. The class styles the horizontal scroll to match the design; without it the scroll works but looks off.
# Naming conventions # Naming conventions
A page module lives under `src/pages/{module}` with this sub-structure: `components/`, `config/`, `forms/`, `hooks/`, `services/`, `index.tsx`. File naming: A page module lives under `src/pages/{module}` with this sub-structure: `components/`, `config/`, `forms/`, `hooks/`, `services/`, `index.tsx`. File naming:
@@ -7,7 +7,7 @@ import {
ThemeTag ThemeTag
} from '@gpustack/core-ui'; } from '@gpustack/core-ui';
import { useIntl } from '@umijs/max'; import { useIntl } from '@umijs/max';
import { Space, Tooltip } from 'antd'; import { Flex, Space, Tooltip } from 'antd';
import type { ColumnsType } from 'antd/lib/table'; import type { ColumnsType } from 'antd/lib/table';
import _ from 'lodash'; import _ from 'lodash';
import { useMemo } from 'react'; import { useMemo } from 'react';
@@ -65,7 +65,7 @@ const useInstanceTypeColumns = ({
key: 'name', key: 'name',
ellipsis: { showTitle: false }, ellipsis: { showTitle: false },
render: (text: string) => ( render: (text: string) => (
<AutoTooltip ghost maxWidth={240} title={text}> <AutoTooltip ghost minWidth={20} maxWidth={200} title={text}>
<span className="text-primary">{text || '-'}</span> <span className="text-primary">{text || '-'}</span>
</AutoTooltip> </AutoTooltip>
) )
@@ -75,10 +75,24 @@ const useInstanceTypeColumns = ({
dataIndex: ['spec', 'product'], dataIndex: ['spec', 'product'],
key: 'product', key: 'product',
ellipsis: { showTitle: false }, ellipsis: { showTitle: false },
render: (text: string) => ( render: (text: string, record: ListItem) => (
<AutoTooltip ghost maxWidth={200}> <Flex
gap={4}
align="center"
style={{ maxWidth: '100%', minWidth: 0 }}
>
<AutoTooltip ghost minWidth={20} maxWidth={200}>
{text || '-'} {text || '-'}
</AutoTooltip> </AutoTooltip>
{record.spec?.sliceable && (
<ThemeTag
color="geekblue"
style={{ fontWeight: 400, flexShrink: 0 }}
>
{intl.formatMessage({ id: 'gpuservice.instance.sliceable' })}
</ThemeTag>
)}
</Flex>
) )
}, },
{ {
@@ -184,7 +198,15 @@ const useInstanceTypeColumns = ({
const os = _.capitalize(record.spec?.os || ''); const os = _.capitalize(record.spec?.os || '');
const arch = _.toUpper(record.spec?.arch || ''); const arch = _.toUpper(record.spec?.arch || '');
if (!os) return '-'; if (!os) return '-';
return arch ? `${os} (${arch})` : os; return (
<AutoTooltip
ghost
maxWidth={240}
title={arch ? `${os} (${arch})` : os}
>
{arch ? `${os} (${arch})` : os}
</AutoTooltip>
);
} }
}, },
{ {
@@ -207,6 +207,8 @@ const GPUServiceInstanceTypes: React.FC = () => {
<Table <Table
columns={columns} columns={columns}
dataSource={filteredList} dataSource={filteredList}
scroll={{ x: 'max-content' }}
className={'scroll-table'}
loading={{ loading={{
spinning: instanceTypesLoading || clusterLoading, spinning: instanceTypesLoading || clusterLoading,
size: 'middle' size: 'middle'