From 3225ebfda4b9114a4a3bb41ef8908f2416eab939 Mon Sep 17 00:00:00 2001 From: Thomas Randolph Date: Wed, 8 May 2024 21:47:33 -0600 Subject: [PATCH 1/2] Add source branch filter to Vue MR list app --- app/assets/javascripts/issues/list/constants.js | 11 +++++++++++ .../list/components/merge_requests_list_app.vue | 13 ++++++++++++- .../list/queries/get_merge_requests.query.graphql | 2 ++ 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/issues/list/constants.js b/app/assets/javascripts/issues/list/constants.js index a2705932156ba4..972d6e69aa7678 100644 --- a/app/assets/javascripts/issues/list/constants.js +++ b/app/assets/javascripts/issues/list/constants.js @@ -24,6 +24,7 @@ import { TOKEN_TYPE_MY_REACTION, TOKEN_TYPE_ORGANIZATION, TOKEN_TYPE_RELEASE, + TOKEN_TYPE_SOURCE_BRANCH, TOKEN_TYPE_TARGET_BRANCH, TOKEN_TYPE_TYPE, TOKEN_TYPE_WEIGHT, @@ -268,6 +269,16 @@ export const filtersMap = { }, }, }, + [TOKEN_TYPE_SOURCE_BRANCH]: { + [API_PARAM]: { + [NORMAL_FILTER]: 'sourceBranches', + }, + [URL_PARAM]: { + [OPERATOR_IS]: { + [NORMAL_FILTER]: 'source_branches[]', + }, + }, + }, [TOKEN_TYPE_TARGET_BRANCH]: { [API_PARAM]: { [NORMAL_FILTER]: 'targetBranches', diff --git a/app/assets/javascripts/merge_requests/list/components/merge_requests_list_app.vue b/app/assets/javascripts/merge_requests/list/components/merge_requests_list_app.vue index d36dea492bf2e8..6aa299e714127c 100644 --- a/app/assets/javascripts/merge_requests/list/components/merge_requests_list_app.vue +++ b/app/assets/javascripts/merge_requests/list/components/merge_requests_list_app.vue @@ -21,6 +21,8 @@ import { TOKEN_TYPE_DRAFT, TOKEN_TITLE_TARGET_BRANCH, TOKEN_TYPE_TARGET_BRANCH, + TOKEN_TITLE_SOURCE_BRANCH, + TOKEN_TYPE_SOURCE_BRANCH, } from '~/vue_shared/components/filtered_search_bar/constants'; import { convertToApiParams, @@ -202,7 +204,16 @@ export default { operators: OPERATORS_IS, fullPath: this.fullPath, isProject: true, - multiselect: true, + fetchBranches: this.fetchBranches, + }, + { + type: TOKEN_TYPE_SOURCE_BRANCH, + title: TOKEN_TITLE_SOURCE_BRANCH, + icon: 'branch', + token: BranchToken, + operators: OPERATORS_IS, + fullPath: this.fullPath, + isProject: true, fetchBranches: this.fetchBranches, }, ]; diff --git a/app/assets/javascripts/merge_requests/list/queries/get_merge_requests.query.graphql b/app/assets/javascripts/merge_requests/list/queries/get_merge_requests.query.graphql index a97ca144b25e6d..b7811523b0b624 100644 --- a/app/assets/javascripts/merge_requests/list/queries/get_merge_requests.query.graphql +++ b/app/assets/javascripts/merge_requests/list/queries/get_merge_requests.query.graphql @@ -9,6 +9,7 @@ query getMergeRequests( $state: MergeRequestState $authorUsername: String $draft: Boolean + $sourceBranches: [String!] $targetBranches: [String!] $beforeCursor: String $afterCursor: String @@ -22,6 +23,7 @@ query getMergeRequests( state: $state authorUsername: $authorUsername draft: $draft + sourceBranches: $sourceBranches targetBranches: $targetBranches before: $beforeCursor after: $afterCursor -- GitLab From bde3bbad3b54ede43239681f0cf01cec50b43d7a Mon Sep 17 00:00:00 2001 From: Thomas Randolph Date: Wed, 8 May 2024 21:52:56 -0600 Subject: [PATCH 2/2] Test that the source branch filter tokens are correctly rendered --- .../list/components/merge_requests_list_app_spec.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/spec/frontend/merge_requests/list/components/merge_requests_list_app_spec.js b/spec/frontend/merge_requests/list/components/merge_requests_list_app_spec.js index b25b05cc0a1c01..7438508cd1e92f 100644 --- a/spec/frontend/merge_requests/list/components/merge_requests_list_app_spec.js +++ b/spec/frontend/merge_requests/list/components/merge_requests_list_app_spec.js @@ -10,6 +10,7 @@ import { convertToGraphQLId } from '~/graphql_shared/utils'; import { TOKEN_TYPE_AUTHOR, TOKEN_TYPE_DRAFT, + TOKEN_TYPE_SOURCE_BRANCH, TOKEN_TYPE_TARGET_BRANCH, } from '~/vue_shared/components/filtered_search_bar/constants'; import { mergeRequestListTabs } from '~/vue_shared/issuable/list/constants'; @@ -101,13 +102,14 @@ describe('Merge requests list app', () => { { type: TOKEN_TYPE_AUTHOR, preloadedUsers: [] }, { type: TOKEN_TYPE_DRAFT }, { type: TOKEN_TYPE_TARGET_BRANCH }, + { type: TOKEN_TYPE_SOURCE_BRANCH }, ]); }); }); describe('when all tokens are available', () => { beforeEach(async () => { - setWindowLocation('?draft=yes&target_branches[]="branch-a"'); + setWindowLocation('?draft=yes&target_branches[]=branch-a&source_branches[]=branch-b'); window.gon = { current_user_id: mockCurrentUser.id, current_user_fullname: mockCurrentUser.name, @@ -134,6 +136,7 @@ describe('Merge requests list app', () => { { type: TOKEN_TYPE_AUTHOR, preloadedUsers }, { type: TOKEN_TYPE_DRAFT }, { type: TOKEN_TYPE_TARGET_BRANCH }, + { type: TOKEN_TYPE_SOURCE_BRANCH }, ]); }); @@ -141,6 +144,7 @@ describe('Merge requests list app', () => { expect(findIssuableList().props('initialFilterValue')).toMatchObject([ { type: TOKEN_TYPE_DRAFT }, { type: TOKEN_TYPE_TARGET_BRANCH }, + { type: TOKEN_TYPE_SOURCE_BRANCH }, ]); }); }); -- GitLab