feat: benchmark list

This commit is contained in:
jialin
2026-01-30 18:48:55 +08:00
parent 8b282afb03
commit 37b814b70a
29 changed files with 1034 additions and 19 deletions
@@ -0,0 +1,59 @@
import { PageActionType } from '@/config/types';
import FormDrawer from '@/pages/_components/form-drawer';
import React, { useRef } from 'react';
import { FormData, BenchmarkListItem as ListItem } from '../config/types';
import BenchmarkForm from '../forms';
type AddModalProps = {
title: string;
action: PageActionType;
open: boolean;
currentData?: ListItem; // Used when action is EDIT
onOk: (values: FormData) => void;
onCancel: () => void;
};
const AddBenchmark: React.FC<AddModalProps> = ({
title,
action,
open,
currentData,
onOk,
onCancel
}) => {
const form = useRef<any>(null);
const handleSubmit = () => {
form.current?.submit();
};
const handleOk = async (data: FormData) => {
onOk({
...data
});
};
const handleCancel = () => {
form.current?.resetFields();
onCancel();
};
return (
<FormDrawer
title={title}
open={open}
onCancel={handleCancel}
onSubmit={handleSubmit}
width={600}
>
<BenchmarkForm
ref={form}
action={action}
currentData={currentData}
onFinish={handleOk}
/>
</FormDrawer>
);
};
export default AddBenchmark;
@@ -0,0 +1,61 @@
import {
DeleteOutlined,
PlusOutlined,
SettingOutlined
} from '@ant-design/icons';
import { useIntl } from '@umijs/max';
import { Button, Space } from 'antd';
import React from 'react';
export interface RightActionsProps {
handleDeleteByBatch: () => void;
handleClickPrimary?: () => void;
handleSettingFields?: () => void;
handleCompare?: () => void;
buttonText?: string;
rowSelection: {
selectedRowKeys: React.Key[];
};
}
const RightActions: React.FC<RightActionsProps> = ({
handleDeleteByBatch,
handleClickPrimary,
handleCompare,
handleSettingFields,
buttonText,
rowSelection
}) => {
const intl = useIntl();
return (
<Space size={16}>
<Button onClick={handleSettingFields} icon={<SettingOutlined />}></Button>
<Button variant="solid" color="orange" onClick={handleCompare}>
Compare
</Button>
<Button
icon={<PlusOutlined></PlusOutlined>}
type="primary"
onClick={handleClickPrimary}
>
{buttonText}
</Button>
<Button
icon={<DeleteOutlined />}
danger
onClick={handleDeleteByBatch}
disabled={!rowSelection?.selectedRowKeys?.length}
>
<span>
{intl?.formatMessage?.({ id: 'common.button.delete' })}
{rowSelection?.selectedRowKeys?.length > 0 && (
<span>({rowSelection?.selectedRowKeys?.length})</span>
)}
</span>
</Button>
</Space>
);
};
export default RightActions;