Add working version

This commit is contained in:
Charlie Kolb 2024-10-30 13:41:16 +01:00
parent cfac3c92a7
commit 70606c627d
No known key found for this signature in database
3 changed files with 16 additions and 15 deletions

View file

@ -1,6 +1,6 @@
<script setup lang="ts"> <script setup lang="ts">
import KeyboardShortcutTooltip from '@/components/KeyboardShortcutTooltip.vue'; import KeyboardShortcutTooltip from '@/components/KeyboardShortcutTooltip.vue';
import { computed, ref } from 'vue'; import { computed, ref, unref } from 'vue';
import { useI18n } from '@/composables/useI18n'; import { useI18n } from '@/composables/useI18n';
import type { INodeUi } from '@/Interface'; import type { INodeUi } from '@/Interface';
import { N8nActionDropdown } from 'n8n-design-system'; import { N8nActionDropdown } from 'n8n-design-system';
@ -36,7 +36,7 @@ const label = computed(() => {
const actions = computed(() => { const actions = computed(() => {
return props.triggerNodes.map((triggerNode) => { return props.triggerNodes.map((triggerNode) => {
return { return {
id: triggerNode.name, id: triggerNode.id,
label: triggerNode.name, label: triggerNode.name,
disabled: triggerNode.disabled, disabled: triggerNode.disabled,
}; };
@ -44,7 +44,7 @@ const actions = computed(() => {
}); });
const onActionSelect = (item: string) => { const onActionSelect = (item: string) => {
selectedTrigger.value = item; selectedTrigger.value = actions.value.find((x) => x.id === item)?.label;
}; };
</script> </script>
@ -53,9 +53,10 @@ const onActionSelect = (item: string) => {
<div :class="$style.actionWrapper"> <div :class="$style.actionWrapper">
<KeyboardShortcutTooltip :label="label" :shortcut="{ metaKey: true, keys: ['↵'] }"> <KeyboardShortcutTooltip :label="label" :shortcut="{ metaKey: true, keys: ['↵'] }">
<N8nButton <N8nButton
:class="$style.firstButton" :class="{
[$style.firstButton]: triggerNodes.length > 1,
}"
:loading="executing" :loading="executing"
:label="label"
:disabled="disabled" :disabled="disabled"
size="large" size="large"
icon="flask" icon="flask"
@ -64,7 +65,10 @@ const onActionSelect = (item: string) => {
@mouseenter="$emit('mouseenter', $event)" @mouseenter="$emit('mouseenter', $event)"
@mouseleave="$emit('mouseleave', $event)" @mouseleave="$emit('mouseleave', $event)"
@click.stop="$emit('click', $event, selectedTrigger)" @click.stop="$emit('click', $event, selectedTrigger)"
/> >{{
label + (selectedTrigger && triggerNodes.length > 1 ? ` from "${selectedTrigger}"` : '')
}}</N8nButton
>
</KeyboardShortcutTooltip> </KeyboardShortcutTooltip>
<div :class="$style.line"></div> <div :class="$style.line"></div>
<N8nActionDropdown v-if="triggerNodes.length > 1" :items="actions" @select="onActionSelect"> <N8nActionDropdown v-if="triggerNodes.length > 1" :items="actions" @select="onActionSelect">
@ -85,12 +89,12 @@ const onActionSelect = (item: string) => {
.firstButton { .firstButton {
border-right: none; border-right: none;
border-radius: 8px 0 0 8px; border-radius: 4px 0 0 4px; // hardcoded
} }
.lastButton { .lastButton {
border-left: none; border-left: none;
border-radius: 0 8px 8px 0; border-radius: 0 4px 4px 0; // hardcoded
} }
.line { .line {

View file

@ -69,7 +69,6 @@ export function useRunWorkflow(useRunWorkflowOpts: { router: ReturnType<typeof u
uiStore.addActiveAction('workflowRunning'); uiStore.addActiveAction('workflowRunning');
let response: IExecutionPushResponse; let response: IExecutionPushResponse;
try { try {
response = await workflowsStore.runWorkflow(runData); response = await workflowsStore.runWorkflow(runData);
} catch (error) { } catch (error) {
@ -149,16 +148,15 @@ export function useRunWorkflow(useRunWorkflowOpts: { router: ReturnType<typeof u
) { ) {
executedNode = options.destinationNode; executedNode = options.destinationNode;
startNodeNames.push(options.destinationNode); startNodeNames.push(options.destinationNode);
} else if ('triggerNode' in options && 'nodeData' in options) { } else if ('triggerNode' in options) {
startNodeNames.push( startNodeNames.push(
...workflow.getChildNodes(options.triggerNode as string, NodeConnectionType.Main, 1), ...workflow.getChildNodes(options.triggerNode as string, NodeConnectionType.Main, 1),
); );
newRunData = { newRunData = {
[options.triggerNode as string]: [options.nodeData], [options.triggerNode as string]: options.nodeData ? [options.nodeData] : [],
} as IRunData; } as IRunData;
executedNode = options.triggerNode; executedNode = options.triggerNode;
} }
// If the destination node is specified, check if it is a chat node or has a chat parent // If the destination node is specified, check if it is a chat node or has a chat parent
if ( if (
options.destinationNode && options.destinationNode &&
@ -301,7 +299,6 @@ export function useRunWorkflow(useRunWorkflowOpts: { router: ReturnType<typeof u
nodeName: options.destinationNode, nodeName: options.destinationNode,
source: options.source, source: options.source,
}); });
return runWorkflowApiResponse; return runWorkflowApiResponse;
} catch (error) { } catch (error) {
workflowHelpers.setDocumentTitle(workflow.name as string, 'ERROR'); workflowHelpers.setDocumentTitle(workflow.name as string, 'ERROR');

View file

@ -1008,7 +1008,7 @@ const workflowExecutionData = computed(() => workflowsStore.workflowExecutionDat
async function onRunWorkflow(triggerNode?: string) { async function onRunWorkflow(triggerNode?: string) {
trackRunWorkflow(); trackRunWorkflow();
console.log('triggerNode 1', triggerNode);
if (!isExecutionPreview.value && workflowsStore.isWaitingExecution) { if (!isExecutionPreview.value && workflowsStore.isWaitingExecution) {
void runWorkflowResolvePending({ triggerNode }); void runWorkflowResolvePending({ triggerNode });
} else { } else {
@ -1624,7 +1624,7 @@ onBeforeUnmount(() => {
:trigger-nodes="triggerNodes" :trigger-nodes="triggerNodes"
@mouseenter="onRunWorkflowButtonMouseEnter" @mouseenter="onRunWorkflowButtonMouseEnter"
@mouseleave="onRunWorkflowButtonMouseLeave" @mouseleave="onRunWorkflowButtonMouseLeave"
@click="($event, selectedTrigger) => onRunWorkflow(selectedTrigger)" @click="(_e, selectedTrigger) => onRunWorkflow(selectedTrigger)"
/> />
<CanvasChatButton v-if="containsChatTriggerNodes" @click="onOpenChat" /> <CanvasChatButton v-if="containsChatTriggerNodes" @click="onOpenChat" />
<CanvasStopCurrentExecutionButton <CanvasStopCurrentExecutionButton