|
|
|
@@ -8,7 +8,7 @@ import { pick } from 'lodash'; |
|
|
|
import { forwardRef, useEffect, useImperativeHandle, useState } from 'react'; |
|
|
|
import PropsLabel from '../components/PropsLabel'; |
|
|
|
import ResourceSelectorModal, { ResourceSelectorType } from '../components/ResourceSelectorModal'; |
|
|
|
import styles from './editPipeline.less'; |
|
|
|
import styles from './props.less'; |
|
|
|
import { createMenuItems } from './utils'; |
|
|
|
const { TextArea } = Input; |
|
|
|
|
|
|
|
@@ -188,275 +188,273 @@ const Props = forwardRef(({ onParentChange }, ref) => { |
|
|
|
); |
|
|
|
|
|
|
|
return ( |
|
|
|
<> |
|
|
|
<Drawer |
|
|
|
title="编辑任务" |
|
|
|
placement="right" |
|
|
|
rootStyle={{ marginTop: '45px' }} |
|
|
|
getContainer={false} |
|
|
|
closeIcon={false} |
|
|
|
onClose={onClose} |
|
|
|
afterOpenChange={afterOpenChange} |
|
|
|
open={open} |
|
|
|
width={520} |
|
|
|
className={styles.editPipelineProps} |
|
|
|
<Drawer |
|
|
|
title="编辑任务" |
|
|
|
placement="right" |
|
|
|
rootStyle={{ marginTop: '45px' }} |
|
|
|
getContainer={false} |
|
|
|
closeIcon={false} |
|
|
|
onClose={onClose} |
|
|
|
afterOpenChange={afterOpenChange} |
|
|
|
open={open} |
|
|
|
width={520} |
|
|
|
className={styles.editPipelineProps} |
|
|
|
> |
|
|
|
<Form |
|
|
|
name="form" |
|
|
|
form={form} |
|
|
|
layout="vertical" |
|
|
|
labelCol={{ |
|
|
|
span: 24, |
|
|
|
}} |
|
|
|
wrapperCol={{ |
|
|
|
span: 24, |
|
|
|
}} |
|
|
|
style={{ |
|
|
|
maxWidth: 600, |
|
|
|
}} |
|
|
|
autoComplete="off" |
|
|
|
> |
|
|
|
<Form |
|
|
|
name="form" |
|
|
|
form={form} |
|
|
|
layout="vertical" |
|
|
|
labelCol={{ |
|
|
|
span: 24, |
|
|
|
}} |
|
|
|
wrapperCol={{ |
|
|
|
span: 24, |
|
|
|
}} |
|
|
|
style={{ |
|
|
|
maxWidth: 600, |
|
|
|
}} |
|
|
|
autoComplete="off" |
|
|
|
<div className={styles.editPipelinePropsContent}> |
|
|
|
<SubAreaTitle image="/assets/images/static-message.png" title="基本信息"></SubAreaTitle> |
|
|
|
</div> |
|
|
|
<Form.Item |
|
|
|
label="任务名称" |
|
|
|
name="label" |
|
|
|
rules={[ |
|
|
|
{ |
|
|
|
required: true, |
|
|
|
message: '请输入任务名称', |
|
|
|
}, |
|
|
|
]} |
|
|
|
> |
|
|
|
<div className={styles.editPipelinePropsContent}> |
|
|
|
<SubAreaTitle image="/assets/images/static-message.png" title="基本信息"></SubAreaTitle> |
|
|
|
</div> |
|
|
|
<Form.Item |
|
|
|
label="任务名称" |
|
|
|
name="label" |
|
|
|
rules={[ |
|
|
|
{ |
|
|
|
required: true, |
|
|
|
message: '请输入任务名称', |
|
|
|
}, |
|
|
|
]} |
|
|
|
> |
|
|
|
<Input placeholder="请输入任务名称" allowClear /> |
|
|
|
</Form.Item> |
|
|
|
<Form.Item |
|
|
|
label="任务ID" |
|
|
|
name="id" |
|
|
|
rules={[ |
|
|
|
{ |
|
|
|
required: true, |
|
|
|
message: '请输入任务id', |
|
|
|
}, |
|
|
|
]} |
|
|
|
> |
|
|
|
<Input disabled /> |
|
|
|
</Form.Item> |
|
|
|
<div className={styles.editPipelinePropsContent}> |
|
|
|
<SubAreaTitle image="/assets/images/duty-message.png" title="任务信息"></SubAreaTitle> |
|
|
|
<Input placeholder="请输入任务名称" allowClear /> |
|
|
|
</Form.Item> |
|
|
|
<Form.Item |
|
|
|
label="任务ID" |
|
|
|
name="id" |
|
|
|
rules={[ |
|
|
|
{ |
|
|
|
required: true, |
|
|
|
message: '请输入任务id', |
|
|
|
}, |
|
|
|
]} |
|
|
|
> |
|
|
|
<Input disabled /> |
|
|
|
</Form.Item> |
|
|
|
<div className={styles.editPipelinePropsContent}> |
|
|
|
<SubAreaTitle image="/assets/images/duty-message.png" title="任务信息"></SubAreaTitle> |
|
|
|
</div> |
|
|
|
<Form.Item label="镜像" required> |
|
|
|
<div className={styles['ref-row']}> |
|
|
|
<Form.Item name="image" noStyle rules={[{ required: true, message: '请输入镜像' }]}> |
|
|
|
<Input placeholder="请输入或选择镜像" allowClear /> |
|
|
|
</Form.Item> |
|
|
|
<Form.Item noStyle> |
|
|
|
<Button |
|
|
|
type="link" |
|
|
|
icon={getSelectBtnIcon({ item_type: 'image' })} |
|
|
|
onClick={() => selectResource('image', { item_type: 'image' })} |
|
|
|
className={styles['select-button']} |
|
|
|
> |
|
|
|
选择镜像 |
|
|
|
</Button> |
|
|
|
</Form.Item> |
|
|
|
</div> |
|
|
|
<Form.Item label="镜像" required> |
|
|
|
<div className={styles['ref-row']}> |
|
|
|
<Form.Item name="image" noStyle rules={[{ required: true, message: '请输入镜像' }]}> |
|
|
|
<Input placeholder="请输入或选择镜像" allowClear /> |
|
|
|
</Form.Item> |
|
|
|
<Form.Item noStyle> |
|
|
|
<Button |
|
|
|
type="link" |
|
|
|
icon={getSelectBtnIcon({ item_type: 'image' })} |
|
|
|
onClick={() => selectResource('image', { item_type: 'image' })} |
|
|
|
className={styles['select-button']} |
|
|
|
> |
|
|
|
选择镜像 |
|
|
|
</Button> |
|
|
|
</Form.Item> |
|
|
|
</div> |
|
|
|
</Form.Item> |
|
|
|
</Form.Item> |
|
|
|
<Form.Item |
|
|
|
name="working_directory" |
|
|
|
label={ |
|
|
|
<PropsLabel |
|
|
|
menuItems={menuItems} |
|
|
|
title="工作目录" |
|
|
|
onClick={(value) => { |
|
|
|
handleParameterClick('working_directory', value); |
|
|
|
}} |
|
|
|
/> |
|
|
|
} |
|
|
|
> |
|
|
|
<Input placeholder="请输入工作目录" allowClear /> |
|
|
|
</Form.Item> |
|
|
|
<Form.Item |
|
|
|
name="command" |
|
|
|
label={ |
|
|
|
<PropsLabel |
|
|
|
menuItems={menuItems} |
|
|
|
title="启动命令" |
|
|
|
onClick={(value) => { |
|
|
|
handleParameterClick('command', value); |
|
|
|
}} |
|
|
|
/> |
|
|
|
} |
|
|
|
> |
|
|
|
<TextArea placeholder="请输入启动命令" allowClear /> |
|
|
|
</Form.Item> |
|
|
|
<Form.Item |
|
|
|
label="资源规格" |
|
|
|
name="resources_standard" |
|
|
|
rules={[ |
|
|
|
{ |
|
|
|
required: true, |
|
|
|
message: '请选择资源规格', |
|
|
|
}, |
|
|
|
]} |
|
|
|
> |
|
|
|
<Select |
|
|
|
showSearch |
|
|
|
placeholder="请选择资源规格" |
|
|
|
filterOption={filterResourceStandard} |
|
|
|
options={resourceStandardList} |
|
|
|
fieldNames={{ |
|
|
|
label: 'description', |
|
|
|
value: 'standard', |
|
|
|
}} |
|
|
|
/> |
|
|
|
</Form.Item> |
|
|
|
<Form.Item |
|
|
|
name="mount_path" |
|
|
|
label={ |
|
|
|
<PropsLabel |
|
|
|
menuItems={menuItems} |
|
|
|
title="挂载路径" |
|
|
|
onClick={(value) => { |
|
|
|
handleParameterClick('mount_path', value); |
|
|
|
}} |
|
|
|
/> |
|
|
|
} |
|
|
|
> |
|
|
|
<Input placeholder="请输入挂载路径" allowClear /> |
|
|
|
</Form.Item> |
|
|
|
<Form.Item |
|
|
|
name="env_variables" |
|
|
|
label={ |
|
|
|
<PropsLabel |
|
|
|
menuItems={menuItems} |
|
|
|
title="环境变量" |
|
|
|
onClick={(value) => { |
|
|
|
handleParameterClick('env_variables', value); |
|
|
|
}} |
|
|
|
/> |
|
|
|
} |
|
|
|
> |
|
|
|
<TextArea placeholder="请输入环境变量" allowClear /> |
|
|
|
</Form.Item> |
|
|
|
{controlStrategyList.map((item) => ( |
|
|
|
<Form.Item |
|
|
|
name="working_directory" |
|
|
|
key={item.key} |
|
|
|
name={['control_strategy', item.key]} |
|
|
|
label={ |
|
|
|
<PropsLabel |
|
|
|
menuItems={menuItems} |
|
|
|
title="工作目录" |
|
|
|
title={item.value.label} |
|
|
|
onClick={(value) => { |
|
|
|
handleParameterClick('working_directory', value); |
|
|
|
handleParameterClick(['control_strategy', item.key], { |
|
|
|
...item.value, |
|
|
|
value, |
|
|
|
}); |
|
|
|
}} |
|
|
|
/> |
|
|
|
} |
|
|
|
getValueProps={(e) => { |
|
|
|
return { value: e.value }; |
|
|
|
}} |
|
|
|
getValueFromEvent={(e) => { |
|
|
|
return { |
|
|
|
...item.value, |
|
|
|
value: e.target.value, |
|
|
|
}; |
|
|
|
}} |
|
|
|
> |
|
|
|
<Input placeholder="请输入工作目录" allowClear /> |
|
|
|
<Input placeholder={item.value.label} allowClear /> |
|
|
|
</Form.Item> |
|
|
|
))} |
|
|
|
<div className={styles.editPipelinePropsContent}> |
|
|
|
<SubAreaTitle image="/assets/images/duty-message.png" title="输入参数"></SubAreaTitle> |
|
|
|
</div> |
|
|
|
{inParametersList.map((item) => ( |
|
|
|
<Form.Item |
|
|
|
name="command" |
|
|
|
key={item.key} |
|
|
|
label={ |
|
|
|
<PropsLabel |
|
|
|
menuItems={menuItems} |
|
|
|
title="启动命令" |
|
|
|
title={item.value.label + '(' + item.key + ')'} |
|
|
|
onClick={(value) => { |
|
|
|
handleParameterClick('command', value); |
|
|
|
handleParameterClick(['in_parameters', item.key], { |
|
|
|
...item.value, |
|
|
|
value, |
|
|
|
}); |
|
|
|
}} |
|
|
|
/> |
|
|
|
} |
|
|
|
required={item.value.require ? true : false} |
|
|
|
> |
|
|
|
<TextArea placeholder="请输入启动命令" allowClear /> |
|
|
|
</Form.Item> |
|
|
|
<Form.Item |
|
|
|
label="资源规格" |
|
|
|
name="resources_standard" |
|
|
|
rules={[ |
|
|
|
{ |
|
|
|
required: true, |
|
|
|
message: '请选择资源规格', |
|
|
|
}, |
|
|
|
]} |
|
|
|
> |
|
|
|
<Select |
|
|
|
showSearch |
|
|
|
placeholder="请选择资源规格" |
|
|
|
filterOption={filterResourceStandard} |
|
|
|
options={resourceStandardList} |
|
|
|
fieldNames={{ |
|
|
|
label: 'description', |
|
|
|
value: 'standard', |
|
|
|
}} |
|
|
|
/> |
|
|
|
</Form.Item> |
|
|
|
<Form.Item |
|
|
|
name="mount_path" |
|
|
|
label={ |
|
|
|
<PropsLabel |
|
|
|
menuItems={menuItems} |
|
|
|
title="挂载路径" |
|
|
|
onClick={(value) => { |
|
|
|
handleParameterClick('mount_path', value); |
|
|
|
<div className={styles['ref-row']}> |
|
|
|
<Form.Item |
|
|
|
name={['in_parameters', item.key]} |
|
|
|
noStyle |
|
|
|
rules={[{ required: item.value.require ? true : false }]} |
|
|
|
getValueProps={(e) => { |
|
|
|
return { value: e.value }; |
|
|
|
}} |
|
|
|
/> |
|
|
|
} |
|
|
|
> |
|
|
|
<Input placeholder="请输入挂载路径" allowClear /> |
|
|
|
getValueFromEvent={(e) => { |
|
|
|
return { |
|
|
|
...item.value, |
|
|
|
value: e.target.value, |
|
|
|
}; |
|
|
|
}} |
|
|
|
> |
|
|
|
<Input placeholder={item.value.label} allowClear /> |
|
|
|
</Form.Item> |
|
|
|
{item.value.type === 'ref' && ( |
|
|
|
<Form.Item noStyle> |
|
|
|
<Button |
|
|
|
type="link" |
|
|
|
icon={getSelectBtnIcon(item.value)} |
|
|
|
onClick={() => selectResource(['in_parameters', item.key], item.value)} |
|
|
|
className={styles['select-button']} |
|
|
|
> |
|
|
|
{item.value.label} |
|
|
|
</Button> |
|
|
|
</Form.Item> |
|
|
|
)} |
|
|
|
</div> |
|
|
|
</Form.Item> |
|
|
|
))} |
|
|
|
<div className={styles.editPipelinePropsContent}> |
|
|
|
<SubAreaTitle image="/assets/images/duty-message.png" title="输出参数"></SubAreaTitle> |
|
|
|
</div> |
|
|
|
{outParametersList.map((item) => ( |
|
|
|
<Form.Item |
|
|
|
name="env_variables" |
|
|
|
key={item.key} |
|
|
|
name={['out_parameters', item.key]} |
|
|
|
label={ |
|
|
|
<PropsLabel |
|
|
|
menuItems={menuItems} |
|
|
|
title="环境变量" |
|
|
|
title={item.value.label + '(' + item.key + ')'} |
|
|
|
onClick={(value) => { |
|
|
|
handleParameterClick('env_variables', value); |
|
|
|
handleParameterClick(['out_parameters', item.key], { |
|
|
|
...item.value, |
|
|
|
value, |
|
|
|
}); |
|
|
|
}} |
|
|
|
/> |
|
|
|
} |
|
|
|
rules={[{ required: item.value.require ? true : false }]} |
|
|
|
getValueProps={(e) => { |
|
|
|
return { value: e.value }; |
|
|
|
}} |
|
|
|
getValueFromEvent={(e) => { |
|
|
|
return { |
|
|
|
...item.value, |
|
|
|
value: e.target.value, |
|
|
|
}; |
|
|
|
}} |
|
|
|
> |
|
|
|
<TextArea placeholder="请输入环境变量" allowClear /> |
|
|
|
<Input placeholder={item.value.label} allowClear /> |
|
|
|
</Form.Item> |
|
|
|
{controlStrategyList.map((item) => ( |
|
|
|
<Form.Item |
|
|
|
key={item.key} |
|
|
|
name={['control_strategy', item.key]} |
|
|
|
label={ |
|
|
|
<PropsLabel |
|
|
|
menuItems={menuItems} |
|
|
|
title={item.value.label} |
|
|
|
onClick={(value) => { |
|
|
|
handleParameterClick(['control_strategy', item.key], { |
|
|
|
...item.value, |
|
|
|
value, |
|
|
|
}); |
|
|
|
}} |
|
|
|
/> |
|
|
|
} |
|
|
|
getValueProps={(e) => { |
|
|
|
return { value: e.value }; |
|
|
|
}} |
|
|
|
getValueFromEvent={(e) => { |
|
|
|
return { |
|
|
|
...item.value, |
|
|
|
value: e.target.value, |
|
|
|
}; |
|
|
|
}} |
|
|
|
> |
|
|
|
<Input placeholder={item.value.label} allowClear /> |
|
|
|
</Form.Item> |
|
|
|
))} |
|
|
|
<div className={styles.editPipelinePropsContent}> |
|
|
|
<SubAreaTitle image="/assets/images/duty-message.png" title="输入参数"></SubAreaTitle> |
|
|
|
</div> |
|
|
|
{inParametersList.map((item) => ( |
|
|
|
<Form.Item |
|
|
|
key={item.key} |
|
|
|
label={ |
|
|
|
<PropsLabel |
|
|
|
menuItems={menuItems} |
|
|
|
title={item.value.label + '(' + item.key + ')'} |
|
|
|
onClick={(value) => { |
|
|
|
handleParameterClick(['in_parameters', item.key], { |
|
|
|
...item.value, |
|
|
|
value, |
|
|
|
}); |
|
|
|
}} |
|
|
|
/> |
|
|
|
} |
|
|
|
required={item.value.require ? true : false} |
|
|
|
> |
|
|
|
<div className={styles['ref-row']}> |
|
|
|
<Form.Item |
|
|
|
name={['in_parameters', item.key]} |
|
|
|
noStyle |
|
|
|
rules={[{ required: item.value.require ? true : false }]} |
|
|
|
getValueProps={(e) => { |
|
|
|
return { value: e.value }; |
|
|
|
}} |
|
|
|
getValueFromEvent={(e) => { |
|
|
|
return { |
|
|
|
...item.value, |
|
|
|
value: e.target.value, |
|
|
|
}; |
|
|
|
}} |
|
|
|
> |
|
|
|
<Input placeholder={item.value.label} allowClear /> |
|
|
|
</Form.Item> |
|
|
|
{item.value.type === 'ref' && ( |
|
|
|
<Form.Item noStyle> |
|
|
|
<Button |
|
|
|
type="link" |
|
|
|
icon={getSelectBtnIcon(item.value)} |
|
|
|
onClick={() => selectResource(['in_parameters', item.key], item.value)} |
|
|
|
className={styles['select-button']} |
|
|
|
> |
|
|
|
{item.value.label} |
|
|
|
</Button> |
|
|
|
</Form.Item> |
|
|
|
)} |
|
|
|
</div> |
|
|
|
</Form.Item> |
|
|
|
))} |
|
|
|
<div className={styles.editPipelinePropsContent}> |
|
|
|
<SubAreaTitle image="/assets/images/duty-message.png" title="输出参数"></SubAreaTitle> |
|
|
|
</div> |
|
|
|
{outParametersList.map((item) => ( |
|
|
|
<Form.Item |
|
|
|
key={item.key} |
|
|
|
name={['out_parameters', item.key]} |
|
|
|
label={ |
|
|
|
<PropsLabel |
|
|
|
menuItems={menuItems} |
|
|
|
title={item.value.label + '(' + item.key + ')'} |
|
|
|
onClick={(value) => { |
|
|
|
handleParameterClick(['out_parameters', item.key], { |
|
|
|
...item.value, |
|
|
|
value, |
|
|
|
}); |
|
|
|
}} |
|
|
|
/> |
|
|
|
} |
|
|
|
rules={[{ required: item.value.require ? true : false }]} |
|
|
|
getValueProps={(e) => { |
|
|
|
return { value: e.value }; |
|
|
|
}} |
|
|
|
getValueFromEvent={(e) => { |
|
|
|
return { |
|
|
|
...item.value, |
|
|
|
value: e.target.value, |
|
|
|
}; |
|
|
|
}} |
|
|
|
> |
|
|
|
<Input placeholder={item.value.label} allowClear /> |
|
|
|
</Form.Item> |
|
|
|
))} |
|
|
|
</Form> |
|
|
|
</Drawer> |
|
|
|
</> |
|
|
|
))} |
|
|
|
</Form> |
|
|
|
</Drawer> |
|
|
|
); |
|
|
|
}); |
|
|
|
|
|
|
|
|