You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dolphinscheduler.apache.org by so...@apache.org on 2022/05/05 03:48:08 UTC

[dolphinscheduler] branch dev updated: [Fix][UI Next][V1.0.0-Beta] Fix edge deletion unhandled and remove the useless nextNodes. (#9875)

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

songjian 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 615da96b08 [Fix][UI Next][V1.0.0-Beta] Fix edge deletion unhandled and remove the useless nextNodes. (#9875)
615da96b08 is described below

commit 615da96b08140c5585c622e0b35d0a124af892ba
Author: Amy0104 <97...@users.noreply.github.com>
AuthorDate: Thu May 5 11:48:02 2022 +0800

    [Fix][UI Next][V1.0.0-Beta] Fix edge deletion unhandled and remove the useless nextNodes. (#9875)
---
 .../task/components/node/fields/use-switch.ts      | 37 +++++++++++++++++++++-
 .../workflow/components/dag/dag-toolbar.tsx        |  4 +--
 .../workflow/components/dag/use-task-edit.ts       | 14 +++++++-
 3 files changed, 51 insertions(+), 4 deletions(-)

diff --git a/dolphinscheduler-ui-next/src/views/projects/task/components/node/fields/use-switch.ts b/dolphinscheduler-ui-next/src/views/projects/task/components/node/fields/use-switch.ts
index ae3f48dfc7..0405406192 100644
--- a/dolphinscheduler-ui-next/src/views/projects/task/components/node/fields/use-switch.ts
+++ b/dolphinscheduler-ui-next/src/views/projects/task/components/node/fields/use-switch.ts
@@ -14,10 +14,11 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-import { ref, watch } from 'vue'
+import { ref, watch, onMounted, nextTick } from 'vue'
 import { useI18n } from 'vue-i18n'
 import { useTaskNodeStore } from '@/store/project/task-node'
 import { queryProcessDefinitionByCode } from '@/service/modules/process-definition'
+import { findIndex } from 'lodash'
 import type { IJsonItem } from '../types'
 
 export function useSwitch(
@@ -42,6 +43,35 @@ export function useSwitch(
       }
     })
     loading.value = false
+    clearUselessNode(branchFlowOptions.value)
+  }
+
+  const clearUselessNode = (options: { value: number }[]) => {
+    if (!options || !options.length) {
+      model.nextNode = null
+      model.dependTaskList?.forEach((task: { nextNode: number | null }) => {
+        task.nextNode = null
+      })
+      return
+    }
+    if (
+      findIndex(
+        branchFlowOptions.value,
+        (option: { value: number }) => option.value == model.nextNode
+      ) === -1
+    ) {
+      model.nextNode = null
+    }
+    model.dependTaskList?.forEach((task: { nextNode: number | null }) => {
+      if (
+        findIndex(
+          branchFlowOptions.value,
+          (option: { value: number }) => option.value == task.nextNode
+        ) === -1
+      ) {
+        task.nextNode = null
+      }
+    })
   }
 
   watch(
@@ -53,6 +83,11 @@ export function useSwitch(
     }
   )
 
+  onMounted(async () => {
+    await nextTick()
+    clearUselessNode(branchFlowOptions.value)
+  })
+
   return [
     {
       type: 'multi-condition',
diff --git a/dolphinscheduler-ui-next/src/views/projects/workflow/components/dag/dag-toolbar.tsx b/dolphinscheduler-ui-next/src/views/projects/workflow/components/dag/dag-toolbar.tsx
index c1155efa48..72e5f7f1ed 100644
--- a/dolphinscheduler-ui-next/src/views/projects/workflow/components/dag/dag-toolbar.tsx
+++ b/dolphinscheduler-ui-next/src/views/projects/workflow/components/dag/dag-toolbar.tsx
@@ -168,11 +168,11 @@ export default defineComponent({
       if (graph.value) {
         const cells = graph.value.getSelectedCells()
         if (cells) {
-          graph.value?.removeCells(cells)
           const codes = cells
             .filter((cell) => cell.isNode())
             .map((cell) => +cell.id)
-          context.emit('removeTasks', codes)
+          context.emit('removeTasks', codes, cells)
+          graph.value?.removeCells(cells)
         }
       }
     }
diff --git a/dolphinscheduler-ui-next/src/views/projects/workflow/components/dag/use-task-edit.ts b/dolphinscheduler-ui-next/src/views/projects/workflow/components/dag/use-task-edit.ts
index c90d03dced..87a22e9ea5 100644
--- a/dolphinscheduler-ui-next/src/views/projects/workflow/components/dag/use-task-edit.ts
+++ b/dolphinscheduler-ui-next/src/views/projects/workflow/components/dag/use-task-edit.ts
@@ -108,7 +108,7 @@ export function useTaskEdit(options: Options) {
    * Remove task
    * @param {number} codes
    */
-  function removeTasks(codes: number[]) {
+  function removeTasks(codes: number[], cells: any[]) {
     processDefinition.value.taskDefinitionList =
       processDefinition.value.taskDefinitionList.filter(
         (task) => !codes.includes(task.code)
@@ -120,6 +120,18 @@ export function useTaskEdit(options: Options) {
           process.postTaskCode === code || process.preTaskCode === code
       )
     })
+    cells.forEach((cell) => {
+      if (cell.isEdge()) {
+        const preTaskCode = cell.getSourceCellId()
+        const postTaskCode = cell.getTargetCellId()
+        remove(
+          processDefinition.value.processTaskRelationList,
+          (process) =>
+            String(process.postTaskCode) === postTaskCode &&
+            String(process.preTaskCode) === preTaskCode
+        )
+      }
+    })
   }
 
   function openTaskModal(task: NodeData) {