Commit 2c00c401 authored by André Luís's avatar André Luís Committed by Igor Drozdov

Add diffs_metadata.json to startupjs on Changes tab

Basically we want to avoid adding the diffs_metadata.json
request to startup.js if the page is not rendering the
Changes tab right away.
parent f724bf57
......@@ -151,10 +151,12 @@ export const fetchDiffFilesBatch = ({ commit, state, dispatch }) => {
// eslint-disable-next-line promise/catch-or-return,promise/no-nesting
import('~/code_navigation').then(m =>
m.default({
blobs: state.diffFiles.map(f => ({
path: f.new_path,
codeNavigationPath: f.code_navigation_path,
})),
blobs: state.diffFiles
.filter(f => f.code_navigation_path)
.map(f => ({
path: f.new_path,
codeNavigationPath: f.code_navigation_path,
})),
definitionPathPrefix: state.definitionPathPrefix,
}),
);
......
......@@ -86,6 +86,7 @@ class Projects::MergeRequestsController < Projects::MergeRequests::ApplicationCo
@show_whitespace_default = current_user.nil? || current_user.show_whitespace_in_diffs
@file_by_file_default = Feature.enabled?(:view_diffs_file_by_file) && current_user&.view_diffs_file_by_file
@coverage_path = coverage_reports_project_merge_request_path(@project, @merge_request, format: :json) if @merge_request.has_coverage_reports?
@endpoint_metadata_url = endpoint_metadata_url(@project, @merge_request)
set_pipeline_variables
......@@ -435,6 +436,13 @@ class Projects::MergeRequestsController < Projects::MergeRequests::ApplicationCo
def authorize_read_actual_head_pipeline!
return render_404 unless can?(current_user, :read_build, merge_request.actual_head_pipeline)
end
def endpoint_metadata_url(project, merge_request)
params = request.query_parameters
params[:view] = cookies[:diff_view] if params[:view].blank? && cookies[:diff_view].present?
diffs_metadata_project_json_merge_request_path(project, merge_request, 'json', params)
end
end
Projects::MergeRequestsController.prepend_if_ee('EE::Projects::MergeRequestsController')
......@@ -7,8 +7,9 @@
- page_card_attributes @merge_request.card_attributes
- suggest_changes_help_path = help_page_path('user/discussions/index.md', anchor: 'suggest-changes')
- number_of_pipelines = @pipelines.size
- mr_action = j(params[:tab].presence || 'show')
.merge-request{ data: { mr_action: j(params[:tab].presence || 'show'), url: merge_request_path(@merge_request, format: :json), project_path: project_path(@merge_request.project), lock_version: @merge_request.lock_version } }
.merge-request{ data: { mr_action: mr_action, url: merge_request_path(@merge_request, format: :json), project_path: project_path(@merge_request.project), lock_version: @merge_request.lock_version } }
= render "projects/merge_requests/mr_title"
.merge-request-details.issuable-details{ data: { id: @merge_request.project.id } }
......@@ -76,9 +77,11 @@
= render "projects/merge_requests/tabs/pane", name: "pipelines", id: "pipelines", class: "pipelines" do
- if number_of_pipelines.nonzero?
= render 'projects/commit/pipelines_list', disable_initialization: true, endpoint: pipelines_project_merge_request_path(@project, @merge_request)
- if mr_action === "diffs"
- add_page_startup_api_call @endpoint_metadata_url
= render "projects/merge_requests/tabs/pane", name: "diffs", id: "js-diffs-app", class: "diffs", data: { "is-locked": @merge_request.discussion_locked?,
endpoint: diffs_project_merge_request_path(@project, @merge_request, 'json', request.query_parameters),
endpoint_metadata: diffs_metadata_project_json_merge_request_path(@project, @merge_request, 'json', request.query_parameters),
endpoint_metadata: @endpoint_metadata_url,
endpoint_batch: diffs_batch_project_json_merge_request_path(@project, @merge_request, 'json', request.query_parameters),
endpoint_coverage: @coverage_path,
help_page_path: suggest_changes_help_path,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment