From e68a3fd6ce7c710c398171b3deb8d8eb565e23ba Mon Sep 17 00:00:00 2001 From: Csaba Tuncsik Date: Thu, 30 May 2024 16:47:02 +0200 Subject: [PATCH] fix(editor): Show workflow data in header when execution page is hard reloaded (#9529) --- cypress/e2e/20-workflow-executions.cy.ts | 18 +++++++++++++++ .../Test_workflow_4_executions_view.json | 16 ++++++++++++- .../src/components/MainHeader/MainHeader.vue | 3 --- .../src/views/WorkflowExecutionsView.vue | 23 ++++++++++++------- 4 files changed, 48 insertions(+), 12 deletions(-) diff --git a/cypress/e2e/20-workflow-executions.cy.ts b/cypress/e2e/20-workflow-executions.cy.ts index 9940b865d4..3bcea60d67 100644 --- a/cypress/e2e/20-workflow-executions.cy.ts +++ b/cypress/e2e/20-workflow-executions.cy.ts @@ -133,6 +133,17 @@ describe('Current Workflow Executions', () => { executionsTab.getters.executionListItems().first().should('be.visible'); executionsTab.getters.executionListItems().eq(14).should('not.be.visible'); }); + + it('should show workflow data in executions tab after hard reload', () => { + executionsTab.actions.switchToExecutionsTab(); + checkMainHeaderELements(); + + cy.reload(); + checkMainHeaderELements(); + + executionsTab.actions.switchToEditorTab(); + checkMainHeaderELements(); + }); }); const createMockExecutions = () => { @@ -144,3 +155,10 @@ const createMockExecutions = () => { executionsTab.actions.toggleNodeEnabled('Error'); executionsTab.actions.createManualExecutions(4); }; + +const checkMainHeaderELements = () => { + workflowPage.getters.workflowNameInputContainer().should('be.visible'); + workflowPage.getters.workflowTagsContainer().should('be.visible'); + workflowPage.getters.workflowMenu().should('be.visible'); + workflowPage.getters.saveButton().should('be.visible'); +}; diff --git a/cypress/fixtures/Test_workflow_4_executions_view.json b/cypress/fixtures/Test_workflow_4_executions_view.json index a0be9eae35..2af7a1df29 100644 --- a/cypress/fixtures/Test_workflow_4_executions_view.json +++ b/cypress/fixtures/Test_workflow_4_executions_view.json @@ -65,5 +65,19 @@ ] ] } - } + }, + "tags": [ + { + "name": "some-tag-1", + "createdAt": "2022-11-10T13:43:34.001Z", + "updatedAt": "2022-11-10T13:43:34.001Z", + "id": "6" + }, + { + "name": "some-tag-2", + "createdAt": "2022-11-10T13:43:39.778Z", + "updatedAt": "2022-11-10T13:43:39.778Z", + "id": "7" + } + ] } diff --git a/packages/editor-ui/src/components/MainHeader/MainHeader.vue b/packages/editor-ui/src/components/MainHeader/MainHeader.vue index ed7b43715e..ca1b76e389 100644 --- a/packages/editor-ui/src/components/MainHeader/MainHeader.vue +++ b/packages/editor-ui/src/components/MainHeader/MainHeader.vue @@ -80,9 +80,6 @@ export default defineComponent({ workflow(): IWorkflowDb { return this.workflowsStore.workflow; }, - workflowName(): string { - return this.workflowsStore.workflowName; - }, currentWorkflow(): string { return this.$route.params.name || this.workflowsStore.workflowId; }, diff --git a/packages/editor-ui/src/views/WorkflowExecutionsView.vue b/packages/editor-ui/src/views/WorkflowExecutionsView.vue index 460705d9f0..4155d06809 100644 --- a/packages/editor-ui/src/views/WorkflowExecutionsView.vue +++ b/packages/editor-ui/src/views/WorkflowExecutionsView.vue @@ -3,7 +3,7 @@ import { computed, onBeforeUnmount, onMounted, ref, watch } from 'vue'; import WorkflowExecutionsList from '@/components/executions/workflow/WorkflowExecutionsList.vue'; import { useExecutionsStore } from '@/stores/executions.store'; import { useI18n } from '@/composables/useI18n'; -import type { ExecutionFilterType, IWorkflowDb } from '@/Interface'; +import type { ExecutionFilterType, ITag, IWorkflowDb } from '@/Interface'; import { useWorkflowsStore } from '@/stores/workflows.store'; import { useNodeTypesStore } from '@/stores/nodeTypes.store'; import { NO_NETWORK_ERROR_CODE } from '@/utils/apiUtils'; @@ -14,9 +14,11 @@ import type { ExecutionSummary } from 'n8n-workflow'; import { useDebounce } from '@/composables/useDebounce'; import { storeToRefs } from 'pinia'; import { useTelemetry } from '@/composables/useTelemetry'; +import { useTagsStore } from '@/stores/tags.store'; const executionsStore = useExecutionsStore(); const workflowsStore = useWorkflowsStore(); +const tagsStore = useTagsStore(); const nodeTypesStore = useNodeTypesStore(); const i18n = useI18n(); const telemetry = useTelemetry(); @@ -115,13 +117,14 @@ async function initializeRoute() { } async function fetchWorkflow() { - let data: IWorkflowDb | undefined; - try { - // @TODO Retrieve from store if exists - data = await workflowsStore.fetchWorkflow(workflowId.value); - } catch (error) { - toast.showError(error, i18n.baseText('nodeView.showError.openWorkflow.title')); - return; + let data: IWorkflowDb | undefined = workflowsStore.workflowsById[workflowId.value]; + if (!data) { + try { + data = await workflowsStore.fetchWorkflow(workflowId.value); + } catch (error) { + toast.showError(error, i18n.baseText('nodeView.showError.openWorkflow.title')); + return; + } } if (!data) { @@ -132,7 +135,11 @@ async function fetchWorkflow() { ); } + const tags = (data.tags ?? []) as ITag[]; workflow.value = data; + workflowsStore.setWorkflowName({ newName: data.name, setStateDirty: false }); + workflowsStore.setWorkflowTagIds(tags.map(({ id }) => id) ?? []); + tagsStore.upsertTags(tags); } async function onAutoRefreshToggle(value: boolean) {