Commit ece24655 authored by Phil Hughes's avatar Phil Hughes Committed by Gary Holtz

Default diff version to HEAD

parent 8ba09fa1
...@@ -11,7 +11,9 @@ export const diffCompareDropdownTargetVersions = (state, getters) => { ...@@ -11,7 +11,9 @@ export const diffCompareDropdownTargetVersions = (state, getters) => {
// startVersion only exists if the user has selected a version other // startVersion only exists if the user has selected a version other
// than "base" so if startVersion is null then base must be selected // than "base" so if startVersion is null then base must be selected
const diffHead = parseBoolean(getParameterByName('diff_head')); const defaultMergeRefForDiffs = window.gon?.features?.defaultMergeRefForDiffs;
const diffHeadParam = getParameterByName('diff_head');
const diffHead = parseBoolean(diffHeadParam) || (!diffHeadParam && defaultMergeRefForDiffs);
const isBaseSelected = !state.startVersion && !diffHead; const isBaseSelected = !state.startVersion && !diffHead;
const isHeadSelected = !state.startVersion && diffHead; const isHeadSelected = !state.startVersion && diffHead;
...@@ -40,7 +42,11 @@ export const diffCompareDropdownTargetVersions = (state, getters) => { ...@@ -40,7 +42,11 @@ export const diffCompareDropdownTargetVersions = (state, getters) => {
}; };
}; };
return [...state.mergeRequestDiffs.slice(1).map(formatVersion), baseVersion, headVersion]; return [
...state.mergeRequestDiffs.slice(1).map(formatVersion),
defaultMergeRefForDiffs && baseVersion,
headVersion,
].filter(a => a);
}; };
export const diffCompareDropdownSourceVersions = (state, getters) => { export const diffCompareDropdownSourceVersions = (state, getters) => {
......
...@@ -41,6 +41,7 @@ class Projects::MergeRequestsController < Projects::MergeRequests::ApplicationCo ...@@ -41,6 +41,7 @@ class Projects::MergeRequestsController < Projects::MergeRequests::ApplicationCo
push_frontend_feature_flag(:merge_request_widget_graphql, @project) push_frontend_feature_flag(:merge_request_widget_graphql, @project)
push_frontend_feature_flag(:unified_diff_lines, @project) push_frontend_feature_flag(:unified_diff_lines, @project)
push_frontend_feature_flag(:highlight_current_diff_row, @project) push_frontend_feature_flag(:highlight_current_diff_row, @project)
push_frontend_feature_flag(:default_merge_ref_for_diffs, @project)
end end
before_action do before_action do
...@@ -451,6 +452,10 @@ class Projects::MergeRequestsController < Projects::MergeRequests::ApplicationCo ...@@ -451,6 +452,10 @@ class Projects::MergeRequestsController < Projects::MergeRequests::ApplicationCo
params = request.query_parameters params = request.query_parameters
params[:view] = cookies[:diff_view] if params[:view].blank? && cookies[:diff_view].present? params[:view] = cookies[:diff_view] if params[:view].blank? && cookies[:diff_view].present?
if Feature.enabled?(:default_merge_ref_for_diffs, @project)
params = params.merge(diff_head: true)
end
diffs_metadata_project_json_merge_request_path(project, merge_request, 'json', params) diffs_metadata_project_json_merge_request_path(project, merge_request, 'json', params)
end end
end end
......
...@@ -31,11 +31,7 @@ class MergeRequestDiffEntity < Grape::Entity ...@@ -31,11 +31,7 @@ class MergeRequestDiffEntity < Grape::Entity
next unless project next unless project
if Feature.enabled?(:default_merge_ref_for_diffs) merge_request_version_path(project, merge_request, merge_request_diff)
diffs_project_merge_request_path(project, merge_request, diff_head: true)
else
merge_request_version_path(project, merge_request, merge_request_diff)
end
end end
expose :head_version_path do |merge_request_diff| expose :head_version_path do |merge_request_diff|
......
...@@ -70,10 +70,13 @@ ...@@ -70,10 +70,13 @@
= render 'projects/commit/pipelines_list', disable_initialization: true, endpoint: pipelines_project_merge_request_path(@project, @merge_request) = render 'projects/commit/pipelines_list', disable_initialization: true, endpoint: pipelines_project_merge_request_path(@project, @merge_request)
- if mr_action === "diffs" - if mr_action === "diffs"
- add_page_startup_api_call @endpoint_metadata_url - add_page_startup_api_call @endpoint_metadata_url
- params = request.query_parameters
- if Feature.enabled?(:default_merge_ref_for_diffs, @project)
- params = params.merge(diff_head: true)
= render "projects/merge_requests/tabs/pane", name: "diffs", id: "js-diffs-app", class: "diffs", data: { "is-locked": @merge_request.discussion_locked?, = 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: diffs_project_merge_request_path(@project, @merge_request, 'json', params,
endpoint_metadata: @endpoint_metadata_url, endpoint_metadata: @endpoint_metadata_url,
endpoint_batch: diffs_batch_project_json_merge_request_path(@project, @merge_request, 'json', request.query_parameters), endpoint_batch: diffs_batch_project_json_merge_request_path(@project, @merge_request, 'json', params,
endpoint_coverage: @coverage_path, endpoint_coverage: @coverage_path,
help_page_path: suggest_changes_help_path, help_page_path: suggest_changes_help_path,
current_user_data: @current_user_data, current_user_data: @current_user_data,
......
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