Commit e1cec276 authored by Kyle Mann's avatar Kyle Mann Committed by Mark Florian

Use GlButton for approvals footer toggle

parent cfc6a8bf
<script> <script>
import { GlDeprecatedButton, GlLoadingIcon, GlIcon } from '@gitlab/ui'; import { GlButton, GlDeprecatedButton } from '@gitlab/ui';
import { __ } from '~/locale'; import { __ } from '~/locale';
import UserAvatarList from '~/vue_shared/components/user_avatar/user_avatar_list.vue'; import UserAvatarList from '~/vue_shared/components/user_avatar/user_avatar_list.vue';
import ApprovalsList from './approvals_list.vue'; import ApprovalsList from './approvals_list.vue';
export default { export default {
components: { components: {
GlIcon, GlButton,
GlDeprecatedButton, GlDeprecatedButton,
GlLoadingIcon,
UserAvatarList, UserAvatarList,
ApprovalsList, ApprovalsList,
}, },
...@@ -55,6 +54,9 @@ export default { ...@@ -55,6 +54,9 @@ export default {
suggestedApproversTrimmed() { suggestedApproversTrimmed() {
return this.suggestedApprovers.slice(0, Math.min(5, this.suggestedApprovers.length)); return this.suggestedApprovers.slice(0, Math.min(5, this.suggestedApprovers.length));
}, },
shouldShowLoadingSpinner() {
return !this.isCollapsed && this.isLoadingRules;
},
}, },
methods: { methods: {
toggle() { toggle() {
...@@ -67,15 +69,16 @@ export default { ...@@ -67,15 +69,16 @@ export default {
<template> <template>
<div> <div>
<div class="mr-widget-extension d-flex align-items-center pl-3"> <div class="mr-widget-extension d-flex align-items-center pl-3">
<button <!-- TODO: simplify button classes once https://gitlab.com/gitlab-org/gitlab-ui/-/issues/1029 is completed -->
class="btn btn-blank square s32 gl-mr-3" <gl-button
type="button" class="gl-mr-3"
:class="{ 'gl-shadow-none!': shouldShowLoadingSpinner }"
:aria-label="ariaLabel" :aria-label="ariaLabel"
:loading="shouldShowLoadingSpinner"
:icon="angleIcon"
category="tertiary"
@click="toggle" @click="toggle"
> />
<gl-loading-icon v-if="!isCollapsed && isLoadingRules" />
<gl-icon v-else :name="angleIcon" :size="16" />
</button>
<template v-if="isCollapsed"> <template v-if="isCollapsed">
<user-avatar-list :items="suggestedApproversTrimmed" :breakpoint="0" empty-text="" /> <user-avatar-list :items="suggestedApproversTrimmed" :breakpoint="0" empty-text="" />
<gl-deprecated-button variant="link" @click="toggle">{{ <gl-deprecated-button variant="link" @click="toggle">{{
......
---
title: Update approvals toggle button style
merge_request: 42075
author:
type: other
import { shallowMount } from '@vue/test-utils'; import { mount } from '@vue/test-utils';
import { GlDeprecatedButton, GlLoadingIcon, GlIcon } from '@gitlab/ui'; import { GlDeprecatedButton, GlButton, GlLoadingIcon, GlIcon } from '@gitlab/ui';
import stubChildren from 'helpers/stub_children';
import ApprovalsList from 'ee/vue_merge_request_widget/components/approvals/approvals_list.vue'; import ApprovalsList from 'ee/vue_merge_request_widget/components/approvals/approvals_list.vue';
import ApprovalsFooter from 'ee/vue_merge_request_widget/components/approvals/approvals_footer.vue'; import ApprovalsFooter from 'ee/vue_merge_request_widget/components/approvals/approvals_footer.vue';
import UserAvatarList from '~/vue_shared/components/user_avatar/user_avatar_list.vue'; import UserAvatarList from '~/vue_shared/components/user_avatar/user_avatar_list.vue';
...@@ -11,16 +12,20 @@ describe('EE MRWidget approvals footer', () => { ...@@ -11,16 +12,20 @@ describe('EE MRWidget approvals footer', () => {
let wrapper; let wrapper;
const createComponent = (props = {}) => { const createComponent = (props = {}) => {
wrapper = shallowMount(ApprovalsFooter, { wrapper = mount(ApprovalsFooter, {
propsData: { propsData: {
suggestedApprovers: testSuggestedApprovers(), suggestedApprovers: testSuggestedApprovers(),
approvalRules: testApprovalRules(), approvalRules: testApprovalRules(),
...props, ...props,
}, },
stubs: {
...stubChildren(ApprovalsFooter),
GlButton: false,
},
}); });
}; };
const findToggle = () => wrapper.find('button'); const findToggle = () => wrapper.find(GlButton);
const findToggleIcon = () => findToggle().find(GlIcon); const findToggleIcon = () => findToggle().find(GlIcon);
const findToggleLoadingIcon = () => findToggle().find(GlLoadingIcon); const findToggleLoadingIcon = () => findToggle().find(GlLoadingIcon);
const findExpandButton = () => wrapper.find(GlDeprecatedButton); const findExpandButton = () => wrapper.find(GlDeprecatedButton);
...@@ -138,7 +143,7 @@ describe('EE MRWidget approvals footer', () => { ...@@ -138,7 +143,7 @@ describe('EE MRWidget approvals footer', () => {
it('expands when clicked', () => { it('expands when clicked', () => {
const button = findToggle(); const button = findToggle();
button.trigger('click'); button.vm.$emit('click');
return wrapper.vm.$nextTick().then(() => { return wrapper.vm.$nextTick().then(() => {
expect(wrapper.emitted().input).toEqual([[true]]); expect(wrapper.emitted().input).toEqual([[true]]);
......
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