You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dolphinscheduler.apache.org by wa...@apache.org on 2022/07/13 02:21:24 UTC

[dolphinscheduler] branch dev updated: [Fix][UI] Add validator to the next node field of the switch task. (#10898)

This is an automated email from the ASF dual-hosted git repository.

wanggenhua pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/dolphinscheduler.git


The following commit(s) were added to refs/heads/dev by this push:
     new 51d6eae7f4 [Fix][UI] Add validator to the next node field of the switch task. (#10898)
51d6eae7f4 is described below

commit 51d6eae7f43cff14ae6fe29a50beac4693aad373
Author: Amy0104 <97...@users.noreply.github.com>
AuthorDate: Wed Jul 13 10:21:18 2022 +0800

    [Fix][UI] Add validator to the next node field of the switch task. (#10898)
---
 .../components/form/fields/custom-parameters.ts    | 44 ++++++++++++----------
 dolphinscheduler-ui/src/locales/en_US/project.ts   | 31 +++++++--------
 dolphinscheduler-ui/src/locales/zh_CN/project.ts   |  9 +++--
 .../task/components/node/fields/use-switch.ts      | 27 ++++++-------
 4 files changed, 59 insertions(+), 52 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 43cba0d3d6..3f7bc898ed 100644
--- a/dolphinscheduler-ui/src/locales/en_US/project.ts
+++ b/dolphinscheduler-ui/src/locales/en_US/project.ts
@@ -193,9 +193,9 @@ export default {
     project_name: 'Project Name',
     project_tips: 'Please select project name',
     workflow_relation_no_data_result_title:
-        'Can not find any relations of workflows.',
+      'Can not find any relations of workflows.',
     workflow_relation_no_data_result_desc:
-        'There is not any workflows. Please create a workflow, and then visit this page again.'
+      'There is not any workflows. Please create a workflow, and then visit this page again.'
   },
   task: {
     cancel_full_screen: 'Cancel full screen',
@@ -308,7 +308,7 @@ export default {
     task_priority: 'Task priority',
     worker_group: 'Worker group',
     worker_group_tips:
-        'The Worker group no longer exists, please select the correct Worker group!',
+      'The Worker group no longer exists, please select the correct Worker group!',
     environment_name: 'Environment Name',
     task_group_name: 'Task group name',
     task_group_queue_priority: 'Priority',
@@ -335,11 +335,11 @@ export default {
     success: 'Success',
     failed: 'Failed',
     backfill_tips:
-        'The newly created sub-Process has not yet been executed and cannot enter the sub-Process',
+      'The newly created sub-Process has not yet been executed and cannot enter the sub-Process',
     task_instance_tips:
-        'The task has not been executed and cannot enter the sub-Process',
+      'The task has not been executed and cannot enter the sub-Process',
     branch_tips:
-        'Cannot select the same node for successful branch flow and failed branch flow',
+      'Cannot select the same node for successful branch flow and failed branch flow',
     timeout_alarm: 'Timeout alarm',
     timeout_strategy: 'Timeout strategy',
     timeout_strategy_tips: 'Timeout strategy must be selected',
@@ -399,8 +399,8 @@ export default {
     parallelism_tips: 'Please enter Parallelism',
     parallelism_number_tips: 'Parallelism number should be positive integer',
     parallelism_complement_tips:
-        'If there are a large number of tasks requiring complement, you can use the custom parallelism to ' +
-        'set the complement task thread to a reasonable value to avoid too large impact on the server.',
+      'If there are a large number of tasks requiring complement, you can use the custom parallelism to ' +
+      'set the complement task thread to a reasonable value to avoid too large impact on the server.',
     task_manager_number: 'TaskManager Number',
     task_manager_number_tips: 'Please enter TaskManager number',
     http_url: 'Http Url',
@@ -435,7 +435,7 @@ export default {
     procedure_method: 'SQL Statement',
     procedure_method_tips: 'Please enter the procedure script',
     procedure_method_snippet:
-        '--Please enter the procedure script \n\n--call procedure:call <procedure-name>[(<arg1>,<arg2>, ...)]\n\n--call function:?= call <procedure-name>[(<arg1>,<arg2>, ...)]',
+      '--Please enter the procedure script \n\n--call procedure:call <procedure-name>[(<arg1>,<arg2>, ...)]\n\n--call function:?= call <procedure-name>[(<arg1>,<arg2>, ...)]',
     start: 'Start',
     edit: 'Edit',
     copy: 'Copy',
@@ -501,10 +501,11 @@ export default {
     sea_tunnel_master_url: 'Master URL',
     sea_tunnel_queue: 'Queue',
     sea_tunnel_master_url_tips:
-        'Please enter the master url, e.g., 127.0.0.1:7077',
+      'Please enter the master url, e.g., 127.0.0.1:7077',
     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',
@@ -618,24 +619,24 @@ export default {
       'Please enter the paragraph id of your zeppelin paragraph',
     jupyter_conda_env_name: 'condaEnvName',
     jupyter_conda_env_name_tips:
-        'Please enter the conda environment name of papermill',
+      'Please enter the conda environment name of papermill',
     jupyter_input_note_path: 'inputNotePath',
     jupyter_input_note_path_tips: 'Please enter the input jupyter note path',
     jupyter_output_note_path: 'outputNotePath',
     jupyter_output_note_path_tips: 'Please enter the output jupyter note path',
     jupyter_parameters: 'parameters',
     jupyter_parameters_tips:
-        'Please enter the parameters for jupyter parameterization',
+      'Please enter the parameters for jupyter parameterization',
     jupyter_kernel: 'kernel',
     jupyter_kernel_tips: 'Please enter the jupyter kernel name',
     jupyter_engine: 'engine',
     jupyter_engine_tips: 'Please enter the engine name',
     jupyter_execution_timeout: 'executionTimeout',
     jupyter_execution_timeout_tips:
-        'Please enter the execution timeout for each jupyter note cell',
+      'Please enter the execution timeout for each jupyter note cell',
     jupyter_start_timeout: 'startTimeout',
     jupyter_start_timeout_tips:
-        'Please enter the start timeout for jupyter kernel',
+      'Please enter the start timeout for jupyter kernel',
     jupyter_others: 'others',
     jupyter_others_tips:
       'Please enter the other options you need for papermill',
@@ -648,7 +649,7 @@ export default {
     mlflow_isSearchParams: 'Search Parameters',
     mlflow_dataPath: 'Data Path',
     mlflow_dataPath_tips:
-        ' The absolute path of the file or folder. Ends with .csv for file or contain train.csv and test.csv for folder',
+      ' The absolute path of the file or folder. Ends with .csv for file or contain train.csv and test.csv for folder',
     mlflow_dataPath_error_tips: ' data data can not be empty ',
     mlflow_experimentName: 'Experiment Name',
     mlflow_experimentName_tips: 'experiment_001',
diff --git a/dolphinscheduler-ui/src/locales/zh_CN/project.ts b/dolphinscheduler-ui/src/locales/zh_CN/project.ts
index 3706771854..8e918a6ec1 100644
--- a/dolphinscheduler-ui/src/locales/zh_CN/project.ts
+++ b/dolphinscheduler-ui/src/locales/zh_CN/project.ts
@@ -195,7 +195,7 @@ export default {
     project_tips: '请选择项目',
     workflow_relation_no_data_result_title: '工作流关系不存在',
     workflow_relation_no_data_result_desc:
-        '目前没有任何工作流,请先创建工作流,再访问该页面'
+      '目前没有任何工作流,请先创建工作流,再访问该页面'
   },
   task: {
     cancel_full_screen: '取消全屏',
@@ -394,7 +394,7 @@ export default {
     parallelism_tips: '请输入并行度',
     parallelism_number_tips: '并行度必须为正整数',
     parallelism_complement_tips:
-        '如果存在大量任务需要补数时,可以利用自定义并行度将补数的任务线程设置成合理的数值,避免对服务器造成过大的影响',
+      '如果存在大量任务需要补数时,可以利用自定义并行度将补数的任务线程设置成合理的数值,避免对服务器造成过大的影响',
     task_manager_number: 'TaskManager数量',
     task_manager_number_tips: '请输入TaskManager数量',
     http_url: '请求地址',
@@ -429,7 +429,7 @@ export default {
     procedure_method: 'SQL语句',
     procedure_method_tips: '请输入存储脚本',
     procedure_method_snippet:
-        '--请输入存储脚本 \n\n--调用存储过程: call <procedure-name>[(<arg1>,<arg2>, ...)] \n\n--调用存储函数:?= call <procedure-name>[(<arg1>,<arg2>, ...)]',
+      '--请输入存储脚本 \n\n--调用存储过程: call <procedure-name>[(<arg1>,<arg2>, ...)] \n\n--调用存储函数:?= call <procedure-name>[(<arg1>,<arg2>, ...)]',
     start: '运行',
     edit: '编辑',
     copy: '复制节点',
@@ -498,6 +498,7 @@ export default {
     add_pre_task_check_condition: '添加前置检查条件',
     switch_condition: '条件',
     switch_branch_flow: '分支流转',
+    switch_branch_flow_tips: '请选择分支流转',
     and: '且',
     or: '或',
     datax_custom_template: '自定义模板',
@@ -637,7 +638,7 @@ export default {
     mlflow_isSearchParams: '是否搜索参数',
     mlflow_dataPath: '数据路径',
     mlflow_dataPath_tips:
-        ' 文件/文件夹的绝对路径, 若文件需以.csv结尾, 文件夹需包含train.csv和test.csv ',
+      ' 文件/文件夹的绝对路径, 若文件需以.csv结尾, 文件夹需包含train.csv和test.csv ',
     mlflow_dataPath_error_tips: ' 数据路径不能为空 ',
     mlflow_experimentName: '实验名称',
     mlflow_experimentName_tips: 'experiment_001',
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')
+      }
     }
   ]
 }