Commit 3ba5c205 authored by Jarek Ostrowski's avatar Jarek Ostrowski

Update lock form buttons to gl-button

MR: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/41454
parent 51eebe52
<script> <script>
import $ from 'jquery'; import $ from 'jquery';
import { GlLoadingIcon } from '@gitlab/ui'; import { GlButton } from '@gitlab/ui';
import { mapActions } from 'vuex'; import { mapActions } from 'vuex';
import { __, sprintf } from '../../../locale'; import { __, sprintf } from '../../../locale';
import { deprecatedCreateFlash as Flash } from '~/flash'; import { deprecatedCreateFlash as Flash } from '~/flash';
...@@ -8,7 +8,7 @@ import eventHub from '../../event_hub'; ...@@ -8,7 +8,7 @@ import eventHub from '../../event_hub';
export default { export default {
components: { components: {
GlLoadingIcon, GlButton,
}, },
inject: ['fullPath'], inject: ['fullPath'],
props: { props: {
...@@ -65,19 +65,19 @@ export default { ...@@ -65,19 +65,19 @@ export default {
<template> <template>
<div class="sidebar-item-warning-message-actions"> <div class="sidebar-item-warning-message-actions">
<button type="button" class="btn btn-default gl-mr-3" @click="closeForm"> <gl-button class="gl-mr-3" @click="closeForm">
{{ __('Cancel') }} {{ __('Cancel') }}
</button> </gl-button>
<button <gl-button
type="button"
data-testid="lock-toggle" data-testid="lock-toggle"
class="btn btn-close" category="secondary"
variant="warning"
:disabled="isLoading" :disabled="isLoading"
:loading="isLoading"
@click.prevent="submitForm" @click.prevent="submitForm"
> >
<gl-loading-icon v-if="isLoading" inline />
{{ buttonText }} {{ buttonText }}
</button> </gl-button>
</div> </div>
</template> </template>
---
title: Update lock form buttons to gl-button
merge_request: 41454
author:
type: changed
import { shallowMount } from '@vue/test-utils'; import { mount } from '@vue/test-utils';
import { GlLoadingIcon } from '@gitlab/ui';
import EditFormButtons from '~/sidebar/components/lock/edit_form_buttons.vue'; import EditFormButtons from '~/sidebar/components/lock/edit_form_buttons.vue';
import eventHub from '~/sidebar/event_hub'; import eventHub from '~/sidebar/event_hub';
import { deprecatedCreateFlash as flash } from '~/flash'; import { deprecatedCreateFlash as flash } from '~/flash';
...@@ -22,7 +21,6 @@ describe('EditFormButtons', () => { ...@@ -22,7 +21,6 @@ describe('EditFormButtons', () => {
}; };
const findLockToggle = () => wrapper.find('[data-testid="lock-toggle"]'); const findLockToggle = () => wrapper.find('[data-testid="lock-toggle"]');
const findGlLoadingIcon = () => wrapper.find(GlLoadingIcon);
const createComponent = ({ props = {}, data = {}, resolved = true }) => { const createComponent = ({ props = {}, data = {}, resolved = true }) => {
store = issuableType === ISSUABLE_TYPE_ISSUE ? createStore() : createMrStore(); store = issuableType === ISSUABLE_TYPE_ISSUE ? createStore() : createMrStore();
...@@ -33,7 +31,7 @@ describe('EditFormButtons', () => { ...@@ -33,7 +31,7 @@ describe('EditFormButtons', () => {
jest.spyOn(store, 'dispatch').mockRejectedValue(); jest.spyOn(store, 'dispatch').mockRejectedValue();
} }
wrapper = shallowMount(EditFormButtons, { wrapper = mount(EditFormButtons, {
store, store,
provide: { provide: {
fullPath: '', fullPath: '',
...@@ -78,8 +76,8 @@ describe('EditFormButtons', () => { ...@@ -78,8 +76,8 @@ describe('EditFormButtons', () => {
expect(findLockToggle().attributes('disabled')).toBe('disabled'); expect(findLockToggle().attributes('disabled')).toBe('disabled');
}); });
it('displays the GlLoadingIcon', () => { it('sets loading on the toggle button', () => {
expect(findGlLoadingIcon().exists()).toBe(true); expect(findLockToggle().props('loading')).toBe(true);
}); });
}); });
...@@ -121,7 +119,7 @@ describe('EditFormButtons', () => { ...@@ -121,7 +119,7 @@ describe('EditFormButtons', () => {
it('resets loading', async () => { it('resets loading', async () => {
await wrapper.vm.$nextTick().then(() => { await wrapper.vm.$nextTick().then(() => {
expect(findGlLoadingIcon().exists()).toBe(false); expect(findLockToggle().props('loading')).toBe(false);
}); });
}); });
...@@ -156,7 +154,7 @@ describe('EditFormButtons', () => { ...@@ -156,7 +154,7 @@ describe('EditFormButtons', () => {
it('resets loading', async () => { it('resets loading', async () => {
await wrapper.vm.$nextTick().then(() => { await wrapper.vm.$nextTick().then(() => {
expect(findGlLoadingIcon().exists()).toBe(false); expect(findLockToggle().props('loading')).toBe(false);
}); });
}); });
......
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