Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix][UI] Fix the preTask options are unavailable when creating a tas… #11501

Merged
merged 1 commit into from
Aug 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export { useExecutorMemory } from './use-executor-memory'
export { useExecutorCores } from './use-executor-cores'
export { useMainJar } from './use-main-jar'
export { useResources } from './use-resources'
export { useTaskDefinition } from './use-task-definition'

export { useShell } from './use-shell'
export { useSpark } from './use-spark'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,22 @@
* limitations under the License.
*/

import { ref, watch } from 'vue'
import { useI18n } from 'vue-i18n'
import { useTaskNodeStore } from '@/store/project/task-node'
import type { IJsonItem } from '../types'

export function usePreTasks(): IJsonItem {
const { t } = useI18n()
const taskStore = useTaskNodeStore()
const options = ref(taskStore.getPreTaskOptions)

watch(
() => taskStore.getPreTaskOptions,
(value) => {
options.value = value
}
)

return {
type: 'select',
Expand All @@ -33,6 +42,6 @@ export function usePreTasks(): IJsonItem {
multiple: true,
filterable: true
},
options: taskStore.getPreTaskOptions
options
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,26 @@ import {
querySimpleList,
queryProcessDefinitionByCode
} from '@/service/modules/process-definition'
import { useTaskNodeStore } from '@/store/project/task-node'
import type { IJsonItem } from '../types'

export function useProcessName({
model,
projectCode,
isCreate,
from,
processName
processName,
taskCode
}: {
model: { [field: string]: any }
projectCode: number
isCreate: boolean
from?: number
processName?: number
taskCode?: number
}): IJsonItem {
const { t } = useI18n()

const taskStore = useTaskNodeStore()
const options = ref([] as { label: string; value: string }[])
const loading = ref(false)

Expand All @@ -55,6 +58,7 @@ export function useProcessName({
if (!processCode) return
const res = await queryProcessDefinitionByCode(processCode, projectCode)
model.definition = res
taskStore.updateDefinition(res, taskCode)
}

const onChange = (code: number) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* 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 { useTaskType, useProcessName } from '.'
import type { IJsonItem, ITaskData } from '../types'

export const useTaskDefinition = ({
projectCode,
from = 0,
readonly,
data,
model
}: {
projectCode: number
from?: number
readonly?: boolean
data?: ITaskData
model: { [field: string]: any }
}): IJsonItem[] => {
if (from === 0) return []
return [
useTaskType(model, readonly),
useProcessName({
model,
projectCode,
isCreate: !data?.id,
from,
processName: data?.processName,
taskCode: data?.code
})
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,24 +51,10 @@ export function useChunjun({
timeoutNotifyStrategy: ['WARN']
} as INodeData)

let extra: IJsonItem[] = []
if (from === 1) {
extra = [
Fields.useTaskType(model, readonly),
Fields.useProcessName({
model,
projectCode,
isCreate: !data?.id,
from,
processName: data?.processName
})
]
}

return {
json: [
Fields.useName(from),
...extra,
...Fields.useTaskDefinition({ projectCode, from, readonly, data, model }),
Fields.useRunFlag(),
Fields.useDescription(),
Fields.useTaskPriority(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,24 +50,10 @@ export function useConditions({
timeoutNotifyStrategy: ['WARN']
} as INodeData)

let extra: IJsonItem[] = []
if (from === 1) {
extra = [
Fields.useTaskType(model, readonly),
Fields.useProcessName({
model,
projectCode,
isCreate: !data?.id,
from,
processName: data?.processName
})
]
}

return {
json: [
Fields.useName(from),
...extra,
...Fields.useTaskDefinition({ projectCode, from, readonly, data, model }),
Fields.useRunFlag(),
Fields.useDescription(),
Fields.useTaskPriority(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,24 +60,10 @@ export function useDataQuality({
others: '--conf spark.yarn.maxAppAttempts=1'
} as INodeData)

let extra: IJsonItem[] = []
if (from === 1) {
extra = [
Fields.useTaskType(model, readonly),
Fields.useProcessName({
model,
projectCode,
isCreate: !data?.id,
from,
processName: data?.processName
})
]
}

return {
json: [
Fields.useName(from),
...extra,
...Fields.useTaskDefinition({ projectCode, from, readonly, data, model }),
Fields.useRunFlag(),
Fields.useDescription(),
Fields.useTaskPriority(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,24 +54,10 @@ export function useDataX({
timeoutNotifyStrategy: ['WARN']
} as INodeData)

let extra: IJsonItem[] = []
if (from === 1) {
extra = [
Fields.useTaskType(model, readonly),
Fields.useProcessName({
model,
projectCode,
isCreate: !data?.id,
from,
processName: data?.processName
})
]
}

return {
json: [
Fields.useName(from),
...extra,
...Fields.useTaskDefinition({ projectCode, from, readonly, data, model }),
Fields.useRunFlag(),
Fields.useDescription(),
Fields.useTaskPriority(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,24 +51,10 @@ export function useDependent({
...data
} as INodeData)

let extra: IJsonItem[] = []
if (from === 1) {
extra = [
Fields.useTaskType(model, readonly),
Fields.useProcessName({
model,
projectCode,
isCreate: !data?.id,
from,
processName: data?.processName
})
]
}

return {
json: [
Fields.useName(from),
...extra,
...Fields.useTaskDefinition({ projectCode, from, readonly, data, model }),
Fields.useRunFlag(),
Fields.useDescription(),
Fields.useTaskPriority(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,24 +46,10 @@ export function useDinky({
timeoutNotifyStrategy: ['WARN']
} as INodeData)

let extra: IJsonItem[] = []
if (from === 1) {
extra = [
Fields.useTaskType(model, readonly),
Fields.useProcessName({
model,
projectCode,
isCreate: !data?.id,
from,
processName: data?.processName
})
]
}

return {
json: [
Fields.useName(from),
...extra,
...Fields.useTaskDefinition({ projectCode, from, readonly, data, model }),
Fields.useRunFlag(),
Fields.useDescription(),
Fields.useTaskPriority(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,27 +44,13 @@ export function useDvc({
delayTime: 0,
timeout: 30,
timeoutNotifyStrategy: ['WARN'],
dvcTaskType: 'Upload',
dvcTaskType: 'Upload'
} as INodeData)

let extra: IJsonItem[] = []
if (from === 1) {
extra = [
Fields.useTaskType(model, readonly),
Fields.useProcessName({
model,
projectCode,
isCreate: !data?.id,
from,
processName: data?.processName
})
]
}

return {
json: [
Fields.useName(from),
...extra,
...Fields.useTaskDefinition({ projectCode, from, readonly, data, model }),
Fields.useRunFlag(),
Fields.useDescription(),
Fields.useTaskPriority(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,24 +48,10 @@ export function useEmr({
timeoutNotifyStrategy: ['WARN']
} as INodeData)

let extra: IJsonItem[] = []
if (from === 1) {
extra = [
Fields.useTaskType(model, readonly),
Fields.useProcessName({
model,
projectCode,
isCreate: !data?.id,
from,
processName: data?.processName
})
]
}

return {
json: [
Fields.useName(from),
...extra,
...Fields.useTaskDefinition({ projectCode, from, readonly, data, model }),
Fields.useRunFlag(),
Fields.useDescription(),
Fields.useTaskPriority(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,24 +56,10 @@ export function useFlinkStream({
timeoutNotifyStrategy: ['WARN']
})

let extra: IJsonItem[] = []
if (from === 1) {
extra = [
Fields.useTaskType(model, readonly),
Fields.useProcessName({
model,
projectCode,
isCreate: !data?.id,
from,
processName: data?.processName
})
]
}

return {
json: [
Fields.useName(from),
...extra,
...Fields.useTaskDefinition({ projectCode, from, readonly, data, model }),
Fields.useRunFlag(),
Fields.useDescription(),
Fields.useTaskPriority(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,24 +56,10 @@ export function useFlink({
timeoutNotifyStrategy: ['WARN']
})

let extra: IJsonItem[] = []
if (from === 1) {
extra = [
Fields.useTaskType(model, readonly),
Fields.useProcessName({
model,
projectCode,
isCreate: !data?.id,
from,
processName: data?.processName
})
]
}

return {
json: [
Fields.useName(from),
...extra,
...Fields.useTaskDefinition({ projectCode, from, readonly, data, model }),
Fields.useRunFlag(),
Fields.useDescription(),
Fields.useTaskPriority(),
Expand Down
Loading