Browse Source

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

3.0.0/version-upgrade
Amy0104 3 years ago committed by GitHub
parent
commit
615da96b08
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 37
      dolphinscheduler-ui-next/src/views/projects/task/components/node/fields/use-switch.ts
  2. 4
      dolphinscheduler-ui-next/src/views/projects/workflow/components/dag/dag-toolbar.tsx
  3. 14
      dolphinscheduler-ui-next/src/views/projects/workflow/components/dag/use-task-edit.ts

37
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 * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import { ref, watch } from 'vue' import { ref, watch, onMounted, nextTick } from 'vue'
import { useI18n } from 'vue-i18n' import { useI18n } from 'vue-i18n'
import { useTaskNodeStore } from '@/store/project/task-node' import { useTaskNodeStore } from '@/store/project/task-node'
import { queryProcessDefinitionByCode } from '@/service/modules/process-definition' import { queryProcessDefinitionByCode } from '@/service/modules/process-definition'
import { findIndex } from 'lodash'
import type { IJsonItem } from '../types' import type { IJsonItem } from '../types'
export function useSwitch( export function useSwitch(
@ -42,6 +43,35 @@ export function useSwitch(
} }
}) })
loading.value = false 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( watch(
@ -53,6 +83,11 @@ export function useSwitch(
} }
) )
onMounted(async () => {
await nextTick()
clearUselessNode(branchFlowOptions.value)
})
return [ return [
{ {
type: 'multi-condition', type: 'multi-condition',

4
dolphinscheduler-ui-next/src/views/projects/workflow/components/dag/dag-toolbar.tsx

@ -168,11 +168,11 @@ export default defineComponent({
if (graph.value) { if (graph.value) {
const cells = graph.value.getSelectedCells() const cells = graph.value.getSelectedCells()
if (cells) { if (cells) {
graph.value?.removeCells(cells)
const codes = cells const codes = cells
.filter((cell) => cell.isNode()) .filter((cell) => cell.isNode())
.map((cell) => +cell.id) .map((cell) => +cell.id)
context.emit('removeTasks', codes) context.emit('removeTasks', codes, cells)
graph.value?.removeCells(cells)
} }
} }
} }

14
dolphinscheduler-ui-next/src/views/projects/workflow/components/dag/use-task-edit.ts

@ -108,7 +108,7 @@ export function useTaskEdit(options: Options) {
* Remove task * Remove task
* @param {number} codes * @param {number} codes
*/ */
function removeTasks(codes: number[]) { function removeTasks(codes: number[], cells: any[]) {
processDefinition.value.taskDefinitionList = processDefinition.value.taskDefinitionList =
processDefinition.value.taskDefinitionList.filter( processDefinition.value.taskDefinitionList.filter(
(task) => !codes.includes(task.code) (task) => !codes.includes(task.code)
@ -120,6 +120,18 @@ export function useTaskEdit(options: Options) {
process.postTaskCode === code || process.preTaskCode === code 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) { function openTaskModal(task: NodeData) {

Loading…
Cancel
Save