Browse Source

[Fix] [UI Next][V1.0.0-Alpha] Enviroment name display error in cron manage (#8957)

* fix timing modal env name -1 bug

* add param type
3.0.0/version-upgrade
Devosend 2 years ago committed by GitHub
parent
commit
2b63de0297
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 51
      dolphinscheduler-ui-next/src/views/projects/workflow/definition/components/timing-modal.tsx
  2. 41
      dolphinscheduler-ui-next/src/views/projects/workflow/definition/components/types.ts
  3. 4
      dolphinscheduler-ui-next/src/views/projects/workflow/definition/components/use-form.ts
  4. 17
      dolphinscheduler-ui-next/src/views/projects/workflow/definition/components/use-modal.ts

51
dolphinscheduler-ui-next/src/views/projects/workflow/definition/components/timing-modal.tsx

@ -22,7 +22,8 @@ import {
h, h,
onMounted, onMounted,
ref, ref,
watch watch,
computed
} from 'vue' } from 'vue'
import { useI18n } from 'vue-i18n' import { useI18n } from 'vue-i18n'
import Modal from '@/components/modal' import Modal from '@/components/modal'
@ -83,6 +84,12 @@ export default defineComponent({
getPreviewSchedule getPreviewSchedule
} = useModal(timingState, ctx) } = useModal(timingState, ctx)
const environmentOptions = computed(() =>
variables.environmentList.filter((item: any) =>
item.workerGroups?.includes(timingState.timingForm.workerGroup)
)
)
const hideModal = () => { const hideModal = () => {
ctx.emit('update:show') ctx.emit('update:show')
} }
@ -95,7 +102,7 @@ export default defineComponent({
} }
} }
const generalWarningTypeListOptions = () => [ const warningTypeOptions = [
{ {
value: 'NONE', value: 'NONE',
label: t('project.workflow.none_send') label: t('project.workflow.none_send')
@ -114,7 +121,7 @@ export default defineComponent({
} }
] ]
const generalPriorityList = () => [ const priorityOptions = [
{ {
value: 'HIGHEST', value: 'HIGHEST',
label: 'HIGHEST', label: 'HIGHEST',
@ -178,6 +185,24 @@ export default defineComponent({
getPreviewSchedule() getPreviewSchedule()
} }
const initEnvironment = () => {
timingState.timingForm.environmentCode = null
variables.environmentList.forEach((item) => {
if (props.row.environmentCode === item.value) {
timingState.timingForm.environmentCode = item.value
}
})
}
const initWarningGroup = () => {
timingState.timingForm.warningGroupId = null
variables.alertGroups.forEach((item) => {
if (props.row.warningGroupId === item.value) {
timingState.timingForm.warningGroupId = item.value
}
})
}
onMounted(() => { onMounted(() => {
getWorkerGroups() getWorkerGroups()
getAlertGroups() getAlertGroups()
@ -199,9 +224,9 @@ export default defineComponent({
timingState.timingForm.warningType = props.row.warningType timingState.timingForm.warningType = props.row.warningType
timingState.timingForm.processInstancePriority = timingState.timingForm.processInstancePriority =
props.row.processInstancePriority props.row.processInstancePriority
timingState.timingForm.warningGroupId = props.row.warningGroupId
timingState.timingForm.workerGroup = props.row.workerGroup timingState.timingForm.workerGroup = props.row.workerGroup
timingState.timingForm.environmentCode = props.row.environmentCode initWarningGroup()
initEnvironment()
} }
) )
@ -209,10 +234,11 @@ export default defineComponent({
t, t,
crontabRef, crontabRef,
parallelismRef, parallelismRef,
priorityOptions,
warningTypeOptions,
environmentOptions,
hideModal, hideModal,
handleTiming, handleTiming,
generalWarningTypeListOptions,
generalPriorityList,
timezoneOptions, timezoneOptions,
renderLabel, renderLabel,
updateWorkerGroup, updateWorkerGroup,
@ -225,9 +251,6 @@ export default defineComponent({
render() { render() {
const { t } = this const { t } = this
if (Number(this.timingForm.warningGroupId) === 0) {
this.timingForm.warningGroupId = ''
}
return ( return (
<Modal <Modal
@ -318,7 +341,7 @@ export default defineComponent({
path='warningType' path='warningType'
> >
<NSelect <NSelect
options={this.generalWarningTypeListOptions()} options={this.warningTypeOptions}
v-model:value={this.timingForm.warningType} v-model:value={this.timingForm.warningType}
/> />
</NFormItem> </NFormItem>
@ -327,7 +350,7 @@ export default defineComponent({
path='processInstancePriority' path='processInstancePriority'
> >
<NSelect <NSelect
options={this.generalPriorityList()} options={this.priorityOptions}
renderLabel={this.renderLabel} renderLabel={this.renderLabel}
v-model:value={this.timingForm.processInstancePriority} v-model:value={this.timingForm.processInstancePriority}
/> />
@ -347,9 +370,7 @@ export default defineComponent({
path='environmentCode' path='environmentCode'
> >
<NSelect <NSelect
options={this.environmentList.filter((item: any) => options={this.environmentOptions}
item.workerGroups?.includes(this.timingForm.workerGroup)
)}
v-model:value={this.timingForm.environmentCode} v-model:value={this.timingForm.environmentCode}
clearable clearable
/> />

41
dolphinscheduler-ui-next/src/views/projects/workflow/definition/components/types.ts

@ -0,0 +1,41 @@
/*
* 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.
*/
export interface IEnvironmentOption {
label: string
value: string
workerGroups: Array<string>
}
export interface IOption {
label: string
value: number
}
export interface IParam {
prop: string
value: string
}
export interface ITimingState {
projectCode: number
workerGroups: Array<IOption>
alertGroups: Array<IOption>
environmentList: Array<IEnvironmentOption>
startParamsList: Array<IParam>
schedulePreviewList: Array<string>
}

4
dolphinscheduler-ui-next/src/views/projects/workflow/definition/components/use-form.ts

@ -82,9 +82,9 @@ export const useForm = () => {
failureStrategy: 'CONTINUE', failureStrategy: 'CONTINUE',
warningType: 'NONE', warningType: 'NONE',
processInstancePriority: 'MEDIUM', processInstancePriority: 'MEDIUM',
warningGroupId: '', warningGroupId: null as null | number,
workerGroup: 'default', workerGroup: 'default',
environmentCode: null environmentCode: null as null | string
}, },
saving: false saving: false
}) })

17
dolphinscheduler-ui-next/src/views/projects/workflow/definition/components/use-modal.ts

@ -36,6 +36,8 @@ import {
previewSchedule previewSchedule
} from '@/service/modules/schedules' } from '@/service/modules/schedules'
import { parseTime } from '@/utils/common' import { parseTime } from '@/utils/common'
import { EnvironmentItem } from '@/service/modules/environment/types'
import { ITimingState } from './types'
export function useModal( export function useModal(
state: any, state: any,
@ -45,12 +47,12 @@ export function useModal(
const router: Router = useRouter() const router: Router = useRouter()
const route = useRoute() const route = useRoute()
const variables = reactive({ const variables = reactive<ITimingState>({
projectCode: Number(route.params.projectCode), projectCode: Number(route.params.projectCode),
workerGroups: [], workerGroups: [],
alertGroups: [], alertGroups: [],
environmentList: [], environmentList: [],
startParamsList: [] as Array<{ prop: string; value: string }>, startParamsList: [],
schedulePreviewList: [] schedulePreviewList: []
}) })
@ -197,10 +199,9 @@ export function useModal(
failureStrategy: state.timingForm.failureStrategy, failureStrategy: state.timingForm.failureStrategy,
warningType: state.timingForm.warningType, warningType: state.timingForm.warningType,
processInstancePriority: state.timingForm.processInstancePriority, processInstancePriority: state.timingForm.processInstancePriority,
warningGroupId: warningGroupId: state.timingForm.warningGroupId
state.timingForm.warningGroupId === '' ? state.timingForm.warningGroupId
? 0 : 0,
: state.timingForm.warningGroupId,
workerGroup: state.timingForm.workerGroup, workerGroup: state.timingForm.workerGroup,
environmentCode: state.timingForm.environmentCode environmentCode: state.timingForm.environmentCode
} }
@ -217,8 +218,8 @@ export function useModal(
} }
const getEnvironmentList = () => { const getEnvironmentList = () => {
queryAllEnvironmentList().then((res: any) => { queryAllEnvironmentList().then((res: Array<EnvironmentItem>) => {
variables.environmentList = res.map((item: any) => ({ variables.environmentList = res.map((item) => ({
label: item.name, label: item.name,
value: item.code, value: item.code,
workerGroups: item.workerGroups workerGroups: item.workerGroups

Loading…
Cancel
Save