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

This commit is contained in:
Ricardo Espinoza 2024-10-02 15:11:41 -04:00 committed by GitHub
parent 948edd1a04
commit 59c5ff6135
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 44 additions and 1 deletions

View file

@ -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);
});
});

View file

@ -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,
},
},
},

View file

@ -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,