Browse Source

feat: 流水线模版要求计算资源规格id为字符串

pull/192/head
cp3hnu 10 months ago
parent
commit
2b6e877108
2 changed files with 16 additions and 4 deletions
  1. +13
    -2
      react-ui/src/components/ParameterSelect/index.tsx
  2. +3
    -2
      react-ui/src/pages/Pipeline/components/PipelineNodeDrawer/index.tsx

+ 13
- 2
react-ui/src/components/ParameterSelect/index.tsx View File

@@ -16,13 +16,17 @@ export type ParameterSelectObject = {
[key: string]: any;
};

export type ParameterSelectDataType = 'dataset' | 'model' | 'service' | 'resource';

export interface ParameterSelectProps extends SelectProps {
/** 类型 */
dataType: 'dataset' | 'model' | 'service' | 'resource';
dataType: ParameterSelectDataType;
/** 是否只是展示信息 */
display?: boolean;
/** 值,支持对象,对象必须包含 value */
value?: string | ParameterSelectObject;
/** 用于流水线, 流水线资源规格要求 id 为字符串 */
isPipeline?: boolean;
/** 修改后回调 */
onChange?: (value: string | ParameterSelectObject) => void;
}
@@ -32,6 +36,7 @@ function ParameterSelect({
dataType,
display = false,
value,
isPipeline = false,
onChange,
...rest
}: ParameterSelectProps) {
@@ -39,6 +44,12 @@ function ParameterSelect({
const propsConfig = paramSelectConfig[dataType];
const valueText = typeof value === 'object' && value !== null ? value.value : value;
const [resourceStandardList] = useComputingResource();
const computingResource = isPipeline
? resourceStandardList.map((v) => ({
...v,
id: String(v.id),
}))
: resourceStandardList;

useEffect(() => {
// 获取下拉数据
@@ -56,7 +67,7 @@ function ParameterSelect({
getSelectOptions();
}, [propsConfig]);

const selectOptions = dataType === 'resource' ? resourceStandardList : options;
const selectOptions = dataType === 'resource' ? computingResource : options;

const handleChange = (text: string) => {
if (typeof value === 'object' && value !== null) {


+ 3
- 2
react-ui/src/pages/Pipeline/components/PipelineNodeDrawer/index.tsx View File

@@ -1,7 +1,7 @@
import CodeSelectorModal from '@/components/CodeSelectorModal';
import KFIcon from '@/components/KFIcon';
import ParameterInput, { requiredValidator } from '@/components/ParameterInput';
import ParameterSelect from '@/components/ParameterSelect';
import ParameterSelect, { type ParameterSelectDataType } from '@/components/ParameterSelect';
import ResourceSelectorModal, {
ResourceSelectorType,
selectorTypeConfig,
@@ -520,7 +520,8 @@ const PipelineNodeParameter = forwardRef(({ onFormChange }: PipelineNodeParamete
{item.value.type === 'select' ? (
['dataset', 'model', 'service', 'resource'].includes(item.value.item_type) ? (
<ParameterSelect
dataType={item.value.item_type as any}
isPipeline
dataType={item.value.item_type as ParameterSelectDataType}
placeholder={item.value.placeholder}
/>
) : null


Loading…
Cancel
Save