Commit 92fb6061 authored by Phil Hughes's avatar Phil Hughes

Use simple if statement for setting baseVersion

parent 90d15e76
...@@ -16,8 +16,13 @@ export const diffCompareDropdownTargetVersions = (state, getters) => { ...@@ -16,8 +16,13 @@ export const diffCompareDropdownTargetVersions = (state, getters) => {
const diffHead = parseBoolean(diffHeadParam) || (!diffHeadParam && defaultMergeRefForDiffs); 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;
let baseVersion = null;
const baseVersion = { if (
!defaultMergeRefForDiffs ||
(defaultMergeRefForDiffs && !state.mergeRequestDiff.head_version_path)
) {
baseVersion = {
versionName: state.targetBranchName, versionName: state.targetBranchName,
version_index: DIFF_COMPARE_BASE_VERSION_INDEX, version_index: DIFF_COMPARE_BASE_VERSION_INDEX,
href: state.mergeRequestDiff.base_version_path, href: state.mergeRequestDiff.base_version_path,
...@@ -25,6 +30,7 @@ export const diffCompareDropdownTargetVersions = (state, getters) => { ...@@ -25,6 +30,7 @@ export const diffCompareDropdownTargetVersions = (state, getters) => {
selected: selected:
isBaseSelected || (defaultMergeRefForDiffs && !state.mergeRequestDiff.head_version_path), isBaseSelected || (defaultMergeRefForDiffs && !state.mergeRequestDiff.head_version_path),
}; };
}
const headVersion = { const headVersion = {
versionName: state.targetBranchName, versionName: state.targetBranchName,
...@@ -45,8 +51,6 @@ export const diffCompareDropdownTargetVersions = (state, getters) => { ...@@ -45,8 +51,6 @@ export const diffCompareDropdownTargetVersions = (state, getters) => {
return [ return [
...state.mergeRequestDiffs.slice(1).map(formatVersion), ...state.mergeRequestDiffs.slice(1).map(formatVersion),
(!defaultMergeRefForDiffs ||
(defaultMergeRefForDiffs && !state.mergeRequestDiff.head_version_path)) &&
baseVersion, baseVersion,
state.mergeRequestDiff.head_version_path && headVersion, state.mergeRequestDiff.head_version_path && headVersion,
].filter(a => a); ].filter(a => a);
......
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