From d06f7fd8c1dff863a97fd850789ecfb6dde1e77b Mon Sep 17 00:00:00 2001 From: Thomas Randolph Date: Mon, 13 Feb 2023 19:51:19 -0700 Subject: [PATCH 1/3] Return a diff for path endpoint in the initial diffs page payload --- app/helpers/merge_requests_helper.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/helpers/merge_requests_helper.rb b/app/helpers/merge_requests_helper.rb index ec395baef9e1cd..590659be0cb2c6 100644 --- a/app/helpers/merge_requests_helper.rb +++ b/app/helpers/merge_requests_helper.rb @@ -185,6 +185,7 @@ def diffs_tab_pane_data(project, merge_request, params) endpoint_metadata: @endpoint_metadata_url, endpoint_batch: diffs_batch_project_json_merge_request_path(project, merge_request, 'json', params), endpoint_coverage: @coverage_path, + endpoint_diff_for_path: diff_for_path_namespace_project_merge_request_path(format: 'json', id: merge_request.iid, namespace_id: project.namespace.path, project_id: project.path), help_page_path: help_page_path('user/project/merge_requests/reviews/suggestions.md'), current_user_data: @current_user_data, update_current_user_path: @update_current_user_path, -- GitLab From fdc8cdd356d7fb8c81b6f7c88d383e02f434346e Mon Sep 17 00:00:00 2001 From: Thomas Randolph Date: Mon, 13 Feb 2023 19:53:21 -0700 Subject: [PATCH 2/3] Ingest the Diff For Path endpoint into the Diffs app --- app/assets/javascripts/diffs/components/app.vue | 5 +++++ app/assets/javascripts/diffs/index.js | 2 ++ app/assets/javascripts/diffs/store/actions.js | 2 ++ app/assets/javascripts/diffs/store/modules/diff_state.js | 1 + app/assets/javascripts/diffs/store/mutations.js | 2 ++ 5 files changed, 12 insertions(+) diff --git a/app/assets/javascripts/diffs/components/app.vue b/app/assets/javascripts/diffs/components/app.vue index 35d1a564178f81..c1d4f6ff089559 100644 --- a/app/assets/javascripts/diffs/components/app.vue +++ b/app/assets/javascripts/diffs/components/app.vue @@ -95,6 +95,10 @@ export default { type: String, required: true, }, + endpointDiffForPath: { + type: String, + required: true, + }, endpointCoverage: { type: String, required: false, @@ -321,6 +325,7 @@ export default { endpoint: this.endpoint, endpointMetadata: this.endpointMetadata, endpointBatch: this.endpointBatch, + endpointDiffForPath: this.endpointDiffForPath, endpointCoverage: this.endpointCoverage, endpointUpdateUser: this.endpointUpdateUser, projectPath: this.projectPath, diff --git a/app/assets/javascripts/diffs/index.js b/app/assets/javascripts/diffs/index.js index 7da5ef54b80d62..f6865056b05e65 100644 --- a/app/assets/javascripts/diffs/index.js +++ b/app/assets/javascripts/diffs/index.js @@ -25,6 +25,7 @@ export default function initDiffsApp(store = notesStore) { endpoint: dataset.endpoint, endpointMetadata: dataset.endpointMetadata || '', endpointBatch: dataset.endpointBatch || '', + endpointDiffForPath: dataset.endpointDiffForPath || '', endpointCoverage: dataset.endpointCoverage || '', endpointCodequality: dataset.endpointCodequality || '', endpointUpdateUser: dataset.updateCurrentUserPath, @@ -86,6 +87,7 @@ export default function initDiffsApp(store = notesStore) { endpoint: this.endpoint, endpointMetadata: this.endpointMetadata, endpointBatch: this.endpointBatch, + endpointDiffForPath: this.endpointDiffForPath, endpointCoverage: this.endpointCoverage, endpointCodequality: this.endpointCodequality, endpointUpdateUser: this.endpointUpdateUser, diff --git a/app/assets/javascripts/diffs/store/actions.js b/app/assets/javascripts/diffs/store/actions.js index 9f90de9abde40c..16c7a3456169fc 100644 --- a/app/assets/javascripts/diffs/store/actions.js +++ b/app/assets/javascripts/diffs/store/actions.js @@ -68,6 +68,7 @@ export const setBaseConfig = ({ commit }, options) => { endpoint, endpointMetadata, endpointBatch, + endpointDiffForPath, endpointCoverage, endpointUpdateUser, projectPath, @@ -81,6 +82,7 @@ export const setBaseConfig = ({ commit }, options) => { endpoint, endpointMetadata, endpointBatch, + endpointDiffForPath, endpointCoverage, endpointUpdateUser, projectPath, diff --git a/app/assets/javascripts/diffs/store/modules/diff_state.js b/app/assets/javascripts/diffs/store/modules/diff_state.js index 329db1fe2cf1ee..593c28f20ecc4c 100644 --- a/app/assets/javascripts/diffs/store/modules/diff_state.js +++ b/app/assets/javascripts/diffs/store/modules/diff_state.js @@ -16,6 +16,7 @@ export default () => ({ removedLines: null, endpoint: '', endpointUpdateUser: '', + endpointDiffForPath: '', basePath: '', commit: null, startVersion: null, // Null unless a target diff is selected for comparison that is not the "base" diff diff --git a/app/assets/javascripts/diffs/store/mutations.js b/app/assets/javascripts/diffs/store/mutations.js index d2b798245fc078..04f08e869552af 100644 --- a/app/assets/javascripts/diffs/store/mutations.js +++ b/app/assets/javascripts/diffs/store/mutations.js @@ -33,6 +33,7 @@ export default { endpoint, endpointMetadata, endpointBatch, + endpointDiffForPath, endpointCoverage, endpointUpdateUser, projectPath, @@ -46,6 +47,7 @@ export default { endpoint, endpointMetadata, endpointBatch, + endpointDiffForPath, endpointCoverage, endpointUpdateUser, projectPath, -- GitLab From bc8ec547592156ddd3c195b6b090b5e9433ee550 Mon Sep 17 00:00:00 2001 From: Thomas Randolph Date: Mon, 20 Feb 2023 15:38:52 -0700 Subject: [PATCH 3/3] Add required endpoint prop to test suite setup --- ee/spec/frontend/diffs/components/app_spec.js | 1 + spec/frontend/diffs/components/app_spec.js | 1 + spec/frontend/diffs/store/actions_spec.js | 4 ++++ 3 files changed, 6 insertions(+) diff --git a/ee/spec/frontend/diffs/components/app_spec.js b/ee/spec/frontend/diffs/components/app_spec.js index 8407242455520b..6d7910245ffcc8 100644 --- a/ee/spec/frontend/diffs/components/app_spec.js +++ b/ee/spec/frontend/diffs/components/app_spec.js @@ -31,6 +31,7 @@ describe('diffs/components/app', () => { endpoint: TEST_ENDPOINT, endpointMetadata: `${TEST_HOST}/diff/endpointMetadata`, endpointBatch: `${TEST_HOST}/diff/endpointBatch`, + endpointDiffForPath: TEST_ENDPOINT, endpointCoverage: `${TEST_HOST}/diff/endpointCoverage`, endpointCodequality: `${TEST_HOST}/diff/endpointCodequality`, projectPath: 'namespace/project', diff --git a/spec/frontend/diffs/components/app_spec.js b/spec/frontend/diffs/components/app_spec.js index 513e67ea247857..ccc892c69ecbf0 100644 --- a/spec/frontend/diffs/components/app_spec.js +++ b/spec/frontend/diffs/components/app_spec.js @@ -59,6 +59,7 @@ describe('diffs/components/app', () => { endpoint: TEST_ENDPOINT, endpointMetadata: `${TEST_HOST}/diff/endpointMetadata`, endpointBatch: `${TEST_HOST}/diff/endpointBatch`, + endpointDiffForPath: TEST_ENDPOINT, endpointCoverage: `${TEST_HOST}/diff/endpointCoverage`, endpointCodequality: '', projectPath: 'namespace/project', diff --git a/spec/frontend/diffs/store/actions_spec.js b/spec/frontend/diffs/store/actions_spec.js index 78765204322d9f..d92a0f4b8ae7da 100644 --- a/spec/frontend/diffs/store/actions_spec.js +++ b/spec/frontend/diffs/store/actions_spec.js @@ -69,6 +69,7 @@ describe('DiffsStoreActions', () => { const endpoint = '/diffs/set/endpoint'; const endpointMetadata = '/diffs/set/endpoint/metadata'; const endpointBatch = '/diffs/set/endpoint/batch'; + const endpointDiffForPath = '/diffs/set/endpoint/path'; const endpointCoverage = '/diffs/set/coverage_reports'; const projectPath = '/root/project'; const dismissEndpoint = '/-/user_callouts'; @@ -83,6 +84,7 @@ describe('DiffsStoreActions', () => { { endpoint, endpointBatch, + endpointDiffForPath, endpointMetadata, endpointCoverage, projectPath, @@ -93,6 +95,7 @@ describe('DiffsStoreActions', () => { { endpoint: '', endpointBatch: '', + endpointDiffForPath: '', endpointMetadata: '', endpointCoverage: '', projectPath: '', @@ -106,6 +109,7 @@ describe('DiffsStoreActions', () => { endpoint, endpointMetadata, endpointBatch, + endpointDiffForPath, endpointCoverage, projectPath, dismissEndpoint, -- GitLab