Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(editor): Show workflow data in header when execution page is hard reloaded #9529

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions cypress/e2e/20-workflow-executions.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = () => {
Expand All @@ -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');
};
16 changes: 15 additions & 1 deletion cypress/fixtures/Test_workflow_4_executions_view.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
]
}
3 changes: 0 additions & 3 deletions packages/editor-ui/src/components/MainHeader/MainHeader.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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;
},
Expand Down
23 changes: 15 additions & 8 deletions packages/editor-ui/src/views/WorkflowExecutionsView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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();
Expand Down Expand Up @@ -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) {
Expand All @@ -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) {
Expand Down
Loading