Skip to content

Commit 45efda7

Browse files
committed
fix: single sorted field, remove token
1 parent db45c86 commit 45efda7

File tree

10 files changed

+59
-25
lines changed

10 files changed

+59
-25
lines changed

src/components/seal-table/components/header.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
import { Col, Row } from 'antd';
22
import React from 'react';
3-
import { OnSortFn, SealColumnProps } from '../types';
3+
import { OnSortFn, SealColumnProps, TableOrder } from '../types';
44
import TableHeader from './table-header';
55

66
interface HeaderProps {
77
columns: SealColumnProps[];
88
sortDirections?: ('ascend' | 'descend' | null)[];
9+
sorterList: TableOrder | Array<TableOrder>;
910
onSort?: OnSortFn;
1011
}
1112

1213
const Header: React.FC<HeaderProps> = (props) => {
13-
const { onSort, sortDirections } = props;
14+
const { onSort, sortDirections, sorterList } = props;
1415

1516
return (
1617
<Row className="row">
@@ -31,6 +32,7 @@ const Header: React.FC<HeaderProps> = (props) => {
3132
<TableHeader
3233
onSort={onSort}
3334
sorter={sorter}
35+
sorterList={sorterList}
3436
dataIndex={dataIndex}
3537
sortOrder={sortOrder}
3638
sortDirections={sortDirections}

src/components/seal-table/components/table-header.tsx

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import AutoTooltip from '@/components/auto-tooltip';
22
import { CaretDownOutlined, CaretUpOutlined } from '@ant-design/icons';
33
import classNames from 'classnames';
4-
import React from 'react';
4+
import React, { useEffect } from 'react';
55
import '../styles/header.less';
66

77
import { TableHeaderProps } from '../types';
@@ -17,6 +17,7 @@ const TableHeader: React.FC<TableHeaderProps> = (props) => {
1717
sortDirections = ['ascend', 'descend', null],
1818
defaultSortOrder,
1919
onSort,
20+
sorterList,
2021
sorter = false,
2122
width,
2223
dataIndex
@@ -47,6 +48,29 @@ const TableHeader: React.FC<TableHeaderProps> = (props) => {
4748
});
4849
};
4950

51+
useEffect(() => {
52+
if (!sorterList) {
53+
setCurrentSortOrder(null);
54+
return;
55+
}
56+
57+
if (Array.isArray(sorterList)) {
58+
const sortItem = sorterList.find(
59+
(item) => item.columnKey === dataIndex || item.field === dataIndex
60+
);
61+
setCurrentSortOrder(sortItem?.order || null);
62+
} else {
63+
if (
64+
sorterList.columnKey === dataIndex ||
65+
sorterList.field === dataIndex
66+
) {
67+
setCurrentSortOrder(sorterList.order);
68+
} else {
69+
setCurrentSortOrder(null);
70+
}
71+
}
72+
}, [sorterList]);
73+
5074
return (
5175
<div
5276
style={{ width, ...style }}

src/components/seal-table/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ const SealTable: React.FC<SealTableProps & { pagination: PaginationProps }> = (
4949
loadChildren,
5050
loadChildrenAPI
5151
} = props;
52-
const { handleOnTableSort } = useSorter({
52+
const { handleOnTableSort, sorterList } = useSorter({
5353
onTableSort,
5454
columns
5555
});
@@ -166,6 +166,7 @@ const SealTable: React.FC<SealTableProps & { pagination: PaginationProps }> = (
166166
onSort={handleOnTableSort}
167167
columns={parsedColumns}
168168
sortDirections={sortDirections}
169+
sorterList={sorterList}
169170
></Header>
170171
</div>
171172
<Spin spinning={loading}>

src/components/seal-table/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ export interface SealColumnProps {
4343
}
4444

4545
export interface TableHeaderProps {
46+
sorterList?: TableOrder | Array<TableOrder>;
4647
sorter?: boolean | { multiple?: number };
4748
sortDirections?: ('ascend' | 'descend' | null)[];
4849
defaultSortOrder?: 'ascend' | 'descend' | null;

src/components/seal-table/use-sorter.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { isBoolean } from 'lodash';
2-
import { useRef } from 'react';
2+
import { useRef, useState } from 'react';
33
import { SealColumnProps, TableOrder } from './types';
44

55
const initSorterList = (columns: SealColumnProps[]) => {
@@ -23,6 +23,9 @@ export default function useSorter(options: {
2323
const sorterListRef = useRef<TableOrder | Array<TableOrder>>(
2424
initSorterList(columns || [])
2525
);
26+
const [sorterList, setSorterList] = useState<TableOrder | Array<TableOrder>>(
27+
initSorterList(columns || [])
28+
);
2629

2730
const handleOnTableSort = (
2831
order: TableOrder,
@@ -39,6 +42,7 @@ export default function useSorter(options: {
3942
}
4043
// single column sort
4144
if (isBoolean(sorter)) {
45+
setSorterList(currentOrder);
4246
sorterListRef.current = currentOrder;
4347

4448
onTableSort?.(sorterListRef.current);
@@ -73,12 +77,14 @@ export default function useSorter(options: {
7377
}
7478
}
7579
}
80+
setSorterList(sorterListRef.current);
7681

7782
onTableSort?.(sorterListRef.current);
7883
};
7984

8085
return {
8186
sorterListRef,
87+
sorterList,
8288
handleOnTableSort
8389
};
8490
}

src/config/settings.ts

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,18 @@ type SortDirection = 'ascend' | 'descend' | null;
1515
export const TABLE_SORT_DIRECTIONS: SortDirection[] = [
1616
'ascend',
1717
'descend',
18-
null
18+
'ascend'
1919
];
2020

2121
export const tableSorter = (order: number | boolean) => {
22-
if (typeof order === 'number') {
23-
return {
24-
multiple: order
25-
};
26-
}
27-
return order;
22+
return true;
23+
24+
// mutiple sorting can be supported in future
25+
26+
// if (typeof order === 'number') {
27+
// return {
28+
// multiple: order
29+
// };
30+
// }
31+
// return order;
2832
};

src/pages/llmodels/components/deploy-builtin-modal.tsx

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { PageActionType } from '@/config/types';
44
import { createAxiosToken } from '@/hooks/use-chunk-request';
55
import { ClusterStatusValueMap } from '@/pages/cluster-management/config';
66
import { useIntl } from '@umijs/max';
7-
import { Button } from 'antd';
7+
import { Button, message } from 'antd';
88
import _ from 'lodash';
99
import React, { useEffect, useMemo, useRef, useState } from 'react';
1010
import styled from 'styled-components';
@@ -96,13 +96,16 @@ const AddModal: React.FC<AddModalProps> = (props) => {
9696
const selectSpecRef = useRef<CatalogSpec>({} as CatalogSpec);
9797
const specListRef = useRef<any[]>([]);
9898
const noCompatibleGPUsRef = useRef<boolean>(false);
99-
const [noCompatibleGPUs, setNoCompatibleGPUs] = useState<boolean>(false);
10099

101100
const handleSumit = () => {
102101
form.current?.submit?.();
103102
};
104103

105104
const handleSubmitAnyway = async () => {
105+
if (noCompatibleGPUsRef.current) {
106+
message.error(intl.formatMessage({ id: 'models.catalog.nogpus.tips' }));
107+
return;
108+
}
106109
submitAnyway.current = true;
107110
form.current?.submit?.();
108111
};
@@ -266,7 +269,6 @@ const AddModal: React.FC<AddModalProps> = (props) => {
266269
// If no avaliable gpus for the model, show warning message
267270
if (!res.items.length) {
268271
noCompatibleGPUsRef.current = true;
269-
setNoCompatibleGPUs(true);
270272
setWarningStatus({
271273
show: true,
272274
type: 'warning',
@@ -275,7 +277,6 @@ const AddModal: React.FC<AddModalProps> = (props) => {
275277
return;
276278
}
277279
noCompatibleGPUsRef.current = false;
278-
setNoCompatibleGPUs(false);
279280
handleCheckCompatibility(allValues);
280281
} catch (error) {
281282
// ignore
@@ -394,11 +395,7 @@ const AddModal: React.FC<AddModalProps> = (props) => {
394395
showOkBtn={!showExtraButton}
395396
extra={
396397
showExtraButton && (
397-
<Button
398-
type="primary"
399-
onClick={handleSubmitAnyway}
400-
disabled={noCompatibleGPUs}
401-
>
398+
<Button type="primary" onClick={handleSubmitAnyway}>
402399
{intl.formatMessage({
403400
id: 'models.form.submit.anyway'
404401
})}

src/pages/llmodels/hooks/use-filter-status.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ const useFilterStatus = (options: {
3838
},
3939
{
4040
value: MyModelsStatusValueMap.Degrade,
41-
color: 'var(--ant-color-error)',
41+
color: 'var(--ant-color-warning)',
4242
label: intl.formatMessage({
4343
id: 'models.mymodels.status.degrade'
4444
})

src/pages/llmodels/user-models.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ const UserModels: React.FC = () => {
8181
},
8282
{
8383
value: MyModelsStatusValueMap.Degrade,
84-
color: 'var(--ant-color-error)',
84+
color: 'var(--ant-color-warning)',
8585
label: intl.formatMessage({
8686
id: 'models.mymodels.status.degrade'
8787
})

src/pages/resources/config/gpu-driver.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,7 @@ const setWorkerIPArg = (params: any) => {
176176

177177
const setImageArgs = (params: any) => {
178178
return `${params.image} \\
179-
--server-url ${params.server} \\
180-
--token ${params.token} \\`;
179+
--server-url ${params.server} \\`;
181180
};
182181

183182
// avaliable for NVIDIA、MThreads

0 commit comments

Comments
 (0)