feat: metadata list

This commit is contained in:
jialin
2026-02-03 18:21:08 +08:00
parent 15cd9795d5
commit df5c2be7fa
5 changed files with 94 additions and 17 deletions
+78
View File
@@ -0,0 +1,78 @@
import { MinusOutlined } from '@ant-design/icons';
import { Button } from 'antd';
import React from 'react';
import styled from 'styled-components';
import Wrapper from '../label-selector/wrapper';
const ItemContainer = styled.div`
display: flex;
margin-bottom: 12px;
align-items: center;
justify-content: flex-start;
.seprator {
display: flex;
flex: none;
width: 12px;
align-items: center;
justify-content: center;
color: var(--ant-color-text-tertiary);
}
.btn {
width: 24px;
margin-left: 10px;
flex: none;
}
`;
interface MetadataListProps {
dataList: any[];
label: React.ReactNode;
description?: React.ReactNode;
disabled?: boolean;
btnText?: string;
onAdd?: () => void;
onDelete?: (index: number, item: any) => void;
children?: (item: any, index: number) => React.ReactNode;
}
const MetadataList: React.FC<MetadataListProps> = ({
dataList,
label,
description,
disabled,
btnText,
children,
onDelete,
onAdd
}) => {
return (
<Wrapper
label={label}
description={description}
onAdd={onAdd}
disabled={disabled}
btnText={btnText}
>
{dataList.map((item, index) => (
<ItemContainer key={index}>
{children ? children(item, index) : null}
{!disabled && (
<Button
size="small"
className="btn"
type="default"
shape="circle"
onClick={() => onDelete?.(index, item)}
>
<MinusOutlined />
</Button>
)}
</ItemContainer>
))}
</Wrapper>
);
};
export default MetadataList;
+6 -6
View File
@@ -4,31 +4,31 @@ import { AccessItem, AccessPointItem } from './types';
export const mockDataList: AccessItem[] = [ export const mockDataList: AccessItem[] = [
{ {
id: 1, id: 1,
name: 'Doubao Access', name: 'model-A',
source: 'Doubao', source: 'Deployments',
accessPoints: 5 accessPoints: 5
}, },
{ {
id: 2, id: 2,
name: 'Qwen Access', name: 'model-B',
source: 'Qwen', source: 'Qwen',
accessPoints: 3 accessPoints: 3
}, },
{ {
id: 3, id: 3,
name: 'OpenAI Access', name: 'model-C',
source: 'OpenAI', source: 'OpenAI',
accessPoints: 8 accessPoints: 8
}, },
{ {
id: 4, id: 4,
name: 'Deepseek Access', name: 'model-D',
source: 'Deepseek', source: 'Deepseek',
accessPoints: 2 accessPoints: 2
}, },
{ {
id: 5, id: 5,
name: 'Anthropic Access', name: 'model-E',
source: 'Anthropic', source: 'Anthropic',
accessPoints: 4 accessPoints: 4
} }
+1 -1
View File
@@ -13,7 +13,7 @@ const Basic = () => {
<Form.Item name="name" data-field="name"> <Form.Item name="name" data-field="name">
<SealInput.Input required label={'Model Name'} /> <SealInput.Input required label={'Model Name'} />
</Form.Item> </Form.Item>
<Form.Item name="category"> <Form.Item name="categories">
<SealSelect <SealSelect
options={modelCategories} options={modelCategories}
label="Category" label="Category"
+7 -1
View File
@@ -84,7 +84,13 @@ const AccessForm: React.FC<ProviderFormProps> = forwardRef((props, ref) => {
}} }}
getScrollElementScrollableHeight={getScrollElementScrollableHeight} getScrollElementScrollableHeight={getScrollElementScrollableHeight}
> >
<Form form={form} onFinish={onFinish}> <Form
form={form}
onFinish={onFinish}
initialValues={{
categories: []
}}
>
<Basic /> <Basic />
<CollapsePanel <CollapsePanel
activeKey={activeKey} activeKey={activeKey}
@@ -6,7 +6,7 @@ import { tableSorter } from '@/config/settings';
import { useIntl } from '@umijs/max'; import { useIntl } from '@umijs/max';
import dayjs from 'dayjs'; import dayjs from 'dayjs';
import { useMemo } from 'react'; import { useMemo } from 'react';
import { maasProviderLabelMap, rowActionList } from '../config'; import { rowActionList } from '../config';
import { AccessItem } from '../config/types'; import { AccessItem } from '../config/types';
const useAccessColumns = ( const useAccessColumns = (
@@ -33,14 +33,7 @@ const useAccessColumns = (
{ {
title: intl.formatMessage({ id: 'models.form.source' }), title: intl.formatMessage({ id: 'models.form.source' }),
dataIndex: 'source', dataIndex: 'source',
span: 5, span: 5
render: (value: string) => (
<>
<AutoTooltip ghost minWidth={20}>
{maasProviderLabelMap[value]}
</AutoTooltip>
</>
)
}, },
{ {
title: intl.formatMessage({ id: 'accesses.table.accessPoints' }), title: intl.formatMessage({ id: 'accesses.table.accessPoints' }),