| @@ -1 +1 @@ | |||||
| v18.16.0 | |||||
| v18.20.7 | |||||
| @@ -30,6 +30,7 @@ function CodeSelect({ | |||||
| onChange, | onChange, | ||||
| ...rest | ...rest | ||||
| }: CodeSelectProps) { | }: CodeSelectProps) { | ||||
| // 选择代码配置 | |||||
| const selectResource = () => { | const selectResource = () => { | ||||
| const { close } = openAntdModal(CodeSelectorModal, { | const { close } = openAntdModal(CodeSelectorModal, { | ||||
| onOk: (res) => { | onOk: (res) => { | ||||
| @@ -59,6 +60,11 @@ function CodeSelect({ | |||||
| }); | }); | ||||
| }; | }; | ||||
| // 删除 | |||||
| const handleRemove = () => { | |||||
| onChange?.(undefined); | |||||
| }; | |||||
| return ( | return ( | ||||
| <div className={classNames('kf-code-select', className)} style={style}> | <div className={classNames('kf-code-select', className)} style={style}> | ||||
| <ParameterInput | <ParameterInput | ||||
| @@ -68,6 +74,7 @@ function CodeSelect({ | |||||
| value={value} | value={value} | ||||
| onChange={onChange} | onChange={onChange} | ||||
| onClick={selectResource} | onClick={selectResource} | ||||
| onRemove={handleRemove} | |||||
| ></ParameterInput> | ></ParameterInput> | ||||
| <Button | <Button | ||||
| className="kf-code-select__button" | className="kf-code-select__button" | ||||
| @@ -6,7 +6,7 @@ | |||||
| import { CommonTabKeys } from '@/enums'; | import { CommonTabKeys } from '@/enums'; | ||||
| import { CloseOutlined } from '@ant-design/icons'; | import { CloseOutlined } from '@ant-design/icons'; | ||||
| import { Form, Input } from 'antd'; | |||||
| import { ConfigProvider, Form, Input } from 'antd'; | |||||
| import { RuleObject } from 'antd/es/form'; | import { RuleObject } from 'antd/es/form'; | ||||
| import classNames from 'classnames'; | import classNames from 'classnames'; | ||||
| import './index.less'; | import './index.less'; | ||||
| @@ -67,7 +67,7 @@ function ParameterInput({ | |||||
| allowClear, | allowClear, | ||||
| className, | className, | ||||
| style, | style, | ||||
| size = 'middle', | |||||
| size, | |||||
| disabled = false, | disabled = false, | ||||
| id, | id, | ||||
| ...rest | ...rest | ||||
| @@ -81,10 +81,17 @@ function ParameterInput({ | |||||
| const placeholder = valueObj?.placeholder || rest?.placeholder; | const placeholder = valueObj?.placeholder || rest?.placeholder; | ||||
| const InputComponent = textArea ? Input.TextArea : Input; | const InputComponent = textArea ? Input.TextArea : Input; | ||||
| const { status } = Form.Item.useStatus(); | const { status } = Form.Item.useStatus(); | ||||
| const { componentSize } = ConfigProvider.useConfig(); | |||||
| const mySize = size || componentSize; | |||||
| // 删除 | // 删除 | ||||
| const handleRemove = (e: React.MouseEvent<HTMLSpanElement, MouseEvent>) => { | const handleRemove = (e: React.MouseEvent<HTMLSpanElement, MouseEvent>) => { | ||||
| e.stopPropagation(); | e.stopPropagation(); | ||||
| if (onRemove) { | |||||
| onRemove(); | |||||
| return; | |||||
| } | |||||
| onChange?.({ | onChange?.({ | ||||
| ...valueObj, | ...valueObj, | ||||
| value: undefined, | value: undefined, | ||||
| @@ -94,7 +101,6 @@ function ParameterInput({ | |||||
| expandedKeys: [], | expandedKeys: [], | ||||
| checkedKeys: [], | checkedKeys: [], | ||||
| }); | }); | ||||
| onRemove?.(); | |||||
| }; | }; | ||||
| return ( | return ( | ||||
| @@ -104,8 +110,8 @@ function ParameterInput({ | |||||
| id={id} | id={id} | ||||
| className={classNames( | className={classNames( | ||||
| 'parameter-input', | 'parameter-input', | ||||
| { 'parameter-input--large': size === 'large' }, | |||||
| { 'parameter-input--small': size === 'small' }, | |||||
| { 'parameter-input--large': mySize === 'large' }, | |||||
| { 'parameter-input--small': mySize === 'small' }, | |||||
| { [`parameter-input--${status}`]: status }, | { [`parameter-input--${status}`]: status }, | ||||
| className, | className, | ||||
| )} | )} | ||||
| @@ -128,7 +134,7 @@ function ParameterInput({ | |||||
| <InputComponent | <InputComponent | ||||
| {...rest} | {...rest} | ||||
| id={id} | id={id} | ||||
| size={size} | |||||
| size={mySize} | |||||
| className={className} | className={className} | ||||
| style={style} | style={style} | ||||
| placeholder={placeholder} | placeholder={placeholder} | ||||
| @@ -1,21 +1,10 @@ | |||||
| import { filterResourceStandard, resourceFieldNames } from '@/hooks/resource'; | |||||
| import { ServiceData } from '@/pages/ModelDeployment/types'; | import { ServiceData } from '@/pages/ModelDeployment/types'; | ||||
| import { getDatasetList, getModelList } from '@/services/dataset/index.js'; | import { getDatasetList, getModelList } from '@/services/dataset/index.js'; | ||||
| import { getServiceListReq } from '@/services/modelDeployment'; | import { getServiceListReq } from '@/services/modelDeployment'; | ||||
| import { getComputingResourceReq } from '@/services/pipeline'; | |||||
| import { ComputingResource } from '@/types'; | |||||
| import { type SelectProps } from 'antd'; | import { type SelectProps } from 'antd'; | ||||
| import { pick } from 'lodash'; | import { pick } from 'lodash'; | ||||
| // 过滤资源规格 | |||||
| const filterResourceStandard: SelectProps<string, ComputingResource>['filterOption'] = ( | |||||
| input: string, | |||||
| option?: ComputingResource, | |||||
| ) => { | |||||
| return ( | |||||
| option?.computing_resource?.toLocaleLowerCase()?.includes(input.toLocaleLowerCase()) ?? false | |||||
| ); | |||||
| }; | |||||
| // id 从 number 转换为 string | // id 从 number 转换为 string | ||||
| const convertId = (item: any) => ({ | const convertId = (item: any) => ({ | ||||
| ...item, | ...item, | ||||
| @@ -86,17 +75,10 @@ export const paramSelectConfig: Record<string, SelectPropsConfig> = { | |||||
| }, | }, | ||||
| resource: { | resource: { | ||||
| getOptions: async () => { | getOptions: async () => { | ||||
| const res = await getComputingResourceReq({ | |||||
| page: 0, | |||||
| size: 1000, | |||||
| resource_type: '', | |||||
| }); | |||||
| return res?.data?.content ?? []; | |||||
| }, | |||||
| fieldNames: { | |||||
| label: 'description', | |||||
| value: 'standard', | |||||
| // 不需要这个函数 | |||||
| return []; | |||||
| }, | }, | ||||
| fieldNames: resourceFieldNames, | |||||
| filterOption: filterResourceStandard as SelectProps['filterOption'], | filterOption: filterResourceStandard as SelectProps['filterOption'], | ||||
| }, | }, | ||||
| }; | }; | ||||
| @@ -4,6 +4,7 @@ | |||||
| * @Description: 参数下拉选择组件,支持资源规格、数据集、模型、服务 | * @Description: 参数下拉选择组件,支持资源规格、数据集、模型、服务 | ||||
| */ | */ | ||||
| import { useComputingResource } from '@/hooks/resource'; | |||||
| import { to } from '@/utils/promise'; | import { to } from '@/utils/promise'; | ||||
| import { Select, type SelectProps } from 'antd'; | import { Select, type SelectProps } from 'antd'; | ||||
| import { useEffect, useState } from 'react'; | import { useEffect, useState } from 'react'; | ||||
| @@ -20,7 +21,7 @@ export interface ParameterSelectProps extends SelectProps { | |||||
| dataType: 'dataset' | 'model' | 'service' | 'resource'; | dataType: 'dataset' | 'model' | 'service' | 'resource'; | ||||
| /** 是否只是展示信息 */ | /** 是否只是展示信息 */ | ||||
| display?: boolean; | display?: boolean; | ||||
| /** 值 */ | |||||
| /** 值,支持对象,对象必须包含 value */ | |||||
| value?: string | ParameterSelectObject; | value?: string | ParameterSelectObject; | ||||
| /** 修改后回调 */ | /** 修改后回调 */ | ||||
| onChange?: (value: string | ParameterSelectObject) => void; | onChange?: (value: string | ParameterSelectObject) => void; | ||||
| @@ -34,9 +35,10 @@ function ParameterSelect({ | |||||
| onChange, | onChange, | ||||
| ...rest | ...rest | ||||
| }: ParameterSelectProps) { | }: ParameterSelectProps) { | ||||
| const [options, setOptions] = useState([]); | |||||
| const [options, setOptions] = useState<SelectProps['options']>([]); | |||||
| const propsConfig = paramSelectConfig[dataType]; | const propsConfig = paramSelectConfig[dataType]; | ||||
| const valueText = typeof value === 'object' && value !== null ? value.value : value; | const valueText = typeof value === 'object' && value !== null ? value.value : value; | ||||
| const [resourceStandardList] = useComputingResource(); | |||||
| useEffect(() => { | useEffect(() => { | ||||
| // 获取下拉数据 | // 获取下拉数据 | ||||
| @@ -54,6 +56,8 @@ function ParameterSelect({ | |||||
| getSelectOptions(); | getSelectOptions(); | ||||
| }, [propsConfig]); | }, [propsConfig]); | ||||
| const selectOptions = dataType === 'resource' ? resourceStandardList : options; | |||||
| const handleChange = (text: string) => { | const handleChange = (text: string) => { | ||||
| if (typeof value === 'object' && value !== null) { | if (typeof value === 'object' && value !== null) { | ||||
| onChange?.({ | onChange?.({ | ||||
| @@ -71,7 +75,7 @@ function ParameterSelect({ | |||||
| <FormInfo | <FormInfo | ||||
| select | select | ||||
| value={valueText} | value={valueText} | ||||
| options={options} | |||||
| options={selectOptions} | |||||
| fieldNames={propsConfig?.fieldNames} | fieldNames={propsConfig?.fieldNames} | ||||
| ></FormInfo> | ></FormInfo> | ||||
| ); | ); | ||||
| @@ -81,7 +85,7 @@ function ParameterSelect({ | |||||
| <Select | <Select | ||||
| {...rest} | {...rest} | ||||
| filterOption={propsConfig?.filterOption} | filterOption={propsConfig?.filterOption} | ||||
| options={options} | |||||
| options={selectOptions} | |||||
| fieldNames={propsConfig?.fieldNames} | fieldNames={propsConfig?.fieldNames} | ||||
| optionFilterProp={propsConfig?.optionFilterProp} | optionFilterProp={propsConfig?.optionFilterProp} | ||||
| value={valueText} | value={valueText} | ||||
| @@ -11,10 +11,9 @@ import ResourceSelectorModal, { | |||||
| selectorTypeConfig, | selectorTypeConfig, | ||||
| } from '@/components/ResourceSelectorModal'; | } from '@/components/ResourceSelectorModal'; | ||||
| import { openAntdModal } from '@/utils/modal'; | import { openAntdModal } from '@/utils/modal'; | ||||
| import { Button } from 'antd'; | |||||
| import { Button, ConfigProvider } from 'antd'; | |||||
| import classNames from 'classnames'; | import classNames from 'classnames'; | ||||
| import { pick } from 'lodash'; | import { pick } from 'lodash'; | ||||
| import { useEffect, useState } from 'react'; | |||||
| import ParameterInput, { type ParameterInputProps } from '../ParameterInput'; | import ParameterInput, { type ParameterInputProps } from '../ParameterInput'; | ||||
| import './index.less'; | import './index.less'; | ||||
| @@ -46,43 +45,40 @@ function ResourceSelect({ | |||||
| onChange, | onChange, | ||||
| ...rest | ...rest | ||||
| }: ResourceSelectProps) { | }: ResourceSelectProps) { | ||||
| const [selectedResource, setSelectedResource] = useState<ResourceSelectorResponse | undefined>( | |||||
| undefined, | |||||
| ); | |||||
| useEffect(() => { | |||||
| if ( | |||||
| value && | |||||
| typeof value === 'object' && | |||||
| value.activeTab && | |||||
| value.id && | |||||
| value.name && | |||||
| value.version && | |||||
| value.path && | |||||
| (type === ResourceSelectorType.Mirror || (value.identifier && value.owner)) | |||||
| ) { | |||||
| const originResource = pick(value, [ | |||||
| 'activeTab', | |||||
| 'id', | |||||
| 'identifier', | |||||
| 'name', | |||||
| 'owner', | |||||
| 'version', | |||||
| 'path', | |||||
| ]) as ResourceSelectorResponse; | |||||
| setSelectedResource(originResource); | |||||
| } | |||||
| }, [value, type]); | |||||
| const { componentSize } = ConfigProvider.useConfig(); | |||||
| const mySize = size || componentSize; | |||||
| let selectedResource: ResourceSelectorResponse | undefined = undefined; | |||||
| if ( | |||||
| value && | |||||
| typeof value === 'object' && | |||||
| value.activeTab && | |||||
| value.id && | |||||
| value.name && | |||||
| value.version && | |||||
| value.path && | |||||
| (type === ResourceSelectorType.Mirror || (value.identifier && value.owner)) | |||||
| ) { | |||||
| selectedResource = pick(value, [ | |||||
| 'activeTab', | |||||
| 'id', | |||||
| 'identifier', | |||||
| 'name', | |||||
| 'owner', | |||||
| 'version', | |||||
| 'path', | |||||
| ]) as ResourceSelectorResponse; | |||||
| } | |||||
| // 选择数据集、模型、镜像 | |||||
| const selectResource = () => { | const selectResource = () => { | ||||
| const resource = selectedResource; | |||||
| const { close } = openAntdModal(ResourceSelectorModal, { | const { close } = openAntdModal(ResourceSelectorModal, { | ||||
| type, | type, | ||||
| defaultExpandedKeys: resource ? [resource.id] : [], | |||||
| defaultCheckedKeys: resource ? [`${resource.id}-${resource.version}`] : [], | |||||
| defaultActiveTab: resource?.activeTab, | |||||
| defaultExpandedKeys: selectedResource ? [selectedResource.id] : [], | |||||
| defaultCheckedKeys: selectedResource | |||||
| ? [`${selectedResource.id}-${selectedResource.version}`] | |||||
| : [], | |||||
| defaultActiveTab: selectedResource?.activeTab, | |||||
| onOk: (res) => { | onOk: (res) => { | ||||
| setSelectedResource(res); | |||||
| if (res) { | if (res) { | ||||
| const { activeTab, id, name, version, path, identifier, owner } = res; | const { activeTab, id, name, version, path, identifier, owner } = res; | ||||
| if (type === ResourceSelectorType.Mirror) { | if (type === ResourceSelectorType.Mirror) { | ||||
| @@ -116,32 +112,32 @@ function ResourceSelect({ | |||||
| }); | }); | ||||
| } | } | ||||
| } else { | } else { | ||||
| onChange?.({ | |||||
| value: undefined, | |||||
| showValue: undefined, | |||||
| fromSelect: false, | |||||
| activeTab: undefined, | |||||
| }); | |||||
| onChange?.(undefined); | |||||
| } | } | ||||
| close(); | close(); | ||||
| }, | }, | ||||
| }); | }); | ||||
| }; | }; | ||||
| // 删除 | |||||
| const handleRemove = () => { | |||||
| onChange?.(undefined); | |||||
| }; | |||||
| return ( | return ( | ||||
| <div className={classNames('kf-resource-select', className)} style={style}> | <div className={classNames('kf-resource-select', className)} style={style}> | ||||
| <ParameterInput | <ParameterInput | ||||
| {...rest} | {...rest} | ||||
| disabled={disabled} | disabled={disabled} | ||||
| value={value} | value={value} | ||||
| size={size} | |||||
| size={mySize} | |||||
| onChange={onChange} | onChange={onChange} | ||||
| onRemove={() => setSelectedResource(undefined)} | |||||
| onRemove={handleRemove} | |||||
| onClick={selectResource} | onClick={selectResource} | ||||
| ></ParameterInput> | ></ParameterInput> | ||||
| <Button | <Button | ||||
| className="kf-resource-select__button" | className="kf-resource-select__button" | ||||
| size={size} | |||||
| size={mySize} | |||||
| type="link" | type="link" | ||||
| icon={getSelectBtnIcon(type)} | icon={getSelectBtnIcon(type)} | ||||
| disabled={disabled} | disabled={disabled} | ||||
| @@ -12,6 +12,22 @@ import { useCallback, useEffect, useState } from 'react'; | |||||
| const computingResource: ComputingResource[] = []; | const computingResource: ComputingResource[] = []; | ||||
| // 过滤资源规格 | |||||
| export const filterResourceStandard: SelectProps<string, ComputingResource>['filterOption'] = ( | |||||
| input: string, | |||||
| option?: ComputingResource, | |||||
| ) => { | |||||
| return ( | |||||
| option?.computing_resource?.toLocaleLowerCase()?.includes(input.toLocaleLowerCase()) ?? false | |||||
| ); | |||||
| }; | |||||
| // 资源规格字段 | |||||
| export const resourceFieldNames = { | |||||
| label: 'description', | |||||
| value: 'id', | |||||
| }; | |||||
| // 获取资源规格 | // 获取资源规格 | ||||
| export function useComputingResource() { | export function useComputingResource() { | ||||
| const [resourceStandardList, setResourceStandardList] = useState<ComputingResource[]>([]); | const [resourceStandardList, setResourceStandardList] = useState<ComputingResource[]>([]); | ||||
| @@ -25,7 +41,7 @@ export function useComputingResource() { | |||||
| resource_type: '', | resource_type: '', | ||||
| }; | }; | ||||
| const [res] = await to(getComputingResourceReq(params)); | const [res] = await to(getComputingResourceReq(params)); | ||||
| if (res && res.data && res.data.content) { | |||||
| if (res && res.data && Array.isArray(res.data.content)) { | |||||
| setResourceStandardList(res.data.content); | setResourceStandardList(res.data.content); | ||||
| computingResource.splice(0, computingResource.length, ...res.data.content); | computingResource.splice(0, computingResource.length, ...res.data.content); | ||||
| } | } | ||||
| @@ -38,25 +54,16 @@ export function useComputingResource() { | |||||
| } | } | ||||
| }, []); | }, []); | ||||
| // 过滤资源规格 | |||||
| const filterResourceStandard: SelectProps<string, ComputingResource>['filterOption'] = | |||||
| useCallback((input: string, option?: ComputingResource) => { | |||||
| return ( | |||||
| option?.computing_resource?.toLocaleLowerCase()?.includes(input.toLocaleLowerCase()) ?? | |||||
| false | |||||
| ); | |||||
| }, []); | |||||
| // 根据 standard 获取 description | // 根据 standard 获取 description | ||||
| const getDescription = useCallback( | const getDescription = useCallback( | ||||
| (standard?: string) => { | |||||
| if (!standard) { | |||||
| (id?: string | number) => { | |||||
| if (!id) { | |||||
| return undefined; | return undefined; | ||||
| } | } | ||||
| return resourceStandardList.find((item) => item.standard === standard)?.description; | |||||
| return resourceStandardList.find((item) => Number(item.id) === Number(id))?.description; | |||||
| }, | }, | ||||
| [resourceStandardList], | [resourceStandardList], | ||||
| ); | ); | ||||
| return [resourceStandardList, filterResourceStandard, getDescription] as const; | |||||
| return [resourceStandardList, getDescription] as const; | |||||
| } | } | ||||
| @@ -40,7 +40,7 @@ function AutoMLInstance() { | |||||
| closeSSE(); | closeSSE(); | ||||
| }; | }; | ||||
| // eslint-disable-next-line react-hooks/exhaustive-deps | // eslint-disable-next-line react-hooks/exhaustive-deps | ||||
| }, []); | |||||
| }, [instanceId]); | |||||
| // 获取实验实例详情 | // 获取实验实例详情 | ||||
| const getExperimentInsInfo = async (isStatusDetermined: boolean) => { | const getExperimentInsInfo = async (isStatusDetermined: boolean) => { | ||||
| @@ -30,7 +30,6 @@ function DatasetConfig() { | |||||
| type={ResourceSelectorType.Dataset} | type={ResourceSelectorType.Dataset} | ||||
| placeholder="请选择数据集" | placeholder="请选择数据集" | ||||
| canInput={false} | canInput={false} | ||||
| size="large" | |||||
| /> | /> | ||||
| </Form.Item> | </Form.Item> | ||||
| </Col> | </Col> | ||||
| @@ -431,7 +431,12 @@ function ExecuteConfig() { | |||||
| <Row gutter={8}> | <Row gutter={8}> | ||||
| <Col span={10}> | <Col span={10}> | ||||
| <Form.Item label="是否打乱" name="shuffle" tooltip="拆分数据前是否打乱顺序"> | |||||
| <Form.Item | |||||
| label="是否打乱" | |||||
| name="shuffle" | |||||
| tooltip="拆分数据前是否打乱顺序" | |||||
| valuePropName="checked" | |||||
| > | |||||
| <Switch /> | <Switch /> | ||||
| </Form.Item> | </Form.Item> | ||||
| </Col> | </Col> | ||||
| @@ -6,17 +6,17 @@ | |||||
| import KFIcon from '@/components/KFIcon'; | import KFIcon from '@/components/KFIcon'; | ||||
| import KFRadio, { type KFRadioItem } from '@/components/KFRadio'; | import KFRadio, { type KFRadioItem } from '@/components/KFRadio'; | ||||
| import PageTitle from '@/components/PageTitle'; | import PageTitle from '@/components/PageTitle'; | ||||
| import ParameterSelect from '@/components/ParameterSelect'; | |||||
| import ResourceSelect, { | import ResourceSelect, { | ||||
| requiredValidator, | requiredValidator, | ||||
| ResourceSelectorType, | ResourceSelectorType, | ||||
| type ParameterInputObject, | type ParameterInputObject, | ||||
| } from '@/components/ResourceSelect'; | } from '@/components/ResourceSelect'; | ||||
| import SubAreaTitle from '@/components/SubAreaTitle'; | import SubAreaTitle from '@/components/SubAreaTitle'; | ||||
| import { useComputingResource } from '@/hooks/resource'; | |||||
| import { createEditorReq } from '@/services/developmentEnvironment'; | import { createEditorReq } from '@/services/developmentEnvironment'; | ||||
| import { to } from '@/utils/promise'; | import { to } from '@/utils/promise'; | ||||
| import { useNavigate } from '@umijs/max'; | import { useNavigate } from '@umijs/max'; | ||||
| import { App, Button, Col, Form, Input, Row, Select } from 'antd'; | |||||
| import { App, Button, Col, Form, Input, Row } from 'antd'; | |||||
| import { omit, pick } from 'lodash'; | import { omit, pick } from 'lodash'; | ||||
| import styles from './index.less'; | import styles from './index.less'; | ||||
| @@ -51,7 +51,6 @@ function EditorCreate() { | |||||
| const navigate = useNavigate(); | const navigate = useNavigate(); | ||||
| const [form] = Form.useForm(); | const [form] = Form.useForm(); | ||||
| const { message } = App.useApp(); | const { message } = App.useApp(); | ||||
| const [resourceStandardList, filterResourceStandard] = useComputingResource(); | |||||
| // 创建编辑器 | // 创建编辑器 | ||||
| const createEditor = async (formData: FormData) => { | const createEditor = async (formData: FormData) => { | ||||
| @@ -62,8 +61,8 @@ function EditorCreate() { | |||||
| const params = { | const params = { | ||||
| ...omit(formData, ['image', 'model', 'dataset']), | ...omit(formData, ['image', 'model', 'dataset']), | ||||
| image: image.value, | image: image.value, | ||||
| model: pick(model, ['id', 'version', 'path', 'showValue']), | |||||
| dataset: pick(dataset, ['id', 'version', 'path', 'showValue']), | |||||
| model: model && pick(model, ['id', 'version', 'path', 'showValue']), | |||||
| dataset: dataset && pick(dataset, ['id', 'version', 'path', 'showValue']), | |||||
| }; | }; | ||||
| const [res] = await to(createEditorReq(params)); | const [res] = await to(createEditorReq(params)); | ||||
| if (res) { | if (res) { | ||||
| @@ -146,16 +145,7 @@ function EditorCreate() { | |||||
| }, | }, | ||||
| ]} | ]} | ||||
| > | > | ||||
| <Select | |||||
| showSearch | |||||
| placeholder="请选择资源规格" | |||||
| filterOption={filterResourceStandard} | |||||
| options={resourceStandardList} | |||||
| fieldNames={{ | |||||
| label: 'description', | |||||
| value: 'standard', | |||||
| }} | |||||
| /> | |||||
| <ParameterSelect dataType="resource" placeholder="请选择资源规格" /> | |||||
| </Form.Item> | </Form.Item> | ||||
| </Col> | </Col> | ||||
| </Row> | </Row> | ||||
| @@ -181,7 +171,6 @@ function EditorCreate() { | |||||
| type={ResourceSelectorType.Mirror} | type={ResourceSelectorType.Mirror} | ||||
| placeholder="请选择镜像" | placeholder="请选择镜像" | ||||
| canInput={false} | canInput={false} | ||||
| size="large" | |||||
| /> | /> | ||||
| </Form.Item> | </Form.Item> | ||||
| </Col> | </Col> | ||||
| @@ -193,7 +182,6 @@ function EditorCreate() { | |||||
| type={ResourceSelectorType.Model} | type={ResourceSelectorType.Model} | ||||
| placeholder="请选择模型" | placeholder="请选择模型" | ||||
| canInput={false} | canInput={false} | ||||
| size="large" | |||||
| /> | /> | ||||
| </Form.Item> | </Form.Item> | ||||
| </Col> | </Col> | ||||
| @@ -205,7 +193,6 @@ function EditorCreate() { | |||||
| type={ResourceSelectorType.Dataset} | type={ResourceSelectorType.Dataset} | ||||
| placeholder="请选择数据集" | placeholder="请选择数据集" | ||||
| canInput={false} | canInput={false} | ||||
| size="large" | |||||
| /> | /> | ||||
| </Form.Item> | </Form.Item> | ||||
| </Col> | </Col> | ||||
| @@ -1,7 +1,6 @@ | |||||
| import FormInfo from '@/components/FormInfo'; | import FormInfo from '@/components/FormInfo'; | ||||
| import ParameterSelect from '@/components/ParameterSelect'; | import ParameterSelect from '@/components/ParameterSelect'; | ||||
| import SubAreaTitle from '@/components/SubAreaTitle'; | import SubAreaTitle from '@/components/SubAreaTitle'; | ||||
| import { useComputingResource } from '@/hooks/resource'; | |||||
| import { PipelineNodeModelSerialize } from '@/types'; | import { PipelineNodeModelSerialize } from '@/types'; | ||||
| import { Form } from 'antd'; | import { Form } from 'antd'; | ||||
| import styles from './index.less'; | import styles from './index.less'; | ||||
| @@ -11,8 +10,6 @@ type ExperimentParameterProps = { | |||||
| }; | }; | ||||
| function ExperimentParameter({ nodeData }: ExperimentParameterProps) { | function ExperimentParameter({ nodeData }: ExperimentParameterProps) { | ||||
| const [resourceStandardList] = useComputingResource(); // 资源规模 | |||||
| // 控制策略 | // 控制策略 | ||||
| const controlStrategyList = Object.entries(nodeData.control_strategy ?? {}).map( | const controlStrategyList = Object.entries(nodeData.control_strategy ?? {}).map( | ||||
| ([key, value]) => ({ key, value }), | ([key, value]) => ({ key, value }), | ||||
| @@ -112,14 +109,7 @@ function ExperimentParameter({ nodeData }: ExperimentParameterProps) { | |||||
| }, | }, | ||||
| ]} | ]} | ||||
| > | > | ||||
| <FormInfo | |||||
| select | |||||
| options={resourceStandardList} | |||||
| fieldNames={{ | |||||
| label: 'description', | |||||
| value: 'standard', | |||||
| }} | |||||
| /> | |||||
| <ParameterSelect dataType="resource" placeholder="请选择资源规格" display /> | |||||
| </Form.Item> | </Form.Item> | ||||
| <Form.Item label="挂载路径" name="mount_path"> | <Form.Item label="挂载路径" name="mount_path"> | ||||
| <FormInfo /> | <FormInfo /> | ||||
| @@ -33,7 +33,7 @@ function LogGroup({ | |||||
| status, | status, | ||||
| }: LogGroupProps) { | }: LogGroupProps) { | ||||
| const [collapse, setCollapse] = useState(true); | const [collapse, setCollapse] = useState(true); | ||||
| const [logList, setLogList, logListRef] = useStateRef<Log[]>([]); | |||||
| const [logList, setLogList] = useState<Log[]>([]); | |||||
| const [completed, setCompleted] = useState(false); | const [completed, setCompleted] = useState(false); | ||||
| // eslint-disable-next-line @typescript-eslint/no-unused-vars | // eslint-disable-next-line @typescript-eslint/no-unused-vars | ||||
| const [_isMouseDown, setIsMouseDown, isMouseDownRef] = useStateRef(false); | const [_isMouseDown, setIsMouseDown, isMouseDownRef] = useStateRef(false); | ||||
| @@ -126,6 +126,14 @@ function LogGroup({ | |||||
| socketRef.current = socket; | socketRef.current = socket; | ||||
| }; | }; | ||||
| // 关闭 socket | |||||
| const closeSocket = () => { | |||||
| if (socketRef.current) { | |||||
| socketRef.current.close(1000, 'completed'); | |||||
| socketRef.current = undefined; | |||||
| } | |||||
| }; | |||||
| if (status === ExperimentStatus.Running) { | if (status === ExperimentStatus.Running) { | ||||
| setupSockect(); | setupSockect(); | ||||
| } | } | ||||
| @@ -133,7 +141,7 @@ function LogGroup({ | |||||
| return () => { | return () => { | ||||
| closeSocket(); | closeSocket(); | ||||
| }; | }; | ||||
| }, [status, start_time, pod_name, isMouseDownRef, setLogList]); | |||||
| }, [status, start_time, pod_name, isMouseDownRef]); | |||||
| // 鼠标拖到中不滚动到底部 | // 鼠标拖到中不滚动到底部 | ||||
| useEffect(() => { | useEffect(() => { | ||||
| @@ -153,8 +161,8 @@ function LogGroup({ | |||||
| // 请求日志 | // 请求日志 | ||||
| const requestExperimentPodsLog = async () => { | const requestExperimentPodsLog = async () => { | ||||
| const list = logListRef.current; | |||||
| const startTime = list.length > 0 ? list[list.length - 1].start_time : start_time; | |||||
| const last = logList[logList.length - 1]; | |||||
| const startTime = last ? last.start_time : start_time; | |||||
| const params = { | const params = { | ||||
| pod_name, | pod_name, | ||||
| start_time: startTime, | start_time: startTime, | ||||
| @@ -201,14 +209,6 @@ function LogGroup({ | |||||
| requestExperimentPodsLog(); | requestExperimentPodsLog(); | ||||
| }; | }; | ||||
| // 关闭 socket | |||||
| const closeSocket = () => { | |||||
| if (socketRef.current) { | |||||
| socketRef.current.close(1000, 'completed'); | |||||
| socketRef.current = undefined; | |||||
| } | |||||
| }; | |||||
| // 滚动到底部 | // 滚动到底部 | ||||
| const scrollToBottom = (smooth: boolean = true) => { | const scrollToBottom = (smooth: boolean = true) => { | ||||
| // const element = document.getElementById(listId); | // const element = document.getElementById(listId); | ||||
| @@ -277,7 +277,6 @@ function Experiment() { | |||||
| current, | current, | ||||
| pageSize, | pageSize, | ||||
| }); | }); | ||||
| getExperimentList(); | |||||
| }; | }; | ||||
| // 运行实验 | // 运行实验 | ||||
| const runExperiment = async (id) => { | const runExperiment = async (id) => { | ||||
| @@ -44,7 +44,7 @@ function HyperParameterInstance() { | |||||
| closeSSE(); | closeSSE(); | ||||
| }; | }; | ||||
| // eslint-disable-next-line react-hooks/exhaustive-deps | // eslint-disable-next-line react-hooks/exhaustive-deps | ||||
| }, []); | |||||
| }, [instanceId]); | |||||
| // 获取实验实例详情 | // 获取实验实例详情 | ||||
| const getExperimentInsInfo = async (isStatusDetermined: boolean) => { | const getExperimentInsInfo = async (isStatusDetermined: boolean) => { | ||||
| @@ -1,12 +1,12 @@ | |||||
| import CodeSelect from '@/components/CodeSelect'; | import CodeSelect from '@/components/CodeSelect'; | ||||
| import KFIcon from '@/components/KFIcon'; | import KFIcon from '@/components/KFIcon'; | ||||
| import ParameterSelect from '@/components/ParameterSelect'; | |||||
| import ResourceSelect, { | import ResourceSelect, { | ||||
| ResourceSelectorType, | ResourceSelectorType, | ||||
| requiredValidator, | requiredValidator, | ||||
| } from '@/components/ResourceSelect'; | } from '@/components/ResourceSelect'; | ||||
| import SubAreaTitle from '@/components/SubAreaTitle'; | import SubAreaTitle from '@/components/SubAreaTitle'; | ||||
| import { hyperParameterOptimizedModeOptions } from '@/enums'; | import { hyperParameterOptimizedModeOptions } from '@/enums'; | ||||
| import { useComputingResource } from '@/hooks/resource'; | |||||
| import { isEmpty } from '@/utils'; | import { isEmpty } from '@/utils'; | ||||
| import { modalConfirm, removeFormListItem } from '@/utils/ui'; | import { modalConfirm, removeFormListItem } from '@/utils/ui'; | ||||
| import { MinusCircleOutlined, PlusCircleOutlined, QuestionCircleOutlined } from '@ant-design/icons'; | import { MinusCircleOutlined, PlusCircleOutlined, QuestionCircleOutlined } from '@ant-design/icons'; | ||||
| @@ -86,7 +86,6 @@ function ExecuteConfig() { | |||||
| const searchAlgorithm = Form.useWatch('search_alg', form); | const searchAlgorithm = Form.useWatch('search_alg', form); | ||||
| const paramsTypeOptions = searchAlgorithm === 'Ax' ? axParameterOptions : parameterOptions; | const paramsTypeOptions = searchAlgorithm === 'Ax' ? axParameterOptions : parameterOptions; | ||||
| const paramsTypeTooltip = searchAlgorithm === 'Ax' ? axParameterTooltip : parameterTooltip; | const paramsTypeTooltip = searchAlgorithm === 'Ax' ? axParameterTooltip : parameterTooltip; | ||||
| const [resourceStandardList, filterResourceStandard] = useComputingResource(); | |||||
| const handleSearchAlgorithmChange = (value: string) => { | const handleSearchAlgorithmChange = (value: string) => { | ||||
| if ( | if ( | ||||
| @@ -157,7 +156,6 @@ function ExecuteConfig() { | |||||
| type={ResourceSelectorType.Mirror} | type={ResourceSelectorType.Mirror} | ||||
| placeholder="请选择镜像" | placeholder="请选择镜像" | ||||
| canInput={false} | canInput={false} | ||||
| size="large" | |||||
| /> | /> | ||||
| </Form.Item> | </Form.Item> | ||||
| </Col> | </Col> | ||||
| @@ -180,7 +178,6 @@ function ExecuteConfig() { | |||||
| type={ResourceSelectorType.Dataset} | type={ResourceSelectorType.Dataset} | ||||
| placeholder="请选择数据集" | placeholder="请选择数据集" | ||||
| canInput={false} | canInput={false} | ||||
| size="large" | |||||
| /> | /> | ||||
| </Form.Item> | </Form.Item> | ||||
| </Col> | </Col> | ||||
| @@ -193,7 +190,6 @@ function ExecuteConfig() { | |||||
| type={ResourceSelectorType.Model} | type={ResourceSelectorType.Model} | ||||
| placeholder="请选择模型" | placeholder="请选择模型" | ||||
| canInput={false} | canInput={false} | ||||
| size="large" | |||||
| /> | /> | ||||
| </Form.Item> | </Form.Item> | ||||
| </Col> | </Col> | ||||
| @@ -596,7 +592,7 @@ function ExecuteConfig() { | |||||
| <Col span={10}> | <Col span={10}> | ||||
| <Form.Item | <Form.Item | ||||
| label="资源规格" | label="资源规格" | ||||
| name="resource" | |||||
| name="computing_resource_id" | |||||
| rules={[ | rules={[ | ||||
| { | { | ||||
| required: true, | required: true, | ||||
| @@ -604,16 +600,7 @@ function ExecuteConfig() { | |||||
| }, | }, | ||||
| ]} | ]} | ||||
| > | > | ||||
| <Select | |||||
| showSearch | |||||
| placeholder="请选择资源规格" | |||||
| filterOption={filterResourceStandard} | |||||
| options={resourceStandardList} | |||||
| fieldNames={{ | |||||
| label: 'description', | |||||
| value: 'standard', | |||||
| }} | |||||
| /> | |||||
| <ParameterSelect dataType="resource" placeholder="请选择资源规格" /> | |||||
| </Form.Item> | </Form.Item> | ||||
| </Col> | </Col> | ||||
| </Row> | </Row> | ||||
| @@ -41,7 +41,7 @@ function HyperParameterBasic({ | |||||
| runStatus, | runStatus, | ||||
| isInstance = false, | isInstance = false, | ||||
| }: HyperParameterBasicProps) { | }: HyperParameterBasicProps) { | ||||
| const getResourceDescription = useComputingResource()[2]; | |||||
| const getResourceDescription = useComputingResource()[1]; | |||||
| const basicDatas: BasicInfoData[] = useMemo(() => { | const basicDatas: BasicInfoData[] = useMemo(() => { | ||||
| if (!info) { | if (!info) { | ||||
| @@ -136,7 +136,7 @@ function HyperParameterBasic({ | |||||
| }, | }, | ||||
| { | { | ||||
| label: '资源规格', | label: '资源规格', | ||||
| value: info.resource, | |||||
| value: info.computing_resource_id, | |||||
| format: getResourceDescription, | format: getResourceDescription, | ||||
| }, | }, | ||||
| ]; | ]; | ||||
| @@ -24,7 +24,7 @@ export type FormData = { | |||||
| num_samples: number; // 总试验次数 | num_samples: number; // 总试验次数 | ||||
| max_t: number; // 单次试验最大时间 | max_t: number; // 单次试验最大时间 | ||||
| min_samples_required: number; // 计算中位数的最小试验数 | min_samples_required: number; // 计算中位数的最小试验数 | ||||
| resource: string; // 资源规格 | |||||
| computing_resource_id: number; // 资源规格 | |||||
| parameters: FormParameter[]; | parameters: FormParameter[]; | ||||
| points_to_evaluate: { [key: string]: any }[]; | points_to_evaluate: { [key: string]: any }[]; | ||||
| }; | }; | ||||
| @@ -5,13 +5,13 @@ | |||||
| */ | */ | ||||
| import CodeSelect from '@/components/CodeSelect'; | import CodeSelect from '@/components/CodeSelect'; | ||||
| import PageTitle from '@/components/PageTitle'; | import PageTitle from '@/components/PageTitle'; | ||||
| import ParameterSelect from '@/components/ParameterSelect'; | |||||
| import ResourceSelect, { | import ResourceSelect, { | ||||
| ResourceSelectorType, | ResourceSelectorType, | ||||
| requiredValidator, | requiredValidator, | ||||
| type ParameterInputObject, | type ParameterInputObject, | ||||
| } from '@/components/ResourceSelect'; | } from '@/components/ResourceSelect'; | ||||
| import SubAreaTitle from '@/components/SubAreaTitle'; | import SubAreaTitle from '@/components/SubAreaTitle'; | ||||
| import { useComputingResource } from '@/hooks/resource'; | |||||
| import { | import { | ||||
| createServiceVersionReq, | createServiceVersionReq, | ||||
| getServiceInfoReq, | getServiceInfoReq, | ||||
| @@ -23,7 +23,7 @@ import SessionStorage from '@/utils/sessionStorage'; | |||||
| import { removeFormListItem } from '@/utils/ui'; | import { removeFormListItem } from '@/utils/ui'; | ||||
| import { MinusCircleOutlined, PlusCircleOutlined, PlusOutlined } from '@ant-design/icons'; | import { MinusCircleOutlined, PlusCircleOutlined, PlusOutlined } from '@ant-design/icons'; | ||||
| import { useNavigate, useParams } from '@umijs/max'; | import { useNavigate, useParams } from '@umijs/max'; | ||||
| import { App, Button, Col, Flex, Form, Input, InputNumber, Row, Select } from 'antd'; | |||||
| import { App, Button, Col, Flex, Form, Input, InputNumber, Row } from 'antd'; | |||||
| import { omit, pick } from 'lodash'; | import { omit, pick } from 'lodash'; | ||||
| import { useEffect, useState } from 'react'; | import { useEffect, useState } from 'react'; | ||||
| import { CreateServiceVersionFrom, ServiceOperationType, ServiceVersionData } from '../types'; | import { CreateServiceVersionFrom, ServiceOperationType, ServiceVersionData } from '../types'; | ||||
| @@ -51,7 +51,7 @@ type ServiceVersionCache = ServiceVersionData & { | |||||
| function CreateServiceVersion() { | function CreateServiceVersion() { | ||||
| const navigate = useNavigate(); | const navigate = useNavigate(); | ||||
| const [form] = Form.useForm(); | const [form] = Form.useForm(); | ||||
| const [resourceStandardList, filterResourceStandard] = useComputingResource(); | |||||
| const [operationType, setOperationType] = useState(ServiceOperationType.Create); | const [operationType, setOperationType] = useState(ServiceOperationType.Create); | ||||
| const [lastPage, setLastPage] = useState(CreateServiceVersionFrom.ServiceInfo); | const [lastPage, setLastPage] = useState(CreateServiceVersionFrom.ServiceInfo); | ||||
| const { message } = App.useApp(); | const { message } = App.useApp(); | ||||
| @@ -305,7 +305,6 @@ function CreateServiceVersion() { | |||||
| placeholder="请选择模型" | placeholder="请选择模型" | ||||
| disabled={disabled} | disabled={disabled} | ||||
| canInput={false} | canInput={false} | ||||
| size="large" | |||||
| /> | /> | ||||
| </Form.Item> | </Form.Item> | ||||
| </Col> | </Col> | ||||
| @@ -327,7 +326,6 @@ function CreateServiceVersion() { | |||||
| type={ResourceSelectorType.Mirror} | type={ResourceSelectorType.Mirror} | ||||
| placeholder="请选择镜像" | placeholder="请选择镜像" | ||||
| canInput={false} | canInput={false} | ||||
| size="large" | |||||
| disabled={disabled} | disabled={disabled} | ||||
| /> | /> | ||||
| </Form.Item> | </Form.Item> | ||||
| @@ -357,16 +355,7 @@ function CreateServiceVersion() { | |||||
| }, | }, | ||||
| ]} | ]} | ||||
| > | > | ||||
| <Select | |||||
| showSearch | |||||
| placeholder="请选择资源规格" | |||||
| filterOption={filterResourceStandard} | |||||
| options={resourceStandardList} | |||||
| fieldNames={{ | |||||
| label: 'description', | |||||
| value: 'standard', | |||||
| }} | |||||
| /> | |||||
| <ParameterSelect dataType="resource" placeholder="请选择资源规格" /> | |||||
| </Form.Item> | </Form.Item> | ||||
| </Col> | </Col> | ||||
| </Row> | </Row> | ||||
| @@ -87,7 +87,7 @@ function ServiceInfo() { | |||||
| format: formatDate, | format: formatDate, | ||||
| }, | }, | ||||
| ]; | ]; | ||||
| const getResourceDescription = useComputingResource()[2]; | |||||
| const getResourceDescription = useComputingResource()[1]; | |||||
| // 获取服务详情 | // 获取服务详情 | ||||
| const getServiceInfo = useCallback(async () => { | const getServiceInfo = useCallback(async () => { | ||||
| @@ -36,7 +36,7 @@ const formatEnvText = (env?: Record<string, string>) => { | |||||
| }; | }; | ||||
| function VersionBasicInfo({ info }: BasicInfoProps) { | function VersionBasicInfo({ info }: BasicInfoProps) { | ||||
| const getResourceDescription = useComputingResource()[2]; | |||||
| const getResourceDescription = useComputingResource()[1]; | |||||
| const datas: BasicInfoData[] = [ | const datas: BasicInfoData[] = [ | ||||
| { | { | ||||
| @@ -42,7 +42,7 @@ const formatEnvText = (env: Record<string, string>) => { | |||||
| function VersionCompareModal({ version1, version2, ...rest }: VersionCompareModalProps) { | function VersionCompareModal({ version1, version2, ...rest }: VersionCompareModalProps) { | ||||
| const [compareData, setCompareData] = useState<CompareData | undefined>(undefined); | const [compareData, setCompareData] = useState<CompareData | undefined>(undefined); | ||||
| const getResourceDescription = useComputingResource()[2]; | |||||
| const getResourceDescription = useComputingResource()[1]; | |||||
| const fields: FiledType[] = useMemo( | const fields: FiledType[] = useMemo( | ||||
| () => [ | () => [ | ||||
| @@ -24,7 +24,7 @@ const EditPipeline = () => { | |||||
| const propsRef = useRef(); | const propsRef = useRef(); | ||||
| const [paramsDrawerOpen, openParamsDrawer, closeParamsDrawer] = useVisible(false); | const [paramsDrawerOpen, openParamsDrawer, closeParamsDrawer] = useVisible(false); | ||||
| const [globalParam, setGlobalParam, globalParamRef] = useStateRef([]); | const [globalParam, setGlobalParam, globalParamRef] = useStateRef([]); | ||||
| const [workflowInfo, setWorkflowInfo] = useStateRef(undefined); | |||||
| const [workflowInfo, setWorkflowInfo] = useState(undefined); | |||||
| const { message } = App.useApp(); | const { message } = App.useApp(); | ||||
| let sourceAnchorIdx, targetAnchorIdx, dropAnchorIdx; | let sourceAnchorIdx, targetAnchorIdx, dropAnchorIdx; | ||||
| let dragSourceNode; | let dragSourceNode; | ||||
| @@ -8,7 +8,6 @@ import ResourceSelectorModal, { | |||||
| } from '@/components/ResourceSelectorModal'; | } from '@/components/ResourceSelectorModal'; | ||||
| import SubAreaTitle from '@/components/SubAreaTitle'; | import SubAreaTitle from '@/components/SubAreaTitle'; | ||||
| import { CommonTabKeys } from '@/enums'; | import { CommonTabKeys } from '@/enums'; | ||||
| import { useComputingResource } from '@/hooks/resource'; | |||||
| import { canInput, createMenuItems } from '@/pages/Pipeline/Info/utils'; | import { canInput, createMenuItems } from '@/pages/Pipeline/Info/utils'; | ||||
| import { | import { | ||||
| PipelineGlobalParam, | PipelineGlobalParam, | ||||
| @@ -19,7 +18,7 @@ import { | |||||
| import { openAntdModal } from '@/utils/modal'; | import { openAntdModal } from '@/utils/modal'; | ||||
| import { to } from '@/utils/promise'; | import { to } from '@/utils/promise'; | ||||
| import { INode } from '@antv/g6'; | import { INode } from '@antv/g6'; | ||||
| import { Button, Drawer, Form, Input, MenuProps, Select } from 'antd'; | |||||
| import { Button, Drawer, Form, Input, MenuProps } from 'antd'; | |||||
| import { NamePath } from 'antd/es/form/interface'; | import { NamePath } from 'antd/es/form/interface'; | ||||
| import { forwardRef, useImperativeHandle, useState } from 'react'; | import { forwardRef, useImperativeHandle, useState } from 'react'; | ||||
| import PropsLabel from '../PropsLabel'; | import PropsLabel from '../PropsLabel'; | ||||
| @@ -36,7 +35,6 @@ const PipelineNodeParameter = forwardRef(({ onFormChange }: PipelineNodeParamete | |||||
| {} as PipelineNodeModelSerialize, | {} as PipelineNodeModelSerialize, | ||||
| ); | ); | ||||
| const [open, setOpen] = useState(false); | const [open, setOpen] = useState(false); | ||||
| const [resourceStandardList, filterResourceStandard] = useComputingResource(); // 资源规模 | |||||
| const [menuItems, setMenuItems] = useState<MenuProps['items']>([]); | const [menuItems, setMenuItems] = useState<MenuProps['items']>([]); | ||||
| const afterOpenChange = async () => { | const afterOpenChange = async () => { | ||||
| @@ -458,16 +456,7 @@ const PipelineNodeParameter = forwardRef(({ onFormChange }: PipelineNodeParamete | |||||
| }, | }, | ||||
| ]} | ]} | ||||
| > | > | ||||
| <Select | |||||
| placeholder="请选择资源规格" | |||||
| filterOption={filterResourceStandard} | |||||
| options={resourceStandardList} | |||||
| fieldNames={{ | |||||
| label: 'description', | |||||
| value: 'standard', | |||||
| }} | |||||
| showSearch | |||||
| /> | |||||
| <ParameterSelect dataType="resource" placeholder="请选择资源规格" /> | |||||
| </Form.Item> | </Form.Item> | ||||
| <Form.Item | <Form.Item | ||||
| name="mount_path" | name="mount_path" | ||||
| @@ -41,6 +41,7 @@ export const Primary: Story = { | |||||
| canInput: false, | canInput: false, | ||||
| textArea: false, | textArea: false, | ||||
| size: 'large', | size: 'large', | ||||
| placeholder: '请选择代码配置', | |||||
| style: { width: 400 }, | style: { width: 400 }, | ||||
| }, | }, | ||||
| render: function Render(args) { | render: function Render(args) { | ||||
| @@ -1,5 +1,7 @@ | |||||
| import ParameterInput, { ParameterInputValue } from '@/components/ParameterInput'; | import ParameterInput, { ParameterInputValue } from '@/components/ParameterInput'; | ||||
| import { action } from '@storybook/addon-actions'; | |||||
| import type { Meta, StoryObj } from '@storybook/react'; | import type { Meta, StoryObj } from '@storybook/react'; | ||||
| import { fn } from '@storybook/test'; | |||||
| import { Button } from 'antd'; | import { Button } from 'antd'; | ||||
| import { useState } from 'react'; | import { useState } from 'react'; | ||||
| @@ -18,7 +20,7 @@ const meta = { | |||||
| // backgroundColor: { control: 'color' }, | // backgroundColor: { control: 'color' }, | ||||
| }, | }, | ||||
| // Use `fn` to spy on the onClick arg, which will appear in the actions panel once invoked: https://storybook.js.org/docs/essentials/actions#action-args | // Use `fn` to spy on the onClick arg, which will appear in the actions panel once invoked: https://storybook.js.org/docs/essentials/actions#action-args | ||||
| // args: { onClick: fn() }, | |||||
| args: { onChange: fn() }, | |||||
| } satisfies Meta<typeof ParameterInput>; | } satisfies Meta<typeof ParameterInput>; | ||||
| export default meta; | export default meta; | ||||
| @@ -37,45 +39,6 @@ export const Input: Story = { | |||||
| }; | }; | ||||
| export const Select: Story = { | export const Select: Story = { | ||||
| args: { | |||||
| placeholder: '请输入工作目录', | |||||
| style: { width: 300 }, | |||||
| value: 'storybook', | |||||
| canInput: false, | |||||
| size: 'large', | |||||
| }, | |||||
| }; | |||||
| export const SelectWithObjctValue: Story = { | |||||
| args: { | |||||
| placeholder: '请输入工作目录', | |||||
| style: { width: 300 }, | |||||
| value: { | |||||
| value: 'storybook', | |||||
| showValue: 'storybook', | |||||
| fromSelect: true, | |||||
| }, | |||||
| canInput: true, | |||||
| size: 'large', | |||||
| }, | |||||
| }; | |||||
| export const Disabled: Story = { | |||||
| args: { | |||||
| placeholder: '请输入工作目录', | |||||
| style: { width: 300 }, | |||||
| value: { | |||||
| value: 'storybook', | |||||
| showValue: 'storybook', | |||||
| fromSelect: true, | |||||
| }, | |||||
| canInput: true, | |||||
| size: 'large', | |||||
| disabled: true, | |||||
| }, | |||||
| }; | |||||
| export const Application: Story = { | |||||
| args: { | args: { | ||||
| placeholder: '请输入工作目录', | placeholder: '请输入工作目录', | ||||
| style: { width: 300 }, | style: { width: 300 }, | ||||
| @@ -86,18 +49,24 @@ export const Application: Story = { | |||||
| const [value, setValue] = useState<ParameterInputValue | undefined>(''); | const [value, setValue] = useState<ParameterInputValue | undefined>(''); | ||||
| const onClick = () => { | const onClick = () => { | ||||
| setValue({ | |||||
| const value = { | |||||
| value: 'storybook', | value: 'storybook', | ||||
| showValue: 'storybook', | showValue: 'storybook', | ||||
| fromSelect: true, | fromSelect: true, | ||||
| }); | |||||
| otherValue: 'others', | |||||
| }; | |||||
| setValue(value); | |||||
| action('onChange')(value); | |||||
| }; | }; | ||||
| return ( | return ( | ||||
| <> | <> | ||||
| <ParameterInput | <ParameterInput | ||||
| {...args} | {...args} | ||||
| value={value} | value={value} | ||||
| onChange={(value) => setValue(value)} | |||||
| onChange={(value) => { | |||||
| setValue(value); | |||||
| action('onChange')(value); | |||||
| }} | |||||
| ></ParameterInput> | ></ParameterInput> | ||||
| <Button type="primary" style={{ display: 'block', marginTop: 10 }} onClick={onClick}> | <Button type="primary" style={{ display: 'block', marginTop: 10 }} onClick={onClick}> | ||||
| 模拟从全局参数选择 | 模拟从全局参数选择 | ||||
| @@ -106,3 +75,18 @@ export const Application: Story = { | |||||
| ); | ); | ||||
| }, | }, | ||||
| }; | }; | ||||
| export const Disabled: Story = { | |||||
| args: { | |||||
| placeholder: '请输入工作目录', | |||||
| style: { width: 300 }, | |||||
| value: { | |||||
| value: 'storybook', | |||||
| showValue: 'storybook', | |||||
| fromSelect: true, | |||||
| }, | |||||
| canInput: true, | |||||
| size: 'large', | |||||
| disabled: true, | |||||
| }, | |||||
| }; | |||||
| @@ -76,6 +76,7 @@ export const Primary: Story = { | |||||
| canInput: false, | canInput: false, | ||||
| textArea: false, | textArea: false, | ||||
| size: 'large', | size: 'large', | ||||
| placeholder: '请选择数据集', | |||||
| style: { width: 400 }, | style: { width: 400 }, | ||||
| }, | }, | ||||
| render: function Render(args) { | render: function Render(args) { | ||||
| @@ -120,7 +121,6 @@ export const InForm: Story = { | |||||
| type={ResourceSelectorType.Dataset} | type={ResourceSelectorType.Dataset} | ||||
| placeholder="请选择" | placeholder="请选择" | ||||
| canInput={false} | canInput={false} | ||||
| size="large" | |||||
| onChange={onChange} | onChange={onChange} | ||||
| /> | /> | ||||
| </Form.Item> | </Form.Item> | ||||
| @@ -133,7 +133,6 @@ export const InForm: Story = { | |||||
| type={ResourceSelectorType.Model} | type={ResourceSelectorType.Model} | ||||
| placeholder="请选择" | placeholder="请选择" | ||||
| canInput={false} | canInput={false} | ||||
| size="large" | |||||
| onChange={onChange} | onChange={onChange} | ||||
| /> | /> | ||||
| </Form.Item> | </Form.Item> | ||||
| @@ -146,7 +145,6 @@ export const InForm: Story = { | |||||
| type={ResourceSelectorType.Mirror} | type={ResourceSelectorType.Mirror} | ||||
| placeholder="请选择" | placeholder="请选择" | ||||
| canInput={false} | canInput={false} | ||||
| size="large" | |||||
| onChange={onChange} | onChange={onChange} | ||||
| /> | /> | ||||
| </Form.Item> | </Form.Item> | ||||