2022-04-11 06:12:13 -07:00
|
|
|
<template>
|
|
|
|
<n8n-button
|
2022-05-23 08:56:15 -07:00
|
|
|
:loading="nodeRunning"
|
|
|
|
:disabled="workflowRunning && !nodeRunning"
|
|
|
|
:label="buttonLabel"
|
|
|
|
:type="type"
|
|
|
|
:size="size"
|
|
|
|
:transparentBackground="transparent"
|
2022-04-11 06:12:13 -07:00
|
|
|
@click="onClick"
|
|
|
|
/>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import { INodeUi } from '@/Interface';
|
|
|
|
import { INodeTypeDescription } from 'n8n-workflow';
|
|
|
|
import mixins from 'vue-typed-mixins';
|
|
|
|
import { workflowRun } from './mixins/workflowRun';
|
|
|
|
|
|
|
|
export default mixins(
|
|
|
|
workflowRun,
|
|
|
|
).extend({
|
|
|
|
props: {
|
|
|
|
nodeName: {
|
|
|
|
type: String,
|
|
|
|
},
|
2022-05-23 08:56:15 -07:00
|
|
|
label: {
|
|
|
|
type: String,
|
|
|
|
},
|
|
|
|
type: {
|
|
|
|
type: String,
|
|
|
|
},
|
|
|
|
size: {
|
|
|
|
type: String,
|
|
|
|
},
|
|
|
|
transparent: {
|
|
|
|
type: Boolean,
|
|
|
|
default: false,
|
|
|
|
},
|
2022-04-11 06:12:13 -07:00
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
node (): INodeUi {
|
|
|
|
return this.$store.getters.getNodeByName(this.nodeName);
|
|
|
|
},
|
|
|
|
nodeType (): INodeTypeDescription | null {
|
|
|
|
if (this.node) {
|
|
|
|
return this.$store.getters.nodeType(this.node.type, this.node.typeVersion);
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
},
|
2022-05-23 08:56:15 -07:00
|
|
|
nodeRunning (): boolean {
|
|
|
|
const triggeredNode = this.$store.getters.executedNode;
|
|
|
|
const executingNode = this.$store.getters.executingNode;
|
|
|
|
return executingNode === this.node.name || triggeredNode === this.node.name;
|
|
|
|
},
|
2022-04-11 06:12:13 -07:00
|
|
|
workflowRunning (): boolean {
|
|
|
|
return this.$store.getters.isActionActive('workflowRunning');
|
|
|
|
},
|
|
|
|
isTriggerNode (): boolean {
|
|
|
|
return !!(this.nodeType && this.nodeType.group.includes('trigger'));
|
|
|
|
},
|
|
|
|
isPollingTypeNode (): boolean {
|
|
|
|
return !!(this.nodeType && this.nodeType.polling);
|
|
|
|
},
|
|
|
|
isScheduleTrigger (): boolean {
|
|
|
|
return !!(this.nodeType && this.nodeType.group.includes('schedule'));
|
|
|
|
},
|
2022-05-23 08:56:15 -07:00
|
|
|
buttonLabel(): string {
|
|
|
|
if (this.label) {
|
|
|
|
return this.label;
|
|
|
|
}
|
2022-04-11 06:12:13 -07:00
|
|
|
if (this.isPollingTypeNode) {
|
|
|
|
return this.$locale.baseText('ndv.execute.fetchEvent');
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.isTriggerNode && !this.isScheduleTrigger) {
|
|
|
|
return this.$locale.baseText('ndv.execute.listenForEvent');
|
|
|
|
}
|
|
|
|
|
|
|
|
return this.$locale.baseText('ndv.execute.executeNode');
|
|
|
|
},
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
onClick() {
|
|
|
|
this.runWorkflow(this.nodeName, 'RunData.ExecuteNodeButton');
|
|
|
|
this.$emit('execute');
|
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
|
|
|
</script>
|