Browse Source

[Improvement-11386][UI] Concise the logic available for task action buttons (#11419)

* Remove button instead of disable button

* Correct the value of releaseState in the compare statement

Co-authored-by: sheldonliu <sheldonliu>
3.1.0-release
Sheldon 2 years ago committed by GitHub
parent
commit
376d0a09ae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 54
      dolphinscheduler-ui/src/views/projects/workflow/components/dag/dag-context-menu.tsx
  2. 25
      dolphinscheduler-ui/src/views/projects/workflow/components/dag/index.tsx

54
dolphinscheduler-ui/src/views/projects/workflow/components/dag/dag-context-menu.tsx

@ -26,15 +26,11 @@ import { IWorkflowTaskInstance } from './types'
import { NButton } from 'naive-ui' import { NButton } from 'naive-ui'
const props = { const props = {
startButtonDisplay: { startDisplay: {
type: Boolean as PropType<boolean>,
default: true
},
startReadonly: {
type: Boolean as PropType<boolean>, type: Boolean as PropType<boolean>,
default: false default: false
}, },
menuReadonly: { menuDisplay: {
type: Boolean as PropType<boolean>, type: Boolean as PropType<boolean>,
default: false default: false
}, },
@ -131,36 +127,36 @@ export default defineComponent({
class={styles['dag-context-menu']} class={styles['dag-context-menu']}
style={{ left: `${this.left}px`, top: `${this.top}px` }} style={{ left: `${this.left}px`, top: `${this.top}px` }}
> >
{this.startButtonDisplay && ( {this.startDisplay && (
<NButton <NButton
class={`${styles['menu-item']}`} class={`${styles['menu-item']}`}
disabled={this.startReadonly}
onClick={this.startRunning} onClick={this.startRunning}
> >
{t('project.node.start')} {t('project.node.start')}
</NButton>) </NButton>)
} }
<NButton {this.menuDisplay && (
class={`${styles['menu-item']}`} <>
disabled={this.menuReadonly} <NButton
onClick={this.handleEdit} class={`${styles['menu-item']}`}
> onClick={this.handleEdit}
{t('project.node.edit')} >
</NButton> {t('project.node.edit')}
<NButton </NButton>
class={`${styles['menu-item']}`} <NButton
disabled={this.menuReadonly} class={`${styles['menu-item']}`}
onClick={this.handleCopy} onClick={this.handleCopy}
> >
{t('project.node.copy')} {t('project.node.copy')}
</NButton> </NButton>
<NButton <NButton
class={`${styles['menu-item']}`} class={`${styles['menu-item']}`}
disabled={this.menuReadonly} onClick={this.handleDelete}
onClick={this.handleDelete} >
> {t('project.node.delete')}
{t('project.node.delete')} </NButton>
</NButton> </>
)}
{this.taskInstance && ( {this.taskInstance && (
<NButton <NButton
class={`${styles['menu-item']}`} class={`${styles['menu-item']}`}

25
dolphinscheduler-ui/src/views/projects/workflow/components/dag/index.tsx

@ -119,11 +119,11 @@ export default defineComponent({
}) })
// start button in the dag node menu // start button in the dag node menu
const startReadonly = computed(() => { const startDisplay = computed(() => {
if (props.definition) { if (props.definition) {
return ( return (
route.name === 'workflow-definition-detail' && route.name === 'workflow-definition-detail' &&
props.definition!.processDefinition.releaseState === 'NOT_RELEASE' props.definition!.processDefinition.releaseState === 'ONLINE'
) )
} else { } else {
return false return false
@ -131,17 +131,17 @@ export default defineComponent({
}) })
// other button in the dag node menu // other button in the dag node menu
const menuReadonly = computed(() => { const menuDisplay = computed(() => {
if (props.instance) { if (props.instance) {
return ( return (
props.instance.state !== 'WAITING_THREAD' && props.instance.state === 'WAITING_THREAD' ||
props.instance.state !== 'SUCCESS' && props.instance.state === 'SUCCESS' ||
props.instance.state !== 'PAUSE' && props.instance.state === 'PAUSE' ||
props.instance.state !== 'FAILURE' && props.instance.state === 'FAILURE' ||
props.instance.state !== 'STOP' props.instance.state === 'STOP'
) )
} else if (props.definition) { } else if (props.definition) {
return props.definition!.processDefinition.releaseState === 'ONLINE' return props.definition!.processDefinition.releaseState === 'OFFLINE'
} else { } else {
return false return false
} }
@ -337,7 +337,7 @@ export default defineComponent({
/> />
{!!props.definition && ( {!!props.definition && (
<VersionModal <VersionModal
isInstance={props.instance ? true : false} isInstance={!!props.instance}
v-model:row={props.definition.processDefinition} v-model:row={props.definition.processDefinition}
v-model:show={versionModalShow.value} v-model:show={versionModalShow.value}
onUpdateList={refreshDetail} onUpdateList={refreshDetail}
@ -362,9 +362,8 @@ export default defineComponent({
onCancel={taskCancel} onCancel={taskCancel}
/> />
<ContextMenuItem <ContextMenuItem
startButtonDisplay={!props.instance} startDisplay={startDisplay.value}
startReadonly={startReadonly.value} menuDisplay={menuDisplay.value}
menuReadonly={menuReadonly.value}
taskInstance={taskInstance.value} taskInstance={taskInstance.value}
cell={nodeVariables.menuCell as Cell} cell={nodeVariables.menuCell as Cell}
visible={nodeVariables.menuVisible} visible={nodeVariables.menuVisible}

Loading…
Cancel
Save