diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-05-19 18:44:42 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-05-19 18:44:42 +0300 |
commit | 4555e1b21c365ed8303ffb7a3325d773c9b8bf31 (patch) | |
tree | 5423a1c7516cffe36384133ade12572cf709398d /app/assets/javascripts/diffs/store/getters_versions_dropdowns.js | |
parent | e570267f2f6b326480d284e0164a6464ba4081bc (diff) |
Add latest changes from gitlab-org/gitlab@13-12-stable-eev13.12.0-rc42
Diffstat (limited to 'app/assets/javascripts/diffs/store/getters_versions_dropdowns.js')
-rw-r--r-- | app/assets/javascripts/diffs/store/getters_versions_dropdowns.js | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/app/assets/javascripts/diffs/store/getters_versions_dropdowns.js b/app/assets/javascripts/diffs/store/getters_versions_dropdowns.js index 01811e60caa..673ec821b58 100644 --- a/app/assets/javascripts/diffs/store/getters_versions_dropdowns.js +++ b/app/assets/javascripts/diffs/store/getters_versions_dropdowns.js @@ -7,6 +7,9 @@ export const selectedTargetIndex = (state) => export const selectedSourceIndex = (state) => state.mergeRequestDiff.version_index; +export const selectedContextCommitsDiffs = (state) => + state.contextCommitsDiff && state.contextCommitsDiff.showing_context_commits_diff; + export const diffCompareDropdownTargetVersions = (state, getters) => { // startVersion only exists if the user has selected a version other // than "base" so if startVersion is null then base must be selected @@ -58,7 +61,7 @@ export const diffCompareDropdownTargetVersions = (state, getters) => { export const diffCompareDropdownSourceVersions = (state, getters) => { // Appended properties here are to make the compare_dropdown_layout easier to reason about - return state.mergeRequestDiffs.map((v, i) => { + const versions = state.mergeRequestDiffs.map((v, i) => { const isLatestVersion = i === 0; return { @@ -69,7 +72,20 @@ export const diffCompareDropdownSourceVersions = (state, getters) => { versionName: isLatestVersion ? __('latest version') : sprintf(__(`version %{versionIndex}`), { versionIndex: v.version_index }), - selected: v.version_index === getters.selectedSourceIndex, + selected: + v.version_index === getters.selectedSourceIndex && !getters.selectedContextCommitsDiffs, }; }); + + const { contextCommitsDiff } = state; + if (contextCommitsDiff) { + versions.push({ + href: contextCommitsDiff.diffs_path, + commitsText: n__(`%d commit`, `%d commits`, contextCommitsDiff.commits_count), + versionName: __('previously merged commits'), + selected: getters.selectedContextCommitsDiffs, + addDivider: state.mergeRequestDiffs.length > 0, + }); + } + return versions; }; |