Commit 7407dfdc authored by Natalia Tepluhina's avatar Natalia Tepluhina Committed by Douwe Maan

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

parent eec16ee2
......@@ -54,6 +54,9 @@ export default {
showDropdowns() {
return !this.commit && this.mergeRequestDiffs.length;
},
baseVersionPath() {
return this.mergeRequestDiff.base_version_path;
},
},
methods: {
...mapActions('diffs', [
......@@ -95,6 +98,7 @@ export default {
and
<compare-versions-dropdown
:other-versions="comparableDiffs"
:base-version-path="baseVersionPath"
:start-version="startVersion"
:target-branch="targetBranch"
class="mr-version-compare-dropdown"
......
......@@ -34,14 +34,13 @@ export default {
required: false,
default: false,
},
baseVersionPath: {
type: String,
required: false,
default: null,
},
},
computed: {
baseVersion() {
return {
name: 'hii',
versionIndex: -1,
};
},
targetVersions() {
if (this.mergeRequestVersion) {
return this.otherVersions;
......@@ -62,6 +61,9 @@ export default {
);
},
href(version) {
if (this.isBase(version)) {
return this.baseVersionPath;
}
if (this.showCommitCount) {
return version.version_path;
}
......
......@@ -24,6 +24,14 @@ class MergeRequestDiffEntity < Grape::Entity
short_sha(merge_request_diff.head_commit_sha)
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|
start_sha = options[:start_sha]
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
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', () => {
});
});
describe('baseVersionPath', () => {
it('should be set correctly from mergeRequestDiff', () => {
expect(vm.baseVersionPath).toEqual(vm.mergeRequestDiff.base_version_path);
});
});
describe('isWhitespaceVisible', () => {
const originalHref = window.location.href;
......
export default [
{
versionIndex: 4,
createdAt: '2018-10-23T11:49:16.611Z',
commitsCount: 4,
base_version_path: '/gnuwget/wget2/merge_requests/6/diffs?diff_id=37',
version_index: 4,
created_at: '2018-10-23T11:49:16.611Z',
commits_count: 4,
latest: true,
shortCommitSha: 'de7a8f7f',
versionPath: '/gnuwget/wget2/merge_requests/6/diffs?diff_id=37',
comparePath:
short_commit_sha: 'de7a8f7f',
version_path: '/gnuwget/wget2/merge_requests/6/diffs?diff_id=37',
compare_path:
'/gnuwget/wget2/merge_requests/6/diffs?diff_id=37&start_sha=de7a8f7f20c3ea2e0bef3ba01cfd41c21f6b4995',
},
{
versionIndex: 3,
createdAt: '2018-10-23T11:46:40.617Z',
commitsCount: 3,
base_version_path: '/gnuwget/wget2/merge_requests/6/diffs?diff_id=36',
version_index: 3,
created_at: '2018-10-23T11:46:40.617Z',
commits_count: 3,
latest: false,
shortCommitSha: 'e78fc18f',
versionPath: '/gnuwget/wget2/merge_requests/6/diffs?diff_id=36',
comparePath:
short_commit_sha: 'e78fc18f',
version_path: '/gnuwget/wget2/merge_requests/6/diffs?diff_id=36',
compare_path:
'/gnuwget/wget2/merge_requests/6/diffs?diff_id=37&start_sha=e78fc18fa37acb2185c59ca94d4a964464feb50e',
},
{
versionIndex: 2,
createdAt: '2018-10-04T09:57:39.648Z',
commitsCount: 2,
base_version_path: '/gnuwget/wget2/merge_requests/6/diffs?diff_id=35',
version_index: 2,
created_at: '2018-10-04T09:57:39.648Z',
commits_count: 2,
latest: false,
shortCommitSha: '48da7e7e',
versionPath: '/gnuwget/wget2/merge_requests/6/diffs?diff_id=35',
comparePath:
short_commit_sha: '48da7e7e',
version_path: '/gnuwget/wget2/merge_requests/6/diffs?diff_id=35',
compare_path:
'/gnuwget/wget2/merge_requests/6/diffs?diff_id=37&start_sha=48da7e7e9a99d41c852578bd9cb541ca4d864b3e',
},
{
versionIndex: 1,
createdAt: '2018-09-25T20:30:39.493Z',
commitsCount: 1,
base_version_path: '/gnuwget/wget2/merge_requests/6/diffs?diff_id=20',
version_index: 1,
created_at: '2018-09-25T20:30:39.493Z',
commits_count: 1,
latest: false,
shortCommitSha: '47bac2ed',
versionPath: '/gnuwget/wget2/merge_requests/6/diffs?diff_id=20',
comparePath:
short_commit_sha: '47bac2ed',
version_path: '/gnuwget/wget2/merge_requests/6/diffs?diff_id=20',
compare_path:
'/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