You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dolphinscheduler.apache.org by GitBox <gi...@apache.org> on 2022/08/30 02:37:56 UTC

[GitHub] [dolphinscheduler] Amy0104 commented on a diff in pull request #11670: [Feature-11473][Task]Support test task

Amy0104 commented on code in PR #11670:
URL: https://github.com/apache/dolphinscheduler/pull/11670#discussion_r957945807


##########
dolphinscheduler-ui/src/views/datasource/list/use-form.ts:
##########
@@ -118,7 +124,23 @@ export function useForm(id?: number) {
             return new Error(t('datasource.jdbc_format_tips'))
           }
         }
+      },
+    testFlag: {
+      trigger: ['input'],
+      validator() {
+        if (state.detailForm.testFlag ===undefined) {

Review Comment:
   The empty value is not only undefined. So  it is better to take the opposite here.



##########
dolphinscheduler-ui/src/views/projects/task/instance/use-table.ts:
##########
@@ -116,6 +116,32 @@ export function useTable() {
         key: 'executorName',
         ...COLUMN_WIDTH_CONFIG['name']
       },
+      {
+        title: t('project.task.operating_environment'),
+        key: 'testFlag',
+        width: 160,
+        render: (row: IRecord) => {
+          if (row.testFlag===0) {
+            return h(
+                NTag,
+                { type: 'success', size: 'small' },
+                {
+                  default: () => t('project.task.on_line')
+                }
+            )
+          } else if(row.testFlag===1){
+            return h(
+                NTag,
+                { type: 'warning', size: 'small' },
+                {
+                  default: () => t('project.task.test')
+                }
+            )
+          }else {
+            return '-'
+          }
+        }
+      },

Review Comment:
   It's the same as the testFlag  of the datasource list. It is better to wrap it into a common hook.



##########
dolphinscheduler-ui/src/views/projects/task/components/node/fields/use-sqoop-datasource.ts:
##########
@@ -18,8 +18,8 @@
 import { onMounted, ref, Ref } from 'vue'
 import { queryDataSourceList } from '@/service/modules/data-source'
 import { useI18n } from 'vue-i18n'
-import type { IJsonItem, IDataBase } from '../types'
-
+import { IJsonItem, IDataBase } from '../types'

Review Comment:
   If you're going to import a type, it's better to use 'import type'.



##########
dolphinscheduler-ui/src/views/datasource/list/use-form.ts:
##########
@@ -137,24 +159,47 @@ export function useForm(id?: number) {
     } else {
       state.showPrincipal = false
     }
+    if (!state.detailForm.id) await getSameTypeTestDataSource()
   }
 
   const changePort = async () => {
     if (!state.detailForm.type) return
     const currentDataBaseOption = datasourceType[state.detailForm.type]
     currentDataBaseOption.previousPort = state.detailForm.port
   }
+  const changeTestFlag = async (testFlag: IDataBase) => {
+    if (testFlag) {
+      state.detailForm.bindTestId = undefined
+    }
+    if (state.detailForm.id) await getSameTypeTestDataSource()
+  }
+
+
+  const getSameTypeTestDataSource = async () => {
+    const params = { type: state.detailForm.type,testFlag: 1 } as TypeReq
+    const result = await queryDataSourceList(params)
+    state.bindTestDataSourceExample = result.map(
+        (TestDataSourceExample: { name: string; id: number }) => ({
+          label: TestDataSourceExample.name,
+          value: TestDataSourceExample.id
+        })
+    ).filter((value: { label: string; value: number }) => {
+      if (state.detailForm.id && state.detailForm.id === value.value) return false
+      return true
+    } )
+  }

Review Comment:
   It is better to filter first and then map.



##########
dolphinscheduler-ui/src/views/projects/workflow/instance/use-table.ts:
##########
@@ -109,6 +111,33 @@ export function useTable() {
         className: 'workflow-status',
         render: (_row: IWorkflowInstance) => renderStateCell(_row.state, t)
       },
+      {
+        title: t('project.workflow.operating_environment'),
+        key: 'testFlag',
+        width: 160,
+        className: 'workflow-testFlag',
+        render: (_row: IWorkflowInstance) => {
+          if (_row.testFlag===0) {
+            return h(
+                NTag,
+                { type: 'success', size: 'small' },
+                {
+                  default: () => t('project.workflow.on_line')
+                }
+            )
+          } else if(_row.testFlag===1){
+            return h(
+                NTag,
+                { type: 'warning', size: 'small' },
+                {
+                  default: () => t('project.workflow.test')
+                }
+            )
+          }else {
+            return '-'
+          }

Review Comment:
   Same as above.



##########
dolphinscheduler-ui/src/views/datasource/list/use-form.ts:
##########
@@ -137,24 +159,47 @@ export function useForm(id?: number) {
     } else {
       state.showPrincipal = false
     }
+    if (!state.detailForm.id) await getSameTypeTestDataSource()
   }
 
   const changePort = async () => {
     if (!state.detailForm.type) return
     const currentDataBaseOption = datasourceType[state.detailForm.type]
     currentDataBaseOption.previousPort = state.detailForm.port
   }
+  const changeTestFlag = async (testFlag: IDataBase) => {
+    if (testFlag) {
+      state.detailForm.bindTestId = undefined
+    }
+    if (state.detailForm.id) await getSameTypeTestDataSource()
+  }
+
+
+  const getSameTypeTestDataSource = async () => {
+    const params = { type: state.detailForm.type,testFlag: 1 } as TypeReq
+    const result = await queryDataSourceList(params)
+    state.bindTestDataSourceExample = result.map(
+        (TestDataSourceExample: { name: string; id: number }) => ({
+          label: TestDataSourceExample.name,
+          value: TestDataSourceExample.id
+        })
+    ).filter((value: { label: string; value: number }) => {
+      if (state.detailForm.id && state.detailForm.id === value.value) return false
+      return true
+    } )
+  }
 
   const resetFieldsValue = () => {
     state.detailForm = { ...initialValues }
   }
 
-  const setFieldsValue = (values: IDataSource) => {
+  const setFieldsValue = async (values: IDataSource) => {
     state.detailForm = {
       ...state.detailForm,
       ...values,
       other: values.other ? JSON.stringify(values.other) : values.other
     }
+    await getSameTypeTestDataSource()

Review Comment:
   It seems to be no need to reload the test options  here.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org