From c2adaa58cd7957ec7faae0c87d924a40a56d9726 Mon Sep 17 00:00:00 2001 From: Alex Grozav Date: Thu, 11 Jul 2024 16:37:01 +0300 Subject: [PATCH] feat(editor): Add clear execution button to new canvas (no-changelog) (#10010) --- .../CanvasClearExecutionDataButton.spec.ts | 12 +++++++++++ .../CanvasClearExecutionDataButton.vue | 13 ++++++++++++ ...anvasClearExecutionDataButton.spec.ts.snap | 7 +++++++ packages/editor-ui/src/views/NodeView.v2.vue | 20 +++++++++++++++++++ 4 files changed, 52 insertions(+) create mode 100644 packages/editor-ui/src/components/canvas/elements/buttons/CanvasClearExecutionDataButton.spec.ts create mode 100644 packages/editor-ui/src/components/canvas/elements/buttons/CanvasClearExecutionDataButton.vue create mode 100644 packages/editor-ui/src/components/canvas/elements/buttons/__snapshots__/CanvasClearExecutionDataButton.spec.ts.snap diff --git a/packages/editor-ui/src/components/canvas/elements/buttons/CanvasClearExecutionDataButton.spec.ts b/packages/editor-ui/src/components/canvas/elements/buttons/CanvasClearExecutionDataButton.spec.ts new file mode 100644 index 0000000000..8552d9e8b5 --- /dev/null +++ b/packages/editor-ui/src/components/canvas/elements/buttons/CanvasClearExecutionDataButton.spec.ts @@ -0,0 +1,12 @@ +import { createComponentRenderer } from '@/__tests__/render'; +import CanvasClearExecutionDataButton from './CanvasClearExecutionDataButton.vue'; + +const renderComponent = createComponentRenderer(CanvasClearExecutionDataButton); + +describe('CanvasClearExecutionDataButton', () => { + it('should render correctly', () => { + const wrapper = renderComponent(); + + expect(wrapper.html()).toMatchSnapshot(); + }); +}); diff --git a/packages/editor-ui/src/components/canvas/elements/buttons/CanvasClearExecutionDataButton.vue b/packages/editor-ui/src/components/canvas/elements/buttons/CanvasClearExecutionDataButton.vue new file mode 100644 index 0000000000..505d179d4f --- /dev/null +++ b/packages/editor-ui/src/components/canvas/elements/buttons/CanvasClearExecutionDataButton.vue @@ -0,0 +1,13 @@ + + diff --git a/packages/editor-ui/src/components/canvas/elements/buttons/__snapshots__/CanvasClearExecutionDataButton.spec.ts.snap b/packages/editor-ui/src/components/canvas/elements/buttons/__snapshots__/CanvasClearExecutionDataButton.spec.ts.snap new file mode 100644 index 0000000000..fe19da1dbb --- /dev/null +++ b/packages/editor-ui/src/components/canvas/elements/buttons/__snapshots__/CanvasClearExecutionDataButton.spec.ts.snap @@ -0,0 +1,7 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`CanvasClearExecutionDataButton > should render correctly 1`] = ` +"" +`; diff --git a/packages/editor-ui/src/views/NodeView.v2.vue b/packages/editor-ui/src/views/NodeView.v2.vue index 1d29e85442..38eff5243e 100644 --- a/packages/editor-ui/src/views/NodeView.v2.vue +++ b/packages/editor-ui/src/views/NodeView.v2.vue @@ -83,6 +83,7 @@ import { getNodeViewTab } from '@/utils/canvasUtils'; import { parseCanvasConnectionHandleString } from '@/utils/canvasUtilsV2'; import CanvasStopCurrentExecutionButton from '@/components/canvas/elements/buttons/CanvasStopCurrentExecutionButton.vue'; import CanvasStopWaitingForWebhookButton from '@/components/canvas/elements/buttons/CanvasStopWaitingForWebhookButton.vue'; +import CanvasClearExecutionDataButton from '@/components/canvas/elements/buttons/CanvasClearExecutionDataButton.vue'; import { nodeViewEventBus } from '@/event-bus'; const NodeCreation = defineAsyncComponent( @@ -614,6 +615,16 @@ const isStopExecutionButtonVisible = computed( const isStopWaitingForWebhookButtonVisible = computed( () => isWorkflowRunning.value && isExecutionWaitingForWebhook.value, ); +const isClearExecutionButtonVisible = computed( + () => + !isReadOnlyRoute.value && + !isReadOnlyEnvironment.value && + !isWorkflowRunning.value && + !allTriggerNodesDisabled.value && + workflowExecutionData.value, +); + +const workflowExecutionData = computed(() => workflowsStore.workflowExecutionData); async function onRunWorkflow() { trackRunWorkflow(); @@ -672,6 +683,11 @@ async function onStopWaitingForWebhook() { await stopWaitingForWebhook(); } +async function onClearExecutionData() { + workflowsStore.workflowExecutionData = null; + nodeHelpers.updateNodesExecutionIssues(); +} + function onRunWorkflowButtonMouseEnter() { nodeViewEventBus.emit('runWorkflowButton:mouseenter'); } @@ -1083,6 +1099,10 @@ onBeforeUnmount(() => { v-if="isStopWaitingForWebhookButtonVisible" @click="onStopWaitingForWebhook" /> +