diff --git a/app/assets/javascripts/work_items/pages/work_items_list_app.vue b/app/assets/javascripts/work_items/pages/work_items_list_app.vue index 2ca2946930c1b010dac62db19e2d5b7c9a6469ac..93d00a6e54f4b7bcf4fc0b274cde8eb1e02098a6 100644 --- a/app/assets/javascripts/work_items/pages/work_items_list_app.vue +++ b/app/assets/javascripts/work_items/pages/work_items_list_app.vue @@ -139,6 +139,11 @@ export default { required: false, default: () => [], }, + eeSearchTokens: { + type: Array, + required: false, + default: () => [], + }, }, data() { return { @@ -405,6 +410,10 @@ export default { }); } + if (this.eeSearchTokens.length) { + tokens.push(...this.eeSearchTokens); + } + tokens.sort((a, b) => a.title.localeCompare(b.title)); return tokens; diff --git a/lib/api/discussions.rb b/lib/api/discussions.rb index df27eb80d587e70cb499a9ea3f405a78177ed294..ae3be35575395f3a6fe8708a86b21f5ff996de79 100644 --- a/lib/api/discussions.rb +++ b/lib/api/discussions.rb @@ -91,14 +91,14 @@ class Discussions < ::API::Base optional :start, type: Hash do optional :line_code, type: String, desc: 'Start line code for multi-line note' optional :type, type: String, desc: 'Start line type for multi-line note' - optional :old_line, type: String, desc: 'Start old_line line number' - optional :new_line, type: String, desc: 'Start new_line line number' + optional :old_line, type: Integer, desc: 'Start old_line line number' + optional :new_line, type: Integer, desc: 'Start new_line line number' end optional :end, type: Hash do optional :line_code, type: String, desc: 'End line code for multi-line note' optional :type, type: String, desc: 'End line type for multi-line note' - optional :old_line, type: String, desc: 'End old_line line number' - optional :new_line, type: String, desc: 'End new_line line number' + optional :old_line, type: Integer, desc: 'End old_line line number' + optional :new_line, type: Integer, desc: 'End new_line line number' end end end diff --git a/spec/frontend/work_items/list/components/work_items_list_app_spec.js b/spec/frontend/work_items/list/components/work_items_list_app_spec.js index 240a6da0aa713a9b3e3e99ea2fb6708795855b02..713f1c568ba9947f2e2821207d2b887d9e5f9231 100644 --- a/spec/frontend/work_items/list/components/work_items_list_app_spec.js +++ b/spec/frontend/work_items/list/components/work_items_list_app_spec.js @@ -342,6 +342,45 @@ describeSkipVue3(skipReason, () => { }); }); + describe('custom field tokens', () => { + it('combines eeSearchTokens with default search tokens', async () => { + const customToken = { + type: `custom`, + title: 'Custom Field', + token: () => {}, + }; + + mountComponent({ + props: { + eeSearchTokens: [customToken], + }, + }); + + await waitForPromises(); + + const searchTokens = findIssuableList().props('searchTokens'); + + expect(searchTokens).toContainEqual( + expect.objectContaining({ + type: customToken.type, + title: customToken.title, + }), + ); + + // Other tokens are still included + expect(searchTokens).toContainEqual( + expect.objectContaining({ + type: TOKEN_TYPE_ASSIGNEE, + }), + ); + expect(searchTokens).toContainEqual( + expect.objectContaining({ + type: TOKEN_TYPE_LABEL, + }), + ); + }); + }); + describe('events', () => { describe('when "click-tab" event is emitted by IssuableList', () => { beforeEach(async () => { diff --git a/spec/requests/api/discussions_spec.rb b/spec/requests/api/discussions_spec.rb index aebdcebbc5a84022c6a08315d774faa85f6b6ba3..e22f10a0021e74f827a70cbd1336d9a1fc2d10b3 100644 --- a/spec/requests/api/discussions_spec.rb +++ b/spec/requests/api/discussions_spec.rb @@ -116,6 +116,33 @@ it_behaves_like 'diff discussions API', 'projects', 'merge_requests', 'iid' it_behaves_like 'resolvable discussions API', 'projects', 'merge_requests', 'iid' + context "when creating a note for multiple lines" do + it "creates a new diff multiline note" do + line_range = { + "start" => { + "line_code" => Gitlab::Git.diff_line_code(diff_note.position.file_path, 1, 1), + "type" => diff_note.position.type, + "new_line" => 1 + }, + "end" => { + "line_code" => Gitlab::Git.diff_line_code(diff_note.position.file_path, 3, 3), + "type" => diff_note.position.type, + "new_line" => 3 + } + } + + position = diff_note.position.to_h.merge({ line_range: line_range }).except(:ignore_whitespace_change) + + post api("/projects/#{parent.id}/merge_requests/#{noteable['iid']}/discussions", user), + params: { body: 'hi!', position: position } + + expect(response).to have_gitlab_http_status(:created) + expect(json_response['notes'].first['body']).to eq('hi!') + expect(json_response['notes'].first['type']).to eq('DiffNote') + expect(json_response['notes'].first['position']).to eq(position.stringify_keys) + end + end + context "when position_type is file" do it "creates a new diff note" do position = diff_note.position.to_h.merge({ position_type: 'file' }).except(:ignore_whitespace_change)