Browse Source
* modify the function of queryTaskSubProcessDepOnProcess * add a function to query downstream dependent tasks * confirm to make the workflow offline * query dependent tasks * check dependencies * done * done * done * done * improve the test case * improve the test case * improve codes * prettier the codes * prettier the codesdev_wenjun_refactorMaster
calvin
9 months ago
committed by
GitHub
26 changed files with 692 additions and 92 deletions
@ -0,0 +1,129 @@
|
||||
/* |
||||
* 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 { |
||||
defineComponent, |
||||
PropType, |
||||
h, |
||||
ref, watch |
||||
} from 'vue' |
||||
import { useI18n } from 'vue-i18n' |
||||
import {NEllipsis, NModal, NSpace} from 'naive-ui' |
||||
import {IDefinitionData} from "@/views/projects/workflow/definition/types"; |
||||
import ButtonLink from "@/components/button-link"; |
||||
|
||||
const props = { |
||||
row: { |
||||
type: Object as PropType<IDefinitionData>, |
||||
default: {}, |
||||
required: false |
||||
}, |
||||
show: { |
||||
type: Boolean as PropType<boolean>, |
||||
default: false |
||||
}, |
||||
required: { |
||||
type: Boolean as PropType<boolean>, |
||||
default: true |
||||
}, |
||||
taskLinks: { |
||||
type: Array, |
||||
default: [] |
||||
}, |
||||
content: { |
||||
type: String, |
||||
default: '' |
||||
} |
||||
} |
||||
|
||||
export default defineComponent({ |
||||
name: 'dependenciesConfirm', |
||||
props, |
||||
emits: ['update:show', 'update:row', 'confirm'], |
||||
setup(props, ctx) { |
||||
const { t } = useI18n() |
||||
|
||||
const showRef = ref(props.show) |
||||
|
||||
const confirmToHandle = () => { |
||||
ctx.emit('confirm') |
||||
} |
||||
|
||||
const cancelToHandle = () => { |
||||
ctx.emit('update:show', showRef) |
||||
} |
||||
|
||||
const renderDownstreamDependencies = () => { |
||||
return h( |
||||
<NSpace vertical> |
||||
<div>{props.content}</div> |
||||
<div>{t('project.workflow.warning_dependencies')}</div> |
||||
{props.taskLinks.map((item: any) => { |
||||
return ( |
||||
<ButtonLink |
||||
onClick={item.action} |
||||
disabled={false} |
||||
> |
||||
{{ |
||||
default: () => |
||||
h(NEllipsis, |
||||
{ |
||||
style: 'max-width: 350px;line-height: 1.5' |
||||
}, |
||||
() => item.text |
||||
) |
||||
}} |
||||
</ButtonLink> |
||||
) |
||||
})} |
||||
</NSpace> |
||||
) |
||||
} |
||||
|
||||
watch(()=> props.show, |
||||
() => { |
||||
showRef.value = props.show |
||||
}) |
||||
|
||||
return {renderDownstreamDependencies, confirmToHandle, cancelToHandle, showRef} |
||||
}, |
||||
|
||||
render() { |
||||
const { t } = useI18n() |
||||
|
||||
return ( |
||||
<NModal |
||||
v-model:show={this.showRef} |
||||
preset={'dialog'} |
||||
type={this.$props.required? 'error':'warning'} |
||||
title={t('project.workflow.warning_dependent_tasks_title')} |
||||
positiveText={this.$props.required? '':t('project.workflow.confirm')} |
||||
negativeText={t('project.workflow.cancel')} |
||||
maskClosable={false} |
||||
onNegativeClick={this.cancelToHandle} |
||||
onPositiveClick={this.confirmToHandle} |
||||
onClose={this.cancelToHandle} |
||||
> |
||||
{{ |
||||
default: () => ( |
||||
this.renderDownstreamDependencies() |
||||
) |
||||
}} |
||||
</NModal> |
||||
) |
||||
} |
||||
}) |
@ -0,0 +1,122 @@
|
||||
/* |
||||
* 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 {DependentTaskReq} from "@/service/modules/lineages/types"; |
||||
import {queryDependentTasks} from "@/service/modules/lineages"; |
||||
import {TASK_TYPES_MAP} from "@/store/project"; |
||||
|
||||
export function useDependencies() { |
||||
|
||||
const getDependentTasksBySingleTask = async (projectCode: any, workflowCode: any, taskCode: any) => { |
||||
let tasks = [] as any |
||||
if (workflowCode && taskCode) { |
||||
let dependentTaskReq = {workFlowCode: workflowCode, taskCode: taskCode} as DependentTaskReq |
||||
const res = await queryDependentTasks(projectCode, dependentTaskReq) |
||||
res.filter((item: any) => item.processDefinitionCode !== workflowCode && item.taskType === TASK_TYPES_MAP.DEPENDENT.alias) |
||||
.forEach((item: any) => { |
||||
tasks.push(item.processDefinitionName + '->' + item.taskName) |
||||
}) |
||||
} |
||||
return tasks |
||||
} |
||||
|
||||
const getDependentTasksByWorkflow = async (projectCode: any, workflowCode: any) => { |
||||
let tasks = [] as any |
||||
if (workflowCode) { |
||||
let dependentTaskReq = {workFlowCode: workflowCode} as DependentTaskReq |
||||
const res = await queryDependentTasks(projectCode, dependentTaskReq) |
||||
res.filter((item: any) => item.processDefinitionCode !== workflowCode && item.taskType === TASK_TYPES_MAP.DEPENDENT.alias) |
||||
.forEach((item: any) => { |
||||
tasks.push(item.processDefinitionName + '->' + item.taskName) |
||||
}) |
||||
} |
||||
return tasks |
||||
} |
||||
|
||||
const getDependentTasksByMultipleTasks = async (projectCode: any, workflowCode: any, taskCodes: any[]) => { |
||||
let tasks = [] as any |
||||
if (workflowCode && taskCodes?.length>0) { |
||||
for(const taskCode of taskCodes) { |
||||
const res = await getDependentTasksBySingleTask(projectCode, workflowCode, taskCode) |
||||
if (res?.length >0) { |
||||
tasks = tasks.concat(res) |
||||
} |
||||
} |
||||
} |
||||
return tasks |
||||
} |
||||
|
||||
const getDependentTaskLinksByMultipleTasks = async (projectCode: any, workflowCode: any, taskCodes: any[]) => { |
||||
let dependentTaskLinks = [] as any |
||||
if (workflowCode && projectCode) { |
||||
for (const taskCode of taskCodes) { |
||||
await getDependentTaskLinksByTask(projectCode, workflowCode, taskCode).then((res: any) => { |
||||
dependentTaskLinks = dependentTaskLinks.concat(res) |
||||
}) |
||||
} |
||||
} |
||||
return dependentTaskLinks |
||||
} |
||||
|
||||
const getDependentTaskLinks = async (projectCode: any, workflowCode: any) => { |
||||
let dependentTaskReq = {workFlowCode: workflowCode} as DependentTaskReq |
||||
let dependentTaskLinks = [] as any |
||||
if (workflowCode && projectCode) { |
||||
await queryDependentTasks(projectCode, dependentTaskReq).then((res: any) => { |
||||
res.filter((item: any) => item.processDefinitionCode !== workflowCode && item.taskType === TASK_TYPES_MAP.DEPENDENT.alias) |
||||
.forEach((item: any) => { |
||||
dependentTaskLinks.push( |
||||
{ |
||||
text: item.processDefinitionName + '->' + item.taskName, |
||||
show: true, |
||||
action: () => { |
||||
const url = `/projects/${item.projectCode}/workflow/definitions/${item.processDefinitionCode}` |
||||
window.open(url, '_blank') |
||||
}, |
||||
} |
||||
) |
||||
}) |
||||
}) |
||||
} |
||||
return dependentTaskLinks |
||||
} |
||||
|
||||
const getDependentTaskLinksByTask = async (projectCode: any, workflowCode: any, taskCode: any) => { |
||||
let dependentTaskReq = {workFlowCode: workflowCode, taskCode: taskCode} as DependentTaskReq |
||||
let dependentTaskLinks = [] as any |
||||
if (workflowCode && projectCode) { |
||||
await queryDependentTasks(projectCode, dependentTaskReq).then((res: any) => { |
||||
res.filter((item: any) => item.processDefinitionCode !== workflowCode && item.taskType === TASK_TYPES_MAP.DEPENDENT.alias) |
||||
.forEach((item: any) => { |
||||
dependentTaskLinks.push( |
||||
{ |
||||
text: item.processDefinitionName + '->' + item.taskName, |
||||
show: true, |
||||
action: () => { |
||||
const url = `/projects/${item.projectCode}/workflow/definitions/${item.processDefinitionCode}` |
||||
window.open(url, '_blank') |
||||
}, |
||||
} |
||||
) |
||||
}) |
||||
}) |
||||
} |
||||
return dependentTaskLinks |
||||
} |
||||
|
||||
return { getDependentTasksBySingleTask, getDependentTasksByMultipleTasks, getDependentTaskLinks, getDependentTasksByWorkflow, getDependentTaskLinksByTask, getDependentTaskLinksByMultipleTasks } |
||||
} |
Loading…
Reference in new issue