From 47782ba555616f37de730416c35db8f9f9927e62 Mon Sep 17 00:00:00 2001 From: Amy0104 <97265214+Amy0104@users.noreply.github.com> Date: Wed, 13 Jul 2022 10:21:18 +0800 Subject: [PATCH] [Fix][UI] Add validator to the next node field of the switch task. (#10898) --- .../form/fields/custom-parameters.ts | 44 +++++++------ .../src/locales/en_US/project.ts | 6 +- .../src/locales/zh_CN/project.ts | 62 +------------------ .../task/components/node/fields/use-switch.ts | 27 ++++---- 4 files changed, 40 insertions(+), 99 deletions(-) diff --git a/dolphinscheduler-ui/src/components/form/fields/custom-parameters.ts b/dolphinscheduler-ui/src/components/form/fields/custom-parameters.ts index 83890f708c..fe38899318 100644 --- a/dolphinscheduler-ui/src/components/form/fields/custom-parameters.ts +++ b/dolphinscheduler-ui/src/components/form/fields/custom-parameters.ts @@ -36,27 +36,31 @@ const CustomParameters = defineComponent({ }, render() { const { disabled, $slots, onAdd } = this - return h(NSpace, null, { - default: () => { - return [ - renderSlot($slots, 'default', { disabled }), - h( - NButton, - { - circle: true, - size: 'small', - type: 'info', - class: 'btn-create-custom-parameter', - disabled, - onClick: onAdd - }, - { - icon: () => h(PlusOutlined) - } - ) - ] + return h( + NSpace, + { vertical: true, style: { width: '100%' } }, + { + default: () => { + return [ + renderSlot($slots, 'default', { disabled }), + h( + NButton, + { + circle: true, + size: 'small', + type: 'info', + class: 'btn-create-custom-parameter', + disabled, + onClick: onAdd + }, + { + icon: () => h(PlusOutlined) + } + ) + ] + } } - }) + ) } }) diff --git a/dolphinscheduler-ui/src/locales/en_US/project.ts b/dolphinscheduler-ui/src/locales/en_US/project.ts index 6815c3822a..7d5068d081 100644 --- a/dolphinscheduler-ui/src/locales/en_US/project.ts +++ b/dolphinscheduler-ui/src/locales/en_US/project.ts @@ -489,6 +489,7 @@ export default { add_pre_task_check_condition: 'Add pre task check condition', switch_condition: 'Condition', switch_branch_flow: 'Branch Flow', + switch_branch_flow_tips: 'Please select branch flow', and: 'and', or: 'or', datax_custom_template: 'Custom Template', @@ -593,11 +594,6 @@ export default { emr_flow_define_json_tips: 'Please enter the definition of the job flow.', segment_separator: 'Segment Execution Separator', segment_separator_tips: 'Please enter the segment execution separator', - zeppelin_note_id: 'zeppelinNoteId', - zeppelin_note_id_tips: 'Please enter the note id of your zeppelin note', - zeppelin_paragraph_id: 'zeppelinParagraphId', - zeppelin_paragraph_id_tips: - 'Please enter the paragraph id of your zeppelin paragraph', send_email: 'Send Email', log_display: 'Log display', rows_of_result: 'rows of result', diff --git a/dolphinscheduler-ui/src/locales/zh_CN/project.ts b/dolphinscheduler-ui/src/locales/zh_CN/project.ts index 5d7914a673..ae2d4c80d4 100644 --- a/dolphinscheduler-ui/src/locales/zh_CN/project.ts +++ b/dolphinscheduler-ui/src/locales/zh_CN/project.ts @@ -483,6 +483,7 @@ export default { add_pre_task_check_condition: '添加前置检查条件', switch_condition: '条件', switch_branch_flow: '分支流转', + switch_branch_flow_tips: '请选择分支流转', and: '且', or: '或', datax_custom_template: '自定义模板', @@ -587,67 +588,6 @@ export default { emr_flow_define_json_tips: '请输入工作流定义', segment_separator: '分段执行符号', segment_separator_tips: '请输入分段执行符号', - zeppelin_note_id: 'zeppelin_note_id', - zeppelin_note_id_tips: '请输入zeppelin note id', - zeppelin_paragraph_id: 'zeppelin_paragraph_id', - zeppelin_paragraph_id_tips: '请输入zeppelin paragraph id', - zeppelin_parameters: 'parameters', - zeppelin_parameters_tips: '请输入zeppelin dynamic form参数', - jupyter_conda_env_name: 'condaEnvName', - jupyter_conda_env_name_tips: '请输入papermill所在的conda环境名', - jupyter_input_note_path: 'inputNotePath', - jupyter_input_note_path_tips: '请输入jupyter note的输入路径', - jupyter_output_note_path: 'outputNotePath', - jupyter_output_note_path_tips: '请输入jupyter note的输出路径', - jupyter_parameters: 'parameters', - jupyter_parameters_tips: '请输入jupyter parameterization参数', - jupyter_kernel: 'kernel', - jupyter_kernel_tips: '请输入jupyter kernel名', - jupyter_engine: 'engine', - jupyter_engine_tips: '请输入引擎名称', - jupyter_execution_timeout: 'executionTimeout', - jupyter_execution_timeout_tips: '请输入jupyter note cell的执行最长时间', - jupyter_start_timeout: 'startTimeout', - jupyter_start_timeout_tips: '请输入jupyter kernel的启动最长时间', - jupyter_others: 'others', - jupyter_others_tips: '请输入papermill的其他参数', - mlflow_algorithm: '算法', - mlflow_algorithm_tips: 'svm', - mlflow_params: '参数', - mlflow_params_tips: ' ', - mlflow_searchParams: '参数搜索空间', - mlflow_searchParams_tips: ' ', - mlflow_isSearchParams: '是否搜索参数', - mlflow_dataPath: '数据路径', - mlflow_dataPath_tips: - ' 文件/文件夹的绝对路径, 若文件需以.csv结尾, 文件夹需包含train.csv和test.csv ', - mlflow_dataPath_error_tips: ' 数据路径不能为空 ', - mlflow_experimentName: '实验名称', - mlflow_experimentName_tips: 'experiment_001', - mlflow_registerModel: '注册模型', - mlflow_modelName: '注册的模型名称', - mlflow_modelName_tips: 'model_001', - mlflow_mlflowTrackingUri: 'mlflow server tracking uri', - mlflow_mlflowTrackingUri_tips: 'http://127.0.0.1:5000', - mlflow_mlflowTrackingUri_error_tips: ' mlflow server tracking uri 不能为空', - mlflow_jobType: '任务类型', - mlflow_automlTool: 'AutoML工具', - mlflow_taskType: 'MLflow 任务类型', - mlflow_deployType: '部署类型', - mlflow_deployModelKey: '部署的模型uri', - mlflow_deployPort: '监听端口', - mlflowProjectRepository: '运行仓库', - mlflowProjectRepository_tips: '可以为github仓库或worker上的路径', - mlflowProjectVersion: '项目版本', - mlflowProjectVersion_tips: '项目git版本', - openmldb_zk_address: 'zookeeper地址', - openmldb_zk_address_tips: '请输入zookeeper地址', - openmldb_zk_path: 'zookeeper路径', - openmldb_zk_path_tips: '请输入zookeeper路径', - openmldb_execute_mode: '执行模式', - openmldb_execute_mode_tips: '请选择执行模式', - openmldb_execute_mode_offline: '离线', - openmldb_execute_mode_online: '在线', send_email: '发送邮件', log_display: '日志显示', rows_of_result: '行查询结果', diff --git a/dolphinscheduler-ui/src/views/projects/task/components/node/fields/use-switch.ts b/dolphinscheduler-ui/src/views/projects/task/components/node/fields/use-switch.ts index 0405406192..ebc050250e 100644 --- a/dolphinscheduler-ui/src/views/projects/task/components/node/fields/use-switch.ts +++ b/dolphinscheduler-ui/src/views/projects/task/components/node/fields/use-switch.ts @@ -90,12 +90,9 @@ export function useSwitch( return [ { - type: 'multi-condition', + type: 'custom-parameters', field: 'dependTaskList', name: t('project.node.switch_condition'), - validate: { - required: true - }, children: [ { type: 'input', @@ -105,23 +102,22 @@ export function useSwitch( loading: loading, type: 'textarea', autosize: { minRows: 2 } - }, - validate: { - trigger: ['input', 'blur'], - required: true } }, - { + (i = 0) => ({ type: 'select', field: 'nextNode', - span: 18, + span: 22, name: t('project.node.switch_branch_flow'), options: branchFlowOptions, validate: { trigger: ['input', 'blur'], - required: true + validator: (unuse: any, value: string) => { + if (model.dependTaskList[i].condition && !value) + return new Error(t('project.node.switch_branch_flow_tips')) + } } - } + }) ] }, { @@ -132,7 +128,12 @@ export function useSwitch( props: { loading: loading }, - options: branchFlowOptions + options: branchFlowOptions, + validate: { + trigger: ['input', 'blur'], + required: true, + message: t('project.node.switch_branch_flow_tips') + } } ] }