Browse Source

[Fix][UI Next][V1.0.0-Alpha]Fix branch flown and Custom Parameters field options missing. (#8933)

3.0.0/version-upgrade
Amy0104 3 years ago committed by GitHub
parent
commit
4bb85dd16b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 89
      dolphinscheduler-ui-next/src/store/project/task-node.ts
  2. 26
      dolphinscheduler-ui-next/src/store/project/types.ts
  3. 13
      dolphinscheduler-ui-next/src/views/projects/task/components/node/detail-modal.tsx
  4. 4
      dolphinscheduler-ui-next/src/views/projects/task/components/node/detail.tsx
  5. 41
      dolphinscheduler-ui-next/src/views/projects/task/components/node/fields/use-conditions.ts
  6. 99
      dolphinscheduler-ui-next/src/views/projects/task/components/node/fields/use-pre-tasks.ts
  7. 2
      dolphinscheduler-ui-next/src/views/projects/task/components/node/tasks/use-conditions.ts
  8. 2
      dolphinscheduler-ui-next/src/views/projects/task/components/node/tasks/use-data-quality.ts
  9. 2
      dolphinscheduler-ui-next/src/views/projects/task/components/node/tasks/use-datax.ts
  10. 20
      dolphinscheduler-ui-next/src/views/projects/task/components/node/tasks/use-dependent.ts
  11. 2
      dolphinscheduler-ui-next/src/views/projects/task/components/node/tasks/use-emr.ts
  12. 2
      dolphinscheduler-ui-next/src/views/projects/task/components/node/tasks/use-flink.ts
  13. 2
      dolphinscheduler-ui-next/src/views/projects/task/components/node/tasks/use-http.ts
  14. 2
      dolphinscheduler-ui-next/src/views/projects/task/components/node/tasks/use-mr.ts
  15. 2
      dolphinscheduler-ui-next/src/views/projects/task/components/node/tasks/use-pigeon.ts
  16. 2
      dolphinscheduler-ui-next/src/views/projects/task/components/node/tasks/use-procedure.ts
  17. 2
      dolphinscheduler-ui-next/src/views/projects/task/components/node/tasks/use-python.ts
  18. 2
      dolphinscheduler-ui-next/src/views/projects/task/components/node/tasks/use-sea-tunnel.ts
  19. 2
      dolphinscheduler-ui-next/src/views/projects/task/components/node/tasks/use-shell.ts
  20. 2
      dolphinscheduler-ui-next/src/views/projects/task/components/node/tasks/use-spark.ts
  21. 2
      dolphinscheduler-ui-next/src/views/projects/task/components/node/tasks/use-sql.ts
  22. 2
      dolphinscheduler-ui-next/src/views/projects/task/components/node/tasks/use-sqoop.ts
  23. 2
      dolphinscheduler-ui-next/src/views/projects/task/components/node/tasks/use-sub-process.ts
  24. 2
      dolphinscheduler-ui-next/src/views/projects/task/components/node/tasks/use-switch.ts
  25. 6
      dolphinscheduler-ui-next/src/views/projects/task/components/node/types.ts
  26. 20
      dolphinscheduler-ui-next/src/views/projects/task/components/node/use-task.ts
  27. 6
      dolphinscheduler-ui-next/src/views/projects/workflow/components/dag/use-cell-update.ts

89
dolphinscheduler-ui-next/src/store/project/task-node.ts

@ -0,0 +1,89 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { defineStore } from 'pinia'
import { uniqBy } from 'lodash'
import type { TaskNodeState, EditWorkflowDefinition, IOption } from './types'
export const useTaskNodeStore = defineStore({
id: 'project-task',
state: (): TaskNodeState => ({
preTaskOptions: [],
postTaskOptions: [],
preTasks: []
}),
persist: true,
getters: {
getPreTaskOptions(): IOption[] {
return this.preTaskOptions
},
getPostTaskOptions(): IOption[] {
return this.postTaskOptions
},
getPreTasks(): number[] {
return this.preTasks
}
},
actions: {
updateDefinition(definition?: EditWorkflowDefinition, code?: number) {
if (!definition) return
const { processTaskRelationList = [], taskDefinitionList = [] } =
definition
const preTaskOptions: { value: number; label: string }[] = []
const tasks: { [field: number]: string } = {}
taskDefinitionList.forEach(
(task: { code: number; taskType: string; name: string }) => {
tasks[task.code] = task.name
if (task.code === code) return
if (
task.taskType === 'CONDITIONS' &&
processTaskRelationList.filter(
(relation: { preTaskCode: number }) =>
relation.preTaskCode === task.code
).length >= 2
) {
return
}
preTaskOptions.push({
value: task.code,
label: task.name
})
}
)
this.preTaskOptions = uniqBy(preTaskOptions, 'value')
if (!code) return
const preTasks: number[] = []
const postTaskOptions: { value: number; label: string }[] = []
processTaskRelationList.forEach(
(relation: { preTaskCode: number; postTaskCode: number }) => {
if (relation.preTaskCode === code) {
postTaskOptions.push({
value: relation.postTaskCode,
label: tasks[relation.postTaskCode]
})
}
if (relation.postTaskCode === code && relation.preTaskCode !== 0) {
preTasks.push(relation.preTaskCode)
}
}
)
this.preTasks = preTasks
this.postTaskOptions = postTaskOptions
}
}
})

26
dolphinscheduler-ui-next/src/store/project/types.ts

@ -0,0 +1,26 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import type { EditWorkflowDefinition } from '@/views/projects/workflow/components/dag/types'
import type { IOption } from '@/components/form/types'
interface TaskNodeState {
postTaskOptions: IOption[]
preTaskOptions: IOption[]
preTasks: number[]
}
export { TaskNodeState, EditWorkflowDefinition, IOption }

13
dolphinscheduler-ui-next/src/views/projects/task/components/node/detail-modal.tsx

@ -23,13 +23,13 @@ import {
nextTick, nextTick,
provide, provide,
computed, computed,
h h,
Ref
} from 'vue' } from 'vue'
import { useI18n } from 'vue-i18n' import { useI18n } from 'vue-i18n'
import Modal from '@/components/modal' import Modal from '@/components/modal'
import Detail from './detail' import Detail from './detail'
import { formatModel } from './format-data' import { formatModel } from './format-data'
import type { ITaskData, ITaskType } from './types'
import { import {
HistoryOutlined, HistoryOutlined,
ProfileOutlined, ProfileOutlined,
@ -38,10 +38,13 @@ import {
import { NIcon } from 'naive-ui' import { NIcon } from 'naive-ui'
import { TASK_TYPES_MAP } from '../../constants/task-type' import { TASK_TYPES_MAP } from '../../constants/task-type'
import { Router, useRouter } from 'vue-router' import { Router, useRouter } from 'vue-router'
import { import type {
ITaskData,
ITaskType,
EditWorkflowDefinition,
IWorkflowTaskInstance, IWorkflowTaskInstance,
WorkflowInstance WorkflowInstance
} from '@/views/projects/workflow/components/dag/types' } from './types'
const props = { const props = {
show: { show: {
@ -65,7 +68,7 @@ const props = {
default: 0 default: 0
}, },
definition: { definition: {
type: Object as PropType<any> type: Object as PropType<Ref<EditWorkflowDefinition>>
}, },
processInstance: { processInstance: {
type: Object as PropType<WorkflowInstance> type: Object as PropType<WorkflowInstance>

4
dolphinscheduler-ui-next/src/views/projects/task/components/node/detail.tsx

@ -18,7 +18,7 @@
import { defineComponent, ref, watch, inject, Ref, unref } from 'vue' import { defineComponent, ref, watch, inject, Ref, unref } from 'vue'
import Form from '@/components/form' import Form from '@/components/form'
import { useTask } from './use-task' import { useTask } from './use-task'
import type { ITaskData } from './types' import type { ITaskData, EditWorkflowDefinition } from './types'
interface IDetailPanel { interface IDetailPanel {
projectCode: number projectCode: number
@ -26,7 +26,7 @@ interface IDetailPanel {
readonly: false readonly: false
from: number from: number
detailRef?: Ref detailRef?: Ref
definition?: object definition?: EditWorkflowDefinition
} }
const NodeDetail = defineComponent({ const NodeDetail = defineComponent({

41
dolphinscheduler-ui-next/src/views/projects/task/components/node/fields/use-conditions.ts

@ -15,48 +15,23 @@
* limitations under the License. * limitations under the License.
*/ */
import { ref, watch } from 'vue'
import { useI18n } from 'vue-i18n' import { useI18n } from 'vue-i18n'
import { useTaskNodeStore } from '@/store/project/task-node'
import { useRelationCustomParams, useTimeoutAlarm } from '.' import { useRelationCustomParams, useTimeoutAlarm } from '.'
import type { IJsonItem } from '../types' import type { IJsonItem } from '../types'
export function useConditions(model: { [field: string]: any }): IJsonItem[] { export function useConditions(model: { [field: string]: any }): IJsonItem[] {
const { t } = useI18n() const { t } = useI18n()
const taskStore = useTaskNodeStore()
const taskCodeOptions = ref([] as { label: string; value: number }[]) const preTaskOptions = taskStore.preTaskOptions.filter((option) =>
const postTasksOptions = ref([] as { label: string; value: number }[]) taskStore.preTasks.includes(Number(option.value))
)
const stateOptions = [ const stateOptions = [
{ label: t('project.node.success'), value: 'success' }, { label: t('project.node.success'), value: 'success' },
{ label: t('project.node.failed'), value: 'failed' } { label: t('project.node.failed'), value: 'failed' }
] ]
watch(
() => model.preTasks,
() => {
taskCodeOptions.value =
model.preTaskOptions
?.filter((task: { code: number }) =>
model.preTasks?.includes(task.code)
)
.map((task: { code: number; name: string }) => ({
value: task.code,
label: task.name
})) || []
}
)
watch(
() => model.postTaskOptions,
() => {
postTasksOptions.value = model.postTasksOptions.map(
(task: { code: number; name: string }) => ({
value: task.code,
label: task.name
})
)
}
)
return [ return [
{ {
type: 'select', type: 'select',
@ -76,7 +51,7 @@ export function useConditions(model: { [field: string]: any }): IJsonItem[] {
props: { props: {
clearable: true clearable: true
}, },
options: postTasksOptions options: taskStore.getPostTaskOptions
}, },
{ {
type: 'select', type: 'select',
@ -96,7 +71,7 @@ export function useConditions(model: { [field: string]: any }): IJsonItem[] {
props: { props: {
clearable: true clearable: true
}, },
options: postTasksOptions options: taskStore.getPostTaskOptions
}, },
...useTimeoutAlarm(model), ...useTimeoutAlarm(model),
...useRelationCustomParams({ ...useRelationCustomParams({
@ -110,7 +85,7 @@ export function useConditions(model: { [field: string]: any }): IJsonItem[] {
type: 'select', type: 'select',
field: 'depTaskCode', field: 'depTaskCode',
span: 10, span: 10,
options: taskCodeOptions options: preTaskOptions
}, },
{ {
type: 'select', type: 'select',

99
dolphinscheduler-ui-next/src/views/projects/task/components/node/fields/use-pre-tasks.ts

@ -15,43 +15,13 @@
* limitations under the License. * limitations under the License.
*/ */
import { ref, watch } from 'vue'
import { useI18n } from 'vue-i18n' import { useI18n } from 'vue-i18n'
import { uniqBy } from 'lodash' import { useTaskNodeStore } from '@/store/project/task-node'
import type { IJsonItem } from '../types' import type { IJsonItem } from '../types'
export function usePreTasks( export function usePreTasks(): IJsonItem {
model: { [field: string]: any },
code?: number
): IJsonItem {
const { t } = useI18n() const { t } = useI18n()
const taskStore = useTaskNodeStore()
const options = ref([] as { value: number; label: string }[])
const getOptions = (
options: { code: number; name: string }[]
): { value: number; label: string }[] => {
if (!options?.length) return []
return options.map((task: { code: number; name: string }) => ({
value: task.code,
label: task.name
}))
}
watch(
() => model.definition,
(value) => {
if (!value) return
const {
preTaskOptions,
preTasks = [],
postTaskOptions = []
} = getTaskOptions(value, code)
model.preTasks = preTasks
model.postTaskOptions = postTaskOptions
options.value = getOptions(preTaskOptions)
}
)
return { return {
type: 'select', type: 'select',
@ -63,67 +33,6 @@ export function usePreTasks(
multiple: true, multiple: true,
filterable: true filterable: true
}, },
options options: taskStore.getPreTaskOptions
}
}
function getTaskOptions(
processDefinition: {
processTaskRelationList: []
taskDefinitionList: []
},
code?: number
): {
preTaskOptions: { code: number; name: string }[]
preTasks?: number[]
postTaskOptions?: { code: number; name: string }[]
} {
const { processTaskRelationList = [], taskDefinitionList = [] } =
processDefinition
const preTaskOptions: { code: number; name: string }[] = []
const tasks: { [field: number]: string } = {}
taskDefinitionList.forEach(
(task: { code: number; taskType: string; name: string }) => {
tasks[task.code] = task.name
if (task.code === code) return
if (
task.taskType === 'CONDITIONS' &&
processTaskRelationList.filter(
(relation: { preTaskCode: number }) =>
relation.preTaskCode === task.code
).length >= 2
) {
return
}
preTaskOptions.push({
code: task.code,
name: task.name
})
}
)
if (!code)
return {
preTaskOptions: uniqBy(preTaskOptions, 'code')
}
const preTasks: number[] = []
const postTaskOptions: { code: number; name: string }[] = []
processTaskRelationList.forEach(
(relation: { preTaskCode: number; postTaskCode: number }) => {
if (relation.preTaskCode === code) {
postTaskOptions.push({
code: relation.postTaskCode,
name: tasks[relation.postTaskCode]
})
}
if (relation.postTaskCode === code && relation.preTaskCode !== 0) {
preTasks.push(relation.preTaskCode)
}
}
)
return {
preTaskOptions: uniqBy(preTaskOptions, 'code'),
preTasks,
postTaskOptions
} }
} }

2
dolphinscheduler-ui-next/src/views/projects/task/components/node/tasks/use-conditions.ts

@ -75,7 +75,7 @@ export function useConditions({
...Fields.useTaskGroup(model, projectCode), ...Fields.useTaskGroup(model, projectCode),
...Fields.useFailed(), ...Fields.useFailed(),
...Fields.useConditions(model), ...Fields.useConditions(model),
Fields.usePreTasks(model, data?.code) Fields.usePreTasks()
] as IJsonItem[], ] as IJsonItem[],
model model
} }

2
dolphinscheduler-ui-next/src/views/projects/task/components/node/tasks/use-data-quality.ts

@ -108,7 +108,7 @@ export function useDataQuality({
field: 'localParams', field: 'localParams',
isSimple: true isSimple: true
}), }),
Fields.usePreTasks(model, data?.code) Fields.usePreTasks()
] as IJsonItem[], ] as IJsonItem[],
model model
} }

2
dolphinscheduler-ui-next/src/views/projects/task/components/node/tasks/use-datax.ts

@ -94,7 +94,7 @@ export function useDataX({
Fields.useDelayTime(model), Fields.useDelayTime(model),
...Fields.useTimeoutAlarm(model), ...Fields.useTimeoutAlarm(model),
...Fields.useDataX(model), ...Fields.useDataX(model),
Fields.usePreTasks(model, data?.code) Fields.usePreTasks()
] as IJsonItem[], ] as IJsonItem[],
model model
} }

20
dolphinscheduler-ui-next/src/views/projects/task/components/node/tasks/use-dependent.ts

@ -15,7 +15,7 @@
* limitations under the License. * limitations under the License.
*/ */
import { ref, reactive, watch } from 'vue' import { reactive } from 'vue'
import * as Fields from '../fields/index' import * as Fields from '../fields/index'
import type { IJsonItem, INodeData, ITaskData } from '../types' import type { IJsonItem, INodeData, ITaskData } from '../types'
@ -30,7 +30,6 @@ export function useDependent({
readonly?: boolean readonly?: boolean
data?: ITaskData data?: ITaskData
}) { }) {
const taskCodeOptions = ref([] as { label: string; value: number }[])
const model = reactive({ const model = reactive({
taskType: 'DEPENDENT', taskType: 'DEPENDENT',
name: '', name: '',
@ -66,21 +65,6 @@ export function useDependent({
] ]
} }
watch(
() => model.preTasks,
() => {
taskCodeOptions.value =
model.preTaskOptions
?.filter((task: { code: number }) =>
model.preTasks?.includes(task.code)
)
.map((task: { code: number; name: string }) => ({
value: task.code,
label: task.name
})) || []
}
)
return { return {
json: [ json: [
Fields.useName(), Fields.useName(),
@ -93,7 +77,7 @@ export function useDependent({
...Fields.useTaskGroup(model, projectCode), ...Fields.useTaskGroup(model, projectCode),
...Fields.useFailed(), ...Fields.useFailed(),
...Fields.useDependent(model), ...Fields.useDependent(model),
Fields.usePreTasks(model, data?.code) Fields.usePreTasks()
] as IJsonItem[], ] as IJsonItem[],
model model
} }

2
dolphinscheduler-ui-next/src/views/projects/task/components/node/tasks/use-emr.ts

@ -74,7 +74,7 @@ export function useEmr({
Fields.useDelayTime(model), Fields.useDelayTime(model),
...Fields.useTimeoutAlarm(model), ...Fields.useTimeoutAlarm(model),
...Fields.useEmr(model), ...Fields.useEmr(model),
Fields.usePreTasks(model, data?.code) Fields.usePreTasks()
] as IJsonItem[], ] as IJsonItem[],
model model
} }

2
dolphinscheduler-ui-next/src/views/projects/task/components/node/tasks/use-flink.ts

@ -81,7 +81,7 @@ export function useFlink({
Fields.useDelayTime(model), Fields.useDelayTime(model),
...Fields.useTimeoutAlarm(model), ...Fields.useTimeoutAlarm(model),
...Fields.useFlink(model), ...Fields.useFlink(model),
Fields.usePreTasks(model, data?.code) Fields.usePreTasks()
] as IJsonItem[], ] as IJsonItem[],
model model
} }

2
dolphinscheduler-ui-next/src/views/projects/task/components/node/tasks/use-http.ts

@ -81,7 +81,7 @@ export function useHttp({
Fields.useDelayTime(model), Fields.useDelayTime(model),
...Fields.useTimeoutAlarm(model), ...Fields.useTimeoutAlarm(model),
...Fields.useHttp(model), ...Fields.useHttp(model),
Fields.usePreTasks(model, data?.code) Fields.usePreTasks()
] as IJsonItem[], ] as IJsonItem[],
model model
} }

2
dolphinscheduler-ui-next/src/views/projects/task/components/node/tasks/use-mr.ts

@ -74,7 +74,7 @@ export function useMr({
Fields.useDelayTime(model), Fields.useDelayTime(model),
...Fields.useTimeoutAlarm(model), ...Fields.useTimeoutAlarm(model),
...Fields.useMr(model), ...Fields.useMr(model),
Fields.usePreTasks(model, data?.code) Fields.usePreTasks()
] as IJsonItem[], ] as IJsonItem[],
model model
} }

2
dolphinscheduler-ui-next/src/views/projects/task/components/node/tasks/use-pigeon.ts

@ -73,7 +73,7 @@ export function usePigeon({
Fields.useDelayTime(model), Fields.useDelayTime(model),
...Fields.useTimeoutAlarm(model), ...Fields.useTimeoutAlarm(model),
Fields.useTargetTaskName(), Fields.useTargetTaskName(),
Fields.usePreTasks(model, data?.code) Fields.usePreTasks()
] as IJsonItem[], ] as IJsonItem[],
model model
} }

2
dolphinscheduler-ui-next/src/views/projects/task/components/node/tasks/use-procedure.ts

@ -79,7 +79,7 @@ export function useProcedure({
Fields.useDatasourceType(model), Fields.useDatasourceType(model),
Fields.useDatasource(model), Fields.useDatasource(model),
...Fields.useProcedure(model), ...Fields.useProcedure(model),
Fields.usePreTasks(model, data?.code) Fields.usePreTasks()
] as IJsonItem[], ] as IJsonItem[],
model model
} }

2
dolphinscheduler-ui-next/src/views/projects/task/components/node/tasks/use-python.ts

@ -75,7 +75,7 @@ export function usePython({
Fields.useDelayTime(model), Fields.useDelayTime(model),
...Fields.useTimeoutAlarm(model), ...Fields.useTimeoutAlarm(model),
...Fields.useShell(model), ...Fields.useShell(model),
Fields.usePreTasks(model, data?.code) Fields.usePreTasks()
] as IJsonItem[], ] as IJsonItem[],
model model
} }

2
dolphinscheduler-ui-next/src/views/projects/task/components/node/tasks/use-sea-tunnel.ts

@ -79,7 +79,7 @@ export function useSeaTunnel({
Fields.useDelayTime(model), Fields.useDelayTime(model),
...Fields.useTimeoutAlarm(model), ...Fields.useTimeoutAlarm(model),
...Fields.useSeaTunnel(model), ...Fields.useSeaTunnel(model),
Fields.usePreTasks(model, data?.code) Fields.usePreTasks()
] as IJsonItem[], ] as IJsonItem[],
model model
} }

2
dolphinscheduler-ui-next/src/views/projects/task/components/node/tasks/use-shell.ts

@ -75,7 +75,7 @@ export function useShell({
Fields.useDelayTime(model), Fields.useDelayTime(model),
...Fields.useTimeoutAlarm(model), ...Fields.useTimeoutAlarm(model),
...Fields.useShell(model), ...Fields.useShell(model),
Fields.usePreTasks(model, data?.code) Fields.usePreTasks()
] as IJsonItem[], ] as IJsonItem[],
model model
} }

2
dolphinscheduler-ui-next/src/views/projects/task/components/node/tasks/use-spark.ts

@ -81,7 +81,7 @@ export function useSpark({
Fields.useDelayTime(model), Fields.useDelayTime(model),
...Fields.useTimeoutAlarm(model), ...Fields.useTimeoutAlarm(model),
...Fields.useSpark(model), ...Fields.useSpark(model),
Fields.usePreTasks(model, data?.code) Fields.usePreTasks()
] as IJsonItem[], ] as IJsonItem[],
model model
} }

2
dolphinscheduler-ui-next/src/views/projects/task/components/node/tasks/use-sql.ts

@ -87,7 +87,7 @@ export function useSql({
Fields.useDatasource(model), Fields.useDatasource(model),
Fields.useSqlType(model), Fields.useSqlType(model),
...Fields.useSql(model), ...Fields.useSql(model),
Fields.usePreTasks(model, data?.code) Fields.usePreTasks()
] as IJsonItem[], ] as IJsonItem[],
model model
} }

2
dolphinscheduler-ui-next/src/views/projects/task/components/node/tasks/use-sqoop.ts

@ -93,7 +93,7 @@ export function useSqoop({
Fields.useDelayTime(model), Fields.useDelayTime(model),
...Fields.useTimeoutAlarm(model), ...Fields.useTimeoutAlarm(model),
...Fields.useSqoop(model), ...Fields.useSqoop(model),
Fields.usePreTasks(model, data?.code) Fields.usePreTasks()
] as IJsonItem[], ] as IJsonItem[],
model model
} }

2
dolphinscheduler-ui-next/src/views/projects/task/components/node/tasks/use-sub-process.ts

@ -81,7 +81,7 @@ export function useSubProcess({
processName: data?.processName, processName: data?.processName,
code: from === 1 ? 0 : Number(workflowCode) code: from === 1 ? 0 : Number(workflowCode)
}), }),
Fields.usePreTasks(model, data?.code) Fields.usePreTasks()
] as IJsonItem[], ] as IJsonItem[],
model model
} }

2
dolphinscheduler-ui-next/src/views/projects/task/components/node/tasks/use-switch.ts

@ -77,7 +77,7 @@ export function useSwitch({
Fields.useDelayTime(model), Fields.useDelayTime(model),
...Fields.useTimeoutAlarm(model), ...Fields.useTimeoutAlarm(model),
...Fields.useSwitch(model, projectCode), ...Fields.useSwitch(model, projectCode),
Fields.usePreTasks(model, data?.code) Fields.usePreTasks()
] as IJsonItem[], ] as IJsonItem[],
model model
} }

6
dolphinscheduler-ui-next/src/views/projects/task/components/node/types.ts

@ -17,7 +17,6 @@
import { VNode } from 'vue' import { VNode } from 'vue'
import type { SelectOption } from 'naive-ui' import type { SelectOption } from 'naive-ui'
import type { TaskType } from '@/views/projects/task/constants/task-type' import type { TaskType } from '@/views/projects/task/constants/task-type'
import type { IDataBase } from '@/service/modules/data-source/types' import type { IDataBase } from '@/service/modules/data-source/types'
import type { import type {
@ -26,6 +25,11 @@ import type {
FormRules, FormRules,
IJsonItemParams IJsonItemParams
} from '@/components/form/types' } from '@/components/form/types'
export type { EditWorkflowDefinition } from '@/views/projects/workflow/components/dag/types'
export type {
IWorkflowTaskInstance,
WorkflowInstance
} from '@/views/projects/workflow/components/dag/types'
type ProgramType = 'JAVA' | 'SCALA' | 'PYTHON' type ProgramType = 'JAVA' | 'SCALA' | 'PYTHON'
type SourceType = 'MYSQL' | 'HDFS' | 'HIVE' type SourceType = 'MYSQL' | 'HDFS' | 'HIVE'

20
dolphinscheduler-ui-next/src/views/projects/task/components/node/use-task.ts

@ -14,10 +14,18 @@
* 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, Ref, watch } from 'vue' import { ref, Ref, unref, watch } from 'vue'
import nodes from './tasks' import nodes from './tasks'
import getElementByJson from '@/components/form/get-elements-by-json' import getElementByJson from '@/components/form/get-elements-by-json'
import { IFormItem, IJsonItem, INodeData, ITaskData, FormRules } from './types' import { useTaskNodeStore } from '@/store/project/task-node'
import type {
IFormItem,
IJsonItem,
INodeData,
ITaskData,
FormRules,
EditWorkflowDefinition
} from './types'
export function useTask({ export function useTask({
data, data,
@ -30,15 +38,19 @@ export function useTask({
projectCode: number projectCode: number
from?: number from?: number
readonly?: boolean readonly?: boolean
definition?: object definition?: EditWorkflowDefinition
}): { }): {
elementsRef: Ref<IFormItem[]> elementsRef: Ref<IFormItem[]>
rulesRef: Ref<FormRules> rulesRef: Ref<FormRules>
model: INodeData model: INodeData
} { } {
const taskStore = useTaskNodeStore()
taskStore.updateDefinition(unref(definition), data?.code)
const jsonRef = ref([]) as Ref<IJsonItem[]> const jsonRef = ref([]) as Ref<IJsonItem[]>
const elementsRef = ref([]) as Ref<IFormItem[]> const elementsRef = ref([]) as Ref<IFormItem[]>
const rulesRef = ref({}) const rulesRef = ref({})
const params = { const params = {
projectCode, projectCode,
from, from,
@ -49,7 +61,7 @@ export function useTask({
const { model, json } = nodes[data.taskType || 'SHELL'](params) const { model, json } = nodes[data.taskType || 'SHELL'](params)
jsonRef.value = json jsonRef.value = json
model.definition = definition model.preTasks = taskStore.getPreTasks
const getElements = () => { const getElements = () => {
const { rules, elements } = getElementByJson(jsonRef.value, model) const { rules, elements } = getElementByJson(jsonRef.value, model)

6
dolphinscheduler-ui-next/src/views/projects/workflow/components/dag/use-cell-update.ts

@ -99,9 +99,9 @@ export function useCellUpdate(options: Options) {
if (!edges.length) return [] if (!edges.length) return []
const targets = [] as number[] const targets = [] as number[]
edges.forEach((edge) => { edges.forEach((edge) => {
const targetNode = edge.getSourceNode() const sourceNode = edge.getSourceNode()
if (targetNode) { if (sourceNode && sourceNode.id !== id) {
targets.push(Number(targetNode.id)) targets.push(Number(sourceNode.id))
} }
}) })
return targets return targets

Loading…
Cancel
Save