Commit 8c47fa08 authored by Jose Ivan Vargas's avatar Jose Ivan Vargas

Merge branch...

Merge branch '229331-migrate-bootstrap-button-to-gitlab-ui-glbutton-in-app-assets-javascripts' into 'master'

Migrate Bootstrap button and dropdowns to GitLab UI in app/assets/javascripts/vue_merge_request_widget/components/mr_widget_header.vue

See merge request gitlab-org/gitlab!40823
parents 3f109c02 6b808fe8
...@@ -2,24 +2,32 @@ ...@@ -2,24 +2,32 @@
/* eslint-disable vue/no-v-html */ /* eslint-disable vue/no-v-html */
import Mousetrap from 'mousetrap'; import Mousetrap from 'mousetrap';
import { escape } from 'lodash'; import { escape } from 'lodash';
import { GlIcon } from '@gitlab/ui'; import {
GlButton,
GlNewDropdown as GlDropdown,
GlNewDropdownHeader as GlDropdownHeader,
GlNewDropdownItem as GlDropdownItem,
GlTooltipDirective,
} from '@gitlab/ui';
import { n__, s__, sprintf } from '~/locale'; import { n__, s__, sprintf } from '~/locale';
import { mergeUrlParams, webIDEUrl } from '~/lib/utils/url_utility'; import { mergeUrlParams, webIDEUrl } from '~/lib/utils/url_utility';
import clipboardButton from '~/vue_shared/components/clipboard_button.vue'; import clipboardButton from '~/vue_shared/components/clipboard_button.vue';
import tooltip from '~/vue_shared/directives/tooltip';
import TooltipOnTruncate from '~/vue_shared/components/tooltip_on_truncate.vue'; import TooltipOnTruncate from '~/vue_shared/components/tooltip_on_truncate.vue';
import MrWidgetIcon from './mr_widget_icon.vue'; import MrWidgetIcon from './mr_widget_icon.vue';
export default { export default {
name: 'MRWidgetHeader', name: 'MRWidgetHeader',
components: { components: {
GlIcon,
clipboardButton, clipboardButton,
TooltipOnTruncate, TooltipOnTruncate,
MrWidgetIcon, MrWidgetIcon,
GlButton,
GlDropdown,
GlDropdownHeader,
GlDropdownItem,
}, },
directives: { directives: {
tooltip, GlTooltip: GlTooltipDirective,
}, },
props: { props: {
mr: { mr: {
...@@ -125,63 +133,59 @@ export default { ...@@ -125,63 +133,59 @@ export default {
<div class="branch-actions d-flex"> <div class="branch-actions d-flex">
<template v-if="mr.isOpen"> <template v-if="mr.isOpen">
<a <span
v-if="!mr.sourceBranchRemoved" v-if="!mr.sourceBranchRemoved"
v-tooltip v-gl-tooltip
:href="webIdePath"
:title="ideButtonTitle" :title="ideButtonTitle"
:class="{ disabled: !mr.canPushToSourceBranch }" class="gl-display-none d-md-inline-block gl-mr-3"
class="btn btn-default js-web-ide d-none d-md-inline-block gl-mr-3" :tabindex="!mr.canPushToSourceBranch ? 0 : null"
data-placement="bottom"
tabindex="0"
role="button"
data-qa-selector="open_in_web_ide_button"
> >
{{ s__('mrWidget|Open in Web IDE') }} <gl-button
</a> :href="webIdePath"
<button :disabled="!mr.canPushToSourceBranch"
class="js-web-ide"
tabindex="0"
role="button"
data-qa-selector="open_in_web_ide_button"
>
{{ s__('mrWidget|Open in Web IDE') }}
</gl-button>
</span>
<gl-button
:disabled="mr.sourceBranchRemoved" :disabled="mr.sourceBranchRemoved"
data-target="#modal_merge_info" data-target="#modal_merge_info"
data-toggle="modal" data-toggle="modal"
class="btn btn-default js-check-out-branch gl-mr-3" class="js-check-out-branch gl-mr-3"
type="button"
> >
{{ s__('mrWidget|Check out branch') }} {{ s__('mrWidget|Check out branch') }}
</button> </gl-button>
</template> </template>
<span class="dropdown"> <gl-dropdown
<button v-gl-tooltip
type="button" :title="__('Download as')"
class="btn dropdown-toggle qa-dropdown-toggle" :aria-label="__('Download as')"
data-toggle="dropdown" icon="download"
:aria-label="__('Download as')" right
aria-haspopup="true" data-qa-selector="download_dropdown"
aria-expanded="false" >
<gl-dropdown-header>{{ s__('Download as') }}</gl-dropdown-header>
<gl-dropdown-item
:href="mr.emailPatchesPath"
class="js-download-email-patches"
download
data-qa-selector="download_email_patches"
> >
<gl-icon name="download" /> {{ s__('mrWidget|Email patches') }}
<gl-icon name="chevron-down" aria-hidden="true" /> </gl-dropdown-item>
</button> <gl-dropdown-item
<ul class="dropdown-menu dropdown-menu-right"> :href="mr.plainDiffPath"
<li> class="js-download-plain-diff"
<a download
:href="mr.emailPatchesPath" data-qa-selector="download_plain_diff"
class="js-download-email-patches qa-download-email-patches" >
download {{ s__('mrWidget|Plain diff') }}
> </gl-dropdown-item>
{{ s__('mrWidget|Email patches') }} </gl-dropdown>
</a>
</li>
<li>
<a
:href="mr.plainDiffPath"
class="js-download-plain-diff qa-download-plain-diff"
download
>
{{ s__('mrWidget|Plain diff') }}
</a>
</li>
</ul>
</span>
</div> </div>
</div> </div>
</div> </div>
......
...@@ -8,7 +8,7 @@ module QA ...@@ -8,7 +8,7 @@ module QA
include Page::Component::Issuable::Sidebar include Page::Component::Issuable::Sidebar
view 'app/assets/javascripts/vue_merge_request_widget/components/mr_widget_header.vue' do view 'app/assets/javascripts/vue_merge_request_widget/components/mr_widget_header.vue' do
element :dropdown_toggle element :download_dropdown
element :download_email_patches element :download_email_patches
element :download_plain_diff element :download_plain_diff
element :open_in_web_ide_button element :open_in_web_ide_button
...@@ -255,12 +255,12 @@ module QA ...@@ -255,12 +255,12 @@ module QA
end end
def view_email_patches def view_email_patches
click_element :dropdown_toggle click_element :download_dropdown
visit_link_in_element(:download_email_patches) visit_link_in_element(:download_email_patches)
end end
def view_plain_diff def view_plain_diff
click_element :dropdown_toggle click_element :download_dropdown
visit_link_in_element(:download_plain_diff) visit_link_in_element(:download_plain_diff)
end end
......
...@@ -25,10 +25,14 @@ describe('MRWidgetHeader', () => { ...@@ -25,10 +25,14 @@ describe('MRWidgetHeader', () => {
const downloadEmailPatchesEl = vm.$el.querySelector('.js-download-email-patches'); const downloadEmailPatchesEl = vm.$el.querySelector('.js-download-email-patches');
const downloadPlainDiffEl = vm.$el.querySelector('.js-download-plain-diff'); const downloadPlainDiffEl = vm.$el.querySelector('.js-download-plain-diff');
expect(downloadEmailPatchesEl.textContent.trim()).toEqual('Email patches'); expect(downloadEmailPatchesEl.innerText.trim()).toEqual('Email patches');
expect(downloadEmailPatchesEl.getAttribute('href')).toEqual('/mr/email-patches'); expect(downloadEmailPatchesEl.querySelector('a').getAttribute('href')).toEqual(
expect(downloadPlainDiffEl.textContent.trim()).toEqual('Plain diff'); '/mr/email-patches',
expect(downloadPlainDiffEl.getAttribute('href')).toEqual('/mr/plainDiffPath'); );
expect(downloadPlainDiffEl.innerText.trim()).toEqual('Plain diff');
expect(downloadPlainDiffEl.querySelector('a').getAttribute('href')).toEqual(
'/mr/plainDiffPath',
);
}; };
describe('computed', () => { describe('computed', () => {
......
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