Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

style: add ellipsis for route table #2317

Merged
merged 1 commit into from
Feb 17, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 26 additions & 7 deletions web/src/pages/Route/List.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import {
Divider,
Menu,
Dropdown,
Tooltip,
} from 'antd';
import { history, useIntl } from 'umi';
import { PlusOutlined, ExportOutlined, ImportOutlined, DownOutlined } from '@ant-design/icons';
Expand Down Expand Up @@ -328,7 +329,12 @@ const Page: React.FC = () => {
</Popconfirm>
);
};

const tagStyle = {
maxWidth: '200px',
overflow: 'hidden',
WhiteSpace: 'nowrap',
textOverflow: 'ellipsis',
};
const columns: ProColumns<RouteModule.ResponseBody>[] = [
{
title: formatMessage({ id: 'component.global.name' }),
Expand All @@ -339,37 +345,46 @@ const Page: React.FC = () => {
title: formatMessage({ id: 'component.global.id' }),
hideInSearch: true,
dataIndex: 'id',
width: 200,
},
{
title: formatMessage({ id: 'page.route.host' }),
hideInSearch: true,
width: 224,
render: (_, record) => {
const list = record.hosts || (record.host && [record.host]) || [];

return list.map((item) => (
<Tag key={item} color="geekblue">
{item}
</Tag>
<Tooltip placement="topLeft" title={item}>
<Tag key={item} color="geekblue" style={tagStyle}>
{item}
</Tag>
</Tooltip>
));
},
},
{
title: formatMessage({ id: 'page.route.path' }),
dataIndex: 'uri',
width: 224,
render: (_, record) => {
const list = record.uris || (record.uri && [record.uri]) || [];

return list.map((item) => (
<Tag key={item} color="geekblue">
{item}
</Tag>
<Tooltip placement="topLeft" title={item}>
<Tag key={item} color="geekblue" style={tagStyle}>
{item}
</Tag>
</Tooltip>
));
},
},
{
title: formatMessage({ id: 'component.global.description' }),
dataIndex: 'desc',
hideInSearch: true,
ellipsis: true,
width: 200,
},
{
title: formatMessage({ id: 'component.global.labels' }),
Expand Down Expand Up @@ -423,6 +438,7 @@ const Page: React.FC = () => {
{
title: formatMessage({ id: 'component.global.version' }),
dataIndex: 'API_VERSION',
width: 100,
render: (_, record) => {
return Object.keys(record.labels || {})
.filter((item) => item === 'API_VERSION')
Expand Down Expand Up @@ -460,6 +476,7 @@ const Page: React.FC = () => {
{
title: formatMessage({ id: 'page.route.status' }),
dataIndex: 'status',
width: 100,
render: (_, record) => (
<>
{record.status ? (
Expand Down Expand Up @@ -496,13 +513,15 @@ const Page: React.FC = () => {
title: formatMessage({ id: 'component.global.updateTime' }),
dataIndex: 'update_time',
hideInSearch: true,
width: 200,
render: (text) => timestampToLocaleString(text as number),
},
{
title: formatMessage({ id: 'component.global.operation' }),
valueType: 'option',
fixed: 'right',
hideInSearch: true,
width: 240,
render: (_, record) => (
<>
<Space align="baseline">
Expand Down