Commit 2168c304 authored by Paul Slaughter's avatar Paul Slaughter

Merge branch '224139-merge-request-approval-button-style-inadvertently-changed' into 'master'

Resolve "Merge request approval button style inadvertently changed"

Closes #29151 and #224139

See merge request gitlab-org/gitlab!35213
parents 39348805 943d5c98
<script> <script>
import { GlButton, GlLoadingIcon } from '@gitlab/ui'; import { GlButton } from '@gitlab/ui';
import createFlash, { hideFlash } from '~/flash'; import createFlash, { hideFlash } from '~/flash';
import { s__ } from '~/locale'; import { s__ } from '~/locale';
import eventHub from '~/vue_merge_request_widget/event_hub'; import eventHub from '~/vue_merge_request_widget/event_hub';
...@@ -21,7 +21,6 @@ export default { ...@@ -21,7 +21,6 @@ export default {
ApprovalsFooter, ApprovalsFooter,
ApprovalsAuth, ApprovalsAuth,
GlButton, GlButton,
GlLoadingIcon,
}, },
props: { props: {
mr: { mr: {
...@@ -85,10 +84,9 @@ export default { ...@@ -85,10 +84,9 @@ export default {
action() { action() {
// Use the default approve action, only if we aren't using the auth component for it // Use the default approve action, only if we aren't using the auth component for it
if (this.showApprove) { if (this.showApprove) {
const inverted = this.isApproved;
return { return {
text: this.approvalText, text: this.approvalText,
inverted, category: this.isApproved ? 'secondary' : 'primary',
variant: 'info', variant: 'info',
action: () => this.approve(), action: () => this.approve(),
}; };
...@@ -96,7 +94,7 @@ export default { ...@@ -96,7 +94,7 @@ export default {
return { return {
text: s__('mrWidget|Revoke approval'), text: s__('mrWidget|Revoke approval'),
variant: 'warning', variant: 'warning',
inverted: true, category: 'secondary',
action: () => this.unapprove(), action: () => this.unapprove(),
}; };
} }
...@@ -210,13 +208,12 @@ export default { ...@@ -210,13 +208,12 @@ export default {
<gl-button <gl-button
v-if="action" v-if="action"
:variant="action.variant" :variant="action.variant"
:class="{ 'btn-inverted': action.inverted }" :category="action.category"
category="secondary" :loading="isApproving"
class="mr-3" class="mr-3"
data-qa-selector="approve_button" data-qa-selector="approve_button"
@click="action.action" @click="action.action"
> >
<gl-loading-icon v-if="isApproving" inline />
{{ action.text }} {{ action.text }}
</gl-button> </gl-button>
<approvals-summary-optional <approvals-summary-optional
......
---
title: Fix visual regression for MR approve button
merge_request: 35213
author:
type: fixed
import { createLocalVue, shallowMount } from '@vue/test-utils'; import { createLocalVue, shallowMount } from '@vue/test-utils';
import { GlButton, GlLoadingIcon } from '@gitlab/ui'; import { GlButton } from '@gitlab/ui';
import Approvals from 'ee/vue_merge_request_widget/components/approvals/approvals.vue'; import Approvals from 'ee/vue_merge_request_widget/components/approvals/approvals.vue';
import ApprovalsSummary from 'ee/vue_merge_request_widget/components/approvals/approvals_summary.vue'; import ApprovalsSummary from 'ee/vue_merge_request_widget/components/approvals/approvals_summary.vue';
import ApprovalsSummaryOptional from 'ee/vue_merge_request_widget/components/approvals/approvals_summary_optional.vue'; import ApprovalsSummaryOptional from 'ee/vue_merge_request_widget/components/approvals/approvals_summary_optional.vue';
...@@ -62,8 +62,8 @@ describe('EE MRWidget approvals', () => { ...@@ -62,8 +62,8 @@ describe('EE MRWidget approvals', () => {
return !action.exists() return !action.exists()
? null ? null
: { : {
variant: action.attributes('variant'), variant: action.props('variant'),
inverted: action.classes('btn-inverted'), category: action.props('category'),
text: action.text(), text: action.text(),
}; };
}; };
...@@ -186,7 +186,7 @@ describe('EE MRWidget approvals', () => { ...@@ -186,7 +186,7 @@ describe('EE MRWidget approvals', () => {
expect(findActionData()).toEqual({ expect(findActionData()).toEqual({
variant: 'info', variant: 'info',
text: 'Approve', text: 'Approve',
inverted: false, category: 'primary',
}); });
}); });
}); });
...@@ -203,11 +203,11 @@ describe('EE MRWidget approvals', () => { ...@@ -203,11 +203,11 @@ describe('EE MRWidget approvals', () => {
waitForTick(done); waitForTick(done);
}); });
it('approve action (with inverted) is rendered', () => { it('approve action (with inverted style) is rendered', () => {
expect(findActionData()).toEqual({ expect(findActionData()).toEqual({
variant: 'info', variant: 'info',
text: 'Approve', text: 'Approve',
inverted: true, category: 'secondary',
}); });
}); });
}); });
...@@ -223,7 +223,7 @@ describe('EE MRWidget approvals', () => { ...@@ -223,7 +223,7 @@ describe('EE MRWidget approvals', () => {
expect(findActionData()).toEqual({ expect(findActionData()).toEqual({
variant: 'info', variant: 'info',
text: 'Approve additionally', text: 'Approve additionally',
inverted: true, category: 'secondary',
}); });
}); });
}); });
...@@ -239,13 +239,13 @@ describe('EE MRWidget approvals', () => { ...@@ -239,13 +239,13 @@ describe('EE MRWidget approvals', () => {
service.approveMergeRequest.and.callFake(() => new Promise(() => {})); service.approveMergeRequest.and.callFake(() => new Promise(() => {}));
const action = findAction(); const action = findAction();
expect(action.find(GlLoadingIcon).exists()).toBe(false); expect(action.props('loading')).toBe(false);
action.vm.$emit('click'); action.vm.$emit('click');
tick() tick()
.then(() => { .then(() => {
expect(action.find(GlLoadingIcon).exists()).toBe(true); expect(action.props('loading')).toBe(true);
}) })
.then(done) .then(done)
.catch(done.fail); .catch(done.fail);
...@@ -360,7 +360,7 @@ describe('EE MRWidget approvals', () => { ...@@ -360,7 +360,7 @@ describe('EE MRWidget approvals', () => {
expect(findActionData()).toEqual({ expect(findActionData()).toEqual({
variant: 'warning', variant: 'warning',
text: 'Revoke approval', text: 'Revoke approval',
inverted: true, category: 'secondary',
}); });
}); });
......
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