Commit 06c4b0c5 authored by Mike Greiling's avatar Mike Greiling

Merge branch 'jdb/display-base-label-versions-dropdown' into 'master'

Display "base" label in versions drop down

See merge request gitlab-org/gitlab!25834
parents 715c3a94 dcd45807
<script> <script>
import Icon from '~/vue_shared/components/icon.vue'; import Icon from '~/vue_shared/components/icon.vue';
import { n__, __, sprintf } from '~/locale'; import { n__, __, sprintf } from '~/locale';
import { getParameterByName, parseBoolean } from '~/lib/utils/common_utils';
import TimeAgo from '~/vue_shared/components/time_ago_tooltip.vue'; import TimeAgo from '~/vue_shared/components/time_ago_tooltip.vue';
export default { export default {
...@@ -94,6 +95,9 @@ export default { ...@@ -94,6 +95,9 @@ export default {
} }
return version.versionIndex === -1; return version.versionIndex === -1;
}, },
isHead() {
return parseBoolean(getParameterByName('diff_head'));
},
isLatest(version) { isLatest(version) {
return ( return (
this.mergeRequestVersion && version.version_index === this.targetVersions[0].version_index this.mergeRequestVersion && version.version_index === this.targetVersions[0].version_index
...@@ -121,7 +125,8 @@ export default { ...@@ -121,7 +125,8 @@ export default {
<div> <div>
<strong> <strong>
{{ versionName(version) }} {{ versionName(version) }}
<template v-if="isBase(version)">{{ <template v-if="isHead()">{{ s__('DiffsCompareBaseBranch|(HEAD)') }}</template>
<template v-else-if="isBase(version)">{{
s__('DiffsCompareBaseBranch|(base)') s__('DiffsCompareBaseBranch|(base)')
}}</template> }}</template>
</strong> </strong>
......
---
title: Display base label in versions drop down
merge_request: 25834
author:
type: added
...@@ -6700,6 +6700,9 @@ msgstr "" ...@@ -6700,6 +6700,9 @@ msgstr ""
msgid "Difference between start date and now" msgid "Difference between start date and now"
msgstr "" msgstr ""
msgid "DiffsCompareBaseBranch|(HEAD)"
msgstr ""
msgid "DiffsCompareBaseBranch|(base)" msgid "DiffsCompareBaseBranch|(base)"
msgstr "" msgstr ""
......
...@@ -2,6 +2,7 @@ import { shallowMount, createLocalVue } from '@vue/test-utils'; ...@@ -2,6 +2,7 @@ import { shallowMount, createLocalVue } from '@vue/test-utils';
import CompareVersionsDropdown from '~/diffs/components/compare_versions_dropdown.vue'; import CompareVersionsDropdown from '~/diffs/components/compare_versions_dropdown.vue';
import diffsMockData from '../mock_data/merge_request_diffs'; import diffsMockData from '../mock_data/merge_request_diffs';
import TimeAgo from '~/vue_shared/components/time_ago_tooltip.vue'; import TimeAgo from '~/vue_shared/components/time_ago_tooltip.vue';
import { TEST_HOST } from 'helpers/test_constants';
const localVue = createLocalVue(); const localVue = createLocalVue();
const targetBranch = { branchName: 'tmp-wine-dev', versionIndex: -1 }; const targetBranch = { branchName: 'tmp-wine-dev', versionIndex: -1 };
...@@ -109,6 +110,24 @@ describe('CompareVersionsDropdown', () => { ...@@ -109,6 +110,24 @@ describe('CompareVersionsDropdown', () => {
expect(findLastLink().attributes('href')).toEqual(baseVersionPath); expect(findLastLink().attributes('href')).toEqual(baseVersionPath);
expect(findLastLink().text()).toContain('(base)'); expect(findLastLink().text()).toContain('(base)');
expect(findLastLink().text()).not.toContain('(HEAD)');
});
it('should render a correct head version link', () => {
Object.defineProperty(window, 'location', {
writable: true,
value: { href: `${TEST_HOST}?diff_head=true` },
});
createComponent({
baseVersionPath,
otherVersions: diffsMockData.slice(1),
targetBranch,
});
expect(findLastLink().attributes('href')).toEqual(baseVersionPath);
expect(findLastLink().text()).not.toContain('(base)');
expect(findLastLink().text()).toContain('(HEAD)');
}); });
it('should not render commits count if no showCommitsCount is passed', () => { it('should not render commits count if no showCommitsCount is passed', () => {
......
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