mirror of
https://github.com/n8n-io/n8n.git
synced 2025-01-11 21:07:28 -08:00
fix(editor): Respect tag querystring filter when listing workflows (#11029)
Some checks are pending
Test Master / install-and-build (push) Waiting to run
Test Master / Unit tests (18.x) (push) Blocked by required conditions
Test Master / Unit tests (20.x) (push) Blocked by required conditions
Test Master / Unit tests (22.4) (push) Blocked by required conditions
Test Master / Lint (push) Blocked by required conditions
Test Master / Notify Slack on failure (push) Blocked by required conditions
Benchmark Docker Image CI / build (push) Waiting to run
Some checks are pending
Test Master / install-and-build (push) Waiting to run
Test Master / Unit tests (18.x) (push) Blocked by required conditions
Test Master / Unit tests (20.x) (push) Blocked by required conditions
Test Master / Unit tests (22.4) (push) Blocked by required conditions
Test Master / Lint (push) Blocked by required conditions
Test Master / Notify Slack on failure (push) Blocked by required conditions
Benchmark Docker Image CI / build (push) Waiting to run
This commit is contained in:
parent
948edd1a04
commit
59c5ff6135
|
@ -73,4 +73,28 @@ describe('Workflows', () => {
|
|||
|
||||
WorkflowsPage.getters.newWorkflowButtonCard().should('be.visible');
|
||||
});
|
||||
|
||||
it('should respect tag querystring filter when listing workflows', () => {
|
||||
WorkflowsPage.getters.newWorkflowButtonCard().click();
|
||||
|
||||
cy.createFixtureWorkflow('Test_workflow_2.json', getUniqueWorkflowName('My New Workflow'));
|
||||
|
||||
cy.visit(WorkflowsPage.url);
|
||||
|
||||
WorkflowsPage.getters.createWorkflowButton().click();
|
||||
|
||||
cy.createFixtureWorkflow('Test_workflow_1.json', 'Empty State Card Workflow');
|
||||
|
||||
cy.visit(WorkflowsPage.url);
|
||||
|
||||
WorkflowsPage.getters.workflowFilterButton().click();
|
||||
|
||||
WorkflowsPage.getters.workflowTagsDropdown().click();
|
||||
|
||||
WorkflowsPage.getters.workflowTagItem('some-tag-1').click();
|
||||
|
||||
cy.reload();
|
||||
|
||||
WorkflowsPage.getters.workflowCards().should('have.length', 1);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -22,6 +22,7 @@ describe('WorkflowsView', () => {
|
|||
let projectsStore: ReturnType<typeof useProjectsStore>;
|
||||
|
||||
const routerReplaceMock = vi.fn();
|
||||
const routerPushMock = vi.fn();
|
||||
|
||||
const renderComponent = createComponentRenderer(WorkflowsView, {
|
||||
global: {
|
||||
|
@ -32,6 +33,7 @@ describe('WorkflowsView', () => {
|
|||
},
|
||||
$router: {
|
||||
replace: routerReplaceMock,
|
||||
push: routerPushMock,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
|
@ -26,6 +26,8 @@ interface Filters {
|
|||
tags: string[];
|
||||
}
|
||||
|
||||
type QueryFilters = Partial<Filters>;
|
||||
|
||||
const StatusFilter = {
|
||||
ACTIVE: true,
|
||||
DEACTIVATED: false,
|
||||
|
@ -152,6 +154,9 @@ const WorkflowsView = defineComponent({
|
|||
},
|
||||
async mounted() {
|
||||
this.documentTitle.set(this.$locale.baseText('workflows.heading'));
|
||||
|
||||
await this.tagsStore.fetchAll();
|
||||
|
||||
await this.setFiltersFromQueryString();
|
||||
|
||||
void this.usersStore.showPersonalizationSurvey();
|
||||
|
@ -263,10 +268,20 @@ const WorkflowsView = defineComponent({
|
|||
isValidProjectId(projectId: string) {
|
||||
return this.projectsStore.availableProjects.some((project) => project.id === projectId);
|
||||
},
|
||||
async removeInvalidQueryFiltersFromUrl(filtersToApply: QueryFilters) {
|
||||
await this.$router.push({
|
||||
query: {
|
||||
...(filtersToApply.tags && { tags: filtersToApply.tags?.join(',') }),
|
||||
...(filtersToApply.status && { status: filtersToApply.status?.toString() }),
|
||||
...(filtersToApply.search && { search: filtersToApply.search }),
|
||||
...(filtersToApply.homeProject && { homeProject: filtersToApply.homeProject }),
|
||||
},
|
||||
});
|
||||
},
|
||||
async setFiltersFromQueryString() {
|
||||
const { tags, status, search, homeProject } = this.$route.query;
|
||||
|
||||
const filtersToApply: { [key: string]: string | string[] | boolean } = {};
|
||||
const filtersToApply: QueryFilters = {};
|
||||
|
||||
if (homeProject && typeof homeProject === 'string') {
|
||||
await this.projectsStore.getAvailableProjects();
|
||||
|
@ -295,6 +310,8 @@ const WorkflowsView = defineComponent({
|
|||
filtersToApply.status = status === 'true';
|
||||
}
|
||||
|
||||
await this.removeInvalidQueryFiltersFromUrl(filtersToApply);
|
||||
|
||||
if (Object.keys(filtersToApply).length) {
|
||||
this.filters = {
|
||||
...this.filters,
|
||||
|
|
Loading…
Reference in a new issue