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 aeb861fa15 [Feat][UI] Add language parser. (#12666)
aeb861fa15 is described below

commit aeb861fa1537406fdb2819fe8bbbab2b82891ced
Author: songjianet <[email protected]>
AuthorDate: Wed Nov 2 19:32:00 2022 +0800

    [Feat][UI] Add language parser. (#12666)
---
 .../workflow/components/dynamic-dag/index.tsx      |  4 +-
 .../dynamic-dag/{task-form.tsx => task/index.tsx}  | 14 ++++--
 .../{use-task-form.ts => task/types.ts}            | 43 ++++-------------
 .../use-dynamic-locales.ts}                        | 42 +++--------------
 .../dynamic-dag/{ => task}/use-task-form.ts        | 55 +++++++++++++---------
 5 files changed, 60 insertions(+), 98 deletions(-)

diff --git 
a/dolphinscheduler-ui/src/views/projects/workflow/components/dynamic-dag/index.tsx
 
b/dolphinscheduler-ui/src/views/projects/workflow/components/dynamic-dag/index.tsx
index d605738820..667f244830 100644
--- 
a/dolphinscheduler-ui/src/views/projects/workflow/components/dynamic-dag/index.tsx
+++ 
b/dolphinscheduler-ui/src/views/projects/workflow/components/dynamic-dag/index.tsx
@@ -20,7 +20,7 @@ import { DagSidebar } from './dag-sidebar'
 import { DagCanvas } from './dag-canvas'
 import { useDagStore } from '@/store/project/dynamic/dag'
 import { NodeShape, NodeHeight, NodeWidth } from './dag-setting'
-import { TaskForm } from './task-form'
+import { TaskForm } from './task'
 import styles from './index.module.scss'
 
 const DynamicDag = defineComponent({
@@ -56,6 +56,7 @@ const DynamicDag = defineComponent({
     }
 
     return {
+      draggedTask,
       handelDragstart,
       handelDrop,
       showModal
@@ -69,6 +70,7 @@ const DynamicDag = defineComponent({
           <DagCanvas onDrop={this.handelDrop}/>
         </div>
         <TaskForm
+          task={this.draggedTask}
           showModal={this.showModal}
           onCancelModal={() => this.showModal = false}
           onConfirmModal={() => this.showModal = false}
diff --git 
a/dolphinscheduler-ui/src/views/projects/workflow/components/dynamic-dag/task-form.tsx
 
b/dolphinscheduler-ui/src/views/projects/workflow/components/dynamic-dag/task/index.tsx
similarity index 81%
rename from 
dolphinscheduler-ui/src/views/projects/workflow/components/dynamic-dag/task-form.tsx
rename to 
dolphinscheduler-ui/src/views/projects/workflow/components/dynamic-dag/task/index.tsx
index c440c0ed9e..f1da1689b7 100644
--- 
a/dolphinscheduler-ui/src/views/projects/workflow/components/dynamic-dag/task-form.tsx
+++ 
b/dolphinscheduler-ui/src/views/projects/workflow/components/dynamic-dag/task/index.tsx
@@ -15,15 +15,19 @@
  * limitations under the License.
  */
 
-import { defineComponent, PropType } from 'vue'
+import { defineComponent, PropType, toRefs } from 'vue'
 import { NForm } from 'naive-ui'
 import { useTaskForm } from './use-task-form'
+import { useI18n } from 'vue-i18n'
 import Modal from '@/components/modal'
 
 const props = {
   showModal: {
     type: Boolean as PropType<boolean>,
     default: false
+  },
+  task: {
+    type: String as PropType<string>
   }
 }
 
@@ -33,6 +37,7 @@ const TaskForm = defineComponent({
   emits: ['cancelModal', 'confirmModal'],
   setup(props, ctx) {
     const { variables } = useTaskForm()
+    const { t } = useI18n()
 
     const cancelModal = () => {
       ctx.emit('cancelModal')
@@ -42,18 +47,17 @@ const TaskForm = defineComponent({
       ctx.emit('confirmModal')
     }
 
-    return { ...variables, cancelModal, confirmModal }
+    return { ...toRefs(variables), cancelModal, confirmModal, t }
   },
   render() {
     return (
       <Modal
-        title={''}
-        show={this.showModal}
+        title={this.task}
+        show={(this.showModal && this.task) as boolean}
         onCancel={this.cancelModal}
         onConfirm={this.confirmModal}>
         <NForm
           ref={'TaskForm'}>
-
         </NForm>
       </Modal>
     )
diff --git 
a/dolphinscheduler-ui/src/views/projects/workflow/components/dynamic-dag/use-task-form.ts
 
b/dolphinscheduler-ui/src/views/projects/workflow/components/dynamic-dag/task/types.ts
similarity index 57%
copy from 
dolphinscheduler-ui/src/views/projects/workflow/components/dynamic-dag/use-task-form.ts
copy to 
dolphinscheduler-ui/src/views/projects/workflow/components/dynamic-dag/task/types.ts
index 956356fef5..52c49cd359 100644
--- 
a/dolphinscheduler-ui/src/views/projects/workflow/components/dynamic-dag/use-task-form.ts
+++ 
b/dolphinscheduler-ui/src/views/projects/workflow/components/dynamic-dag/task/types.ts
@@ -15,40 +15,15 @@
  * limitations under the License.
  */
 
-import { reactive } from 'vue'
-
-const shell = {
-  locales: {
-    zh_CN: {
-      node_name: '节点名称',
-      node_name_tips: '节点名称不能为空'
-    },
-    en_US: {
-      node_name: 'Node Name',
-      node_name_tips: 'Node name cannot be empty'
-    }
-  },
-  items: [
-    {
-      label: 'node_name',
-      type: 'input',
-      field: '',
-      validate: {
-        trigger: ['input', 'blur'],
-        message: 'node_name_tips'
-      }
-    }
-  ]
+interface DynamicLocales {
+  zh_CN: object
+  en_US: object
 }
 
-export function useTaskForm() {
-  const variables = reactive({
-    formStructure: {}
-  })
-
-  variables.formStructure = shell
-
-  return {
-    variables
-  }
+interface TaskDynamic {
+  task: string
+  locales: DynamicLocales
+  items: Array<any>
 }
+
+export { DynamicLocales, TaskDynamic }
\ No newline at end of file
diff --git 
a/dolphinscheduler-ui/src/views/projects/workflow/components/dynamic-dag/use-task-form.ts
 
b/dolphinscheduler-ui/src/views/projects/workflow/components/dynamic-dag/task/use-dynamic-locales.ts
similarity index 56%
copy from 
dolphinscheduler-ui/src/views/projects/workflow/components/dynamic-dag/use-task-form.ts
copy to 
dolphinscheduler-ui/src/views/projects/workflow/components/dynamic-dag/task/use-dynamic-locales.ts
index 956356fef5..dac61582cc 100644
--- 
a/dolphinscheduler-ui/src/views/projects/workflow/components/dynamic-dag/use-task-form.ts
+++ 
b/dolphinscheduler-ui/src/views/projects/workflow/components/dynamic-dag/task/use-dynamic-locales.ts
@@ -15,40 +15,10 @@
  * limitations under the License.
  */
 
-import { reactive } from 'vue'
+import { useI18n } from 'vue-i18n'
+import type { DynamicLocales } from './types'
 
-const shell = {
-  locales: {
-    zh_CN: {
-      node_name: '节点名称',
-      node_name_tips: '节点名称不能为空'
-    },
-    en_US: {
-      node_name: 'Node Name',
-      node_name_tips: 'Node name cannot be empty'
-    }
-  },
-  items: [
-    {
-      label: 'node_name',
-      type: 'input',
-      field: '',
-      validate: {
-        trigger: ['input', 'blur'],
-        message: 'node_name_tips'
-      }
-    }
-  ]
-}
-
-export function useTaskForm() {
-  const variables = reactive({
-    formStructure: {}
-  })
-
-  variables.formStructure = shell
-
-  return {
-    variables
-  }
-}
+export function useDynamicLocales(locales: DynamicLocales): void {
+  useI18n().mergeLocaleMessage('zh_CN', { task_components: locales.zh_CN })
+  useI18n().mergeLocaleMessage('en_US', { task_components: locales.en_US })
+}
\ No newline at end of file
diff --git 
a/dolphinscheduler-ui/src/views/projects/workflow/components/dynamic-dag/use-task-form.ts
 
b/dolphinscheduler-ui/src/views/projects/workflow/components/dynamic-dag/task/use-task-form.ts
similarity index 57%
rename from 
dolphinscheduler-ui/src/views/projects/workflow/components/dynamic-dag/use-task-form.ts
rename to 
dolphinscheduler-ui/src/views/projects/workflow/components/dynamic-dag/task/use-task-form.ts
index 956356fef5..3f17507dd9 100644
--- 
a/dolphinscheduler-ui/src/views/projects/workflow/components/dynamic-dag/use-task-form.ts
+++ 
b/dolphinscheduler-ui/src/views/projects/workflow/components/dynamic-dag/task/use-task-form.ts
@@ -16,37 +16,48 @@
  */
 
 import { reactive } from 'vue'
+import { useDynamicLocales } from './use-dynamic-locales'
+import type { TaskDynamic } from './types'
 
-const shell = {
-  locales: {
-    zh_CN: {
-      node_name: '节点名称',
-      node_name_tips: '节点名称不能为空'
+const data = [
+  {
+    task: 'shell',
+    locales: {
+      zh_CN: {
+        node_name: '节点名称',
+        node_name_tips: '节点名称不能为空'
+      },
+      en_US: {
+        node_name: 'Node Name',
+        node_name_tips: 'Node name cannot be empty'
+      }
     },
-    en_US: {
-      node_name: 'Node Name',
-      node_name_tips: 'Node name cannot be empty'
-    }
-  },
-  items: [
-    {
-      label: 'node_name',
-      type: 'input',
-      field: '',
-      validate: {
-        trigger: ['input', 'blur'],
-        message: 'node_name_tips'
+    apis: [
+
+    ],
+    items: [
+      {
+        label: 'task_components.node_name',
+        type: 'input',
+        field: '',
+        validate: {
+          trigger: ['input', 'blur'],
+          message: 'task_components.node_name_tips'
+        }
       }
-    }
-  ]
-}
+    ]
+  }
+]
 
 export function useTaskForm() {
   const variables = reactive({
     formStructure: {}
   })
 
-  variables.formStructure = shell
+  variables.formStructure = data.map((t: TaskDynamic) => {
+    useDynamicLocales(t.locales)
+    return t
+  })
 
   return {
     variables

Reply via email to