Commit 454942da authored by Douwe Maan's avatar Douwe Maan

Merge branch '52275-fix-master-to-be-hyperlink' into 'master'

Resolve "In Merge Request diff screen, master is not a hyperlink"

Closes #52275

See merge request gitlab-org/gitlab-ce!23874
parents eec16ee2 7407dfdc
...@@ -54,6 +54,9 @@ export default { ...@@ -54,6 +54,9 @@ export default {
showDropdowns() { showDropdowns() {
return !this.commit && this.mergeRequestDiffs.length; return !this.commit && this.mergeRequestDiffs.length;
}, },
baseVersionPath() {
return this.mergeRequestDiff.base_version_path;
},
}, },
methods: { methods: {
...mapActions('diffs', [ ...mapActions('diffs', [
...@@ -95,6 +98,7 @@ export default { ...@@ -95,6 +98,7 @@ export default {
and and
<compare-versions-dropdown <compare-versions-dropdown
:other-versions="comparableDiffs" :other-versions="comparableDiffs"
:base-version-path="baseVersionPath"
:start-version="startVersion" :start-version="startVersion"
:target-branch="targetBranch" :target-branch="targetBranch"
class="mr-version-compare-dropdown" class="mr-version-compare-dropdown"
......
...@@ -34,14 +34,13 @@ export default { ...@@ -34,14 +34,13 @@ export default {
required: false, required: false,
default: false, default: false,
}, },
baseVersionPath: {
type: String,
required: false,
default: null,
},
}, },
computed: { computed: {
baseVersion() {
return {
name: 'hii',
versionIndex: -1,
};
},
targetVersions() { targetVersions() {
if (this.mergeRequestVersion) { if (this.mergeRequestVersion) {
return this.otherVersions; return this.otherVersions;
...@@ -62,6 +61,9 @@ export default { ...@@ -62,6 +61,9 @@ export default {
); );
}, },
href(version) { href(version) {
if (this.isBase(version)) {
return this.baseVersionPath;
}
if (this.showCommitCount) { if (this.showCommitCount) {
return version.version_path; return version.version_path;
} }
......
...@@ -24,6 +24,14 @@ class MergeRequestDiffEntity < Grape::Entity ...@@ -24,6 +24,14 @@ class MergeRequestDiffEntity < Grape::Entity
short_sha(merge_request_diff.head_commit_sha) short_sha(merge_request_diff.head_commit_sha)
end end
expose :base_version_path do |merge_request_diff|
project = merge_request.target_project
next unless project
merge_request_version_path(project, merge_request, merge_request_diff)
end
expose :version_path do |merge_request_diff| expose :version_path do |merge_request_diff|
start_sha = options[:start_sha] start_sha = options[:start_sha]
project = merge_request.target_project project = merge_request.target_project
......
---
title: Resolve In Merge Request diff screen, master is not a hyperlink
merge_request: 23874
author:
type: fixed
// TODO: https://gitlab.com/gitlab-org/gitlab-ce/issues/48034 // TODO: https://gitlab.com/gitlab-org/gitlab-ce/issues/48034
import { shallowMount, createLocalVue } from '@vue/test-utils';
import CompareVersionsDropdown from '~/diffs/components/compare_versions_dropdown.vue';
import diffsMockData from '../mock_data/merge_request_diffs';
describe('CompareVersionsDropdown', () => {
let wrapper;
const targetBranch = { branchName: 'tmp-wine-dev', versionIndex: -1 };
const factory = (options = {}) => {
const localVue = createLocalVue();
wrapper = shallowMount(CompareVersionsDropdown, { localVue, ...options });
};
afterEach(() => {
wrapper.destroy();
});
it('should render a correct base version link', () => {
factory({
propsData: {
baseVersionPath: '/gnuwget/wget2/merge_requests/6/diffs?diff_id=37',
otherVersions: diffsMockData.slice(1),
targetBranch,
},
});
const links = wrapper.findAll('a');
const lastLink = links.wrappers[links.length - 1];
expect(lastLink.attributes('href')).toEqual(wrapper.props('baseVersionPath'));
});
});
...@@ -100,6 +100,12 @@ describe('CompareVersions', () => { ...@@ -100,6 +100,12 @@ describe('CompareVersions', () => {
}); });
}); });
describe('baseVersionPath', () => {
it('should be set correctly from mergeRequestDiff', () => {
expect(vm.baseVersionPath).toEqual(vm.mergeRequestDiff.base_version_path);
});
});
describe('isWhitespaceVisible', () => { describe('isWhitespaceVisible', () => {
const originalHref = window.location.href; const originalHref = window.location.href;
......
export default [ export default [
{ {
versionIndex: 4, base_version_path: '/gnuwget/wget2/merge_requests/6/diffs?diff_id=37',
createdAt: '2018-10-23T11:49:16.611Z', version_index: 4,
commitsCount: 4, created_at: '2018-10-23T11:49:16.611Z',
commits_count: 4,
latest: true, latest: true,
shortCommitSha: 'de7a8f7f', short_commit_sha: 'de7a8f7f',
versionPath: '/gnuwget/wget2/merge_requests/6/diffs?diff_id=37', version_path: '/gnuwget/wget2/merge_requests/6/diffs?diff_id=37',
comparePath: compare_path:
'/gnuwget/wget2/merge_requests/6/diffs?diff_id=37&start_sha=de7a8f7f20c3ea2e0bef3ba01cfd41c21f6b4995', '/gnuwget/wget2/merge_requests/6/diffs?diff_id=37&start_sha=de7a8f7f20c3ea2e0bef3ba01cfd41c21f6b4995',
}, },
{ {
versionIndex: 3, base_version_path: '/gnuwget/wget2/merge_requests/6/diffs?diff_id=36',
createdAt: '2018-10-23T11:46:40.617Z', version_index: 3,
commitsCount: 3, created_at: '2018-10-23T11:46:40.617Z',
commits_count: 3,
latest: false, latest: false,
shortCommitSha: 'e78fc18f', short_commit_sha: 'e78fc18f',
versionPath: '/gnuwget/wget2/merge_requests/6/diffs?diff_id=36', version_path: '/gnuwget/wget2/merge_requests/6/diffs?diff_id=36',
comparePath: compare_path:
'/gnuwget/wget2/merge_requests/6/diffs?diff_id=37&start_sha=e78fc18fa37acb2185c59ca94d4a964464feb50e', '/gnuwget/wget2/merge_requests/6/diffs?diff_id=37&start_sha=e78fc18fa37acb2185c59ca94d4a964464feb50e',
}, },
{ {
versionIndex: 2, base_version_path: '/gnuwget/wget2/merge_requests/6/diffs?diff_id=35',
createdAt: '2018-10-04T09:57:39.648Z', version_index: 2,
commitsCount: 2, created_at: '2018-10-04T09:57:39.648Z',
commits_count: 2,
latest: false, latest: false,
shortCommitSha: '48da7e7e', short_commit_sha: '48da7e7e',
versionPath: '/gnuwget/wget2/merge_requests/6/diffs?diff_id=35', version_path: '/gnuwget/wget2/merge_requests/6/diffs?diff_id=35',
comparePath: compare_path:
'/gnuwget/wget2/merge_requests/6/diffs?diff_id=37&start_sha=48da7e7e9a99d41c852578bd9cb541ca4d864b3e', '/gnuwget/wget2/merge_requests/6/diffs?diff_id=37&start_sha=48da7e7e9a99d41c852578bd9cb541ca4d864b3e',
}, },
{ {
versionIndex: 1, base_version_path: '/gnuwget/wget2/merge_requests/6/diffs?diff_id=20',
createdAt: '2018-09-25T20:30:39.493Z', version_index: 1,
commitsCount: 1, created_at: '2018-09-25T20:30:39.493Z',
commits_count: 1,
latest: false, latest: false,
shortCommitSha: '47bac2ed', short_commit_sha: '47bac2ed',
versionPath: '/gnuwget/wget2/merge_requests/6/diffs?diff_id=20', version_path: '/gnuwget/wget2/merge_requests/6/diffs?diff_id=20',
comparePath: compare_path:
'/gnuwget/wget2/merge_requests/6/diffs?diff_id=37&start_sha=47bac2ed972c5bee344c1cea159a22cd7f711dc0', '/gnuwget/wget2/merge_requests/6/diffs?diff_id=37&start_sha=47bac2ed972c5bee344c1cea159a22cd7f711dc0',
}, },
]; ];
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