Show Download diff links in closed MRs

Download MR diffs links were only available for open MRs,
however it may still be useful for closed MRs.
This commit is contained in:
Fatih Acet 2019-03-29 16:02:55 +01:00
parent 645303c7e7
commit 4e5fc1949f
No known key found for this signature in database
GPG Key ID: E994FE39E29B7E11
3 changed files with 43 additions and 42 deletions

View File

@ -109,29 +109,31 @@ export default {
></div>
</div>
<div v-if="mr.isOpen" class="branch-actions d-flex">
<a
v-if="!mr.sourceBranchRemoved"
v-tooltip
:href="webIdePath"
:title="ideButtonTitle"
:class="{ disabled: !mr.canPushToSourceBranch }"
class="btn btn-default js-web-ide d-none d-md-inline-block append-right-8"
data-placement="bottom"
tabindex="0"
role="button"
>
{{ s__('mrWidget|Open in Web IDE') }}
</a>
<button
:disabled="mr.sourceBranchRemoved"
data-target="#modal_merge_info"
data-toggle="modal"
class="btn btn-default js-check-out-branch append-right-default"
type="button"
>
{{ s__('mrWidget|Check out branch') }}
</button>
<div class="branch-actions d-flex">
<template v-if="mr.isOpen">
<a
v-if="!mr.sourceBranchRemoved"
v-tooltip
:href="webIdePath"
:title="ideButtonTitle"
:class="{ disabled: !mr.canPushToSourceBranch }"
class="btn btn-default js-web-ide d-none d-md-inline-block append-right-8"
data-placement="bottom"
tabindex="0"
role="button"
>
{{ s__('mrWidget|Open in Web IDE') }}
</a>
<button
:disabled="mr.sourceBranchRemoved"
data-target="#modal_merge_info"
data-toggle="modal"
class="btn btn-default js-check-out-branch append-right-default"
type="button"
>
{{ s__('mrWidget|Check out branch') }}
</button>
</template>
<span class="dropdown">
<button
type="button"

View File

@ -0,0 +1,5 @@
---
title: Show download diff links for closed MRs
merge_request: 26772
author:
type: changed

View File

@ -15,6 +15,16 @@ describe('MRWidgetHeader', () => {
gon.relative_url_root = '';
});
const expectDownloadDropdownItems = () => {
const downloadEmailPatchesEl = vm.$el.querySelector('.js-download-email-patches');
const downloadPlainDiffEl = vm.$el.querySelector('.js-download-plain-diff');
expect(downloadEmailPatchesEl.textContent.trim()).toEqual('Email patches');
expect(downloadEmailPatchesEl.getAttribute('href')).toEqual('/mr/email-patches');
expect(downloadPlainDiffEl.textContent.trim()).toEqual('Plain diff');
expect(downloadPlainDiffEl.getAttribute('href')).toEqual('/mr/plainDiffPath');
};
describe('computed', () => {
describe('shouldShowCommitsBehindText', () => {
it('return true when there are divergedCommitsCount', () => {
@ -207,21 +217,7 @@ describe('MRWidgetHeader', () => {
});
it('renders download dropdown with links', () => {
expect(vm.$el.querySelector('.js-download-email-patches').textContent.trim()).toEqual(
'Email patches',
);
expect(vm.$el.querySelector('.js-download-email-patches').getAttribute('href')).toEqual(
'/mr/email-patches',
);
expect(vm.$el.querySelector('.js-download-plain-diff').textContent.trim()).toEqual(
'Plain diff',
);
expect(vm.$el.querySelector('.js-download-plain-diff').getAttribute('href')).toEqual(
'/mr/plainDiffPath',
);
expectDownloadDropdownItems();
});
});
@ -250,10 +246,8 @@ describe('MRWidgetHeader', () => {
expect(button).toEqual(null);
});
it('does not render download dropdown with links', () => {
expect(vm.$el.querySelector('.js-download-email-patches')).toEqual(null);
expect(vm.$el.querySelector('.js-download-plain-diff')).toEqual(null);
it('renders download dropdown with links', () => {
expectDownloadDropdownItems();
});
});