Commit 7ad8366e authored by Mike Greiling's avatar Mike Greiling

Merge branch '229342-update-issue-edit-buttons' into 'master'

Update issue edit buttons

Closes #229342

See merge request gitlab-org/gitlab!40298
parents a58edb70 d7a7b519
<script> <script>
/* eslint-disable @gitlab/vue-require-i18n-strings */ import { GlButton } from '@gitlab/ui';
import { __, sprintf } from '~/locale'; import { __, sprintf } from '~/locale';
import updateMixin from '../mixins/update'; import updateMixin from '../mixins/update';
import eventHub from '../event_hub'; import eventHub from '../event_hub';
...@@ -10,6 +10,9 @@ const issuableTypes = { ...@@ -10,6 +10,9 @@ const issuableTypes = {
}; };
export default { export default {
components: {
GlButton,
},
mixins: [updateMixin], mixins: [updateMixin],
props: { props: {
canDestroy: { canDestroy: {
...@@ -64,28 +67,30 @@ export default { ...@@ -64,28 +67,30 @@ export default {
<template> <template>
<div class="gl-mt-3 gl-mb-3 clearfix"> <div class="gl-mt-3 gl-mb-3 clearfix">
<button <gl-button
:class="{ disabled: formState.updateLoading || !isSubmitEnabled }" :loading="formState.updateLoading"
:disabled="formState.updateLoading || !isSubmitEnabled" :disabled="formState.updateLoading || !isSubmitEnabled"
class="btn btn-success float-left qa-save-button" category="primary"
variant="success"
class="float-left qa-save-button"
type="submit" type="submit"
@click.prevent="updateIssuable" @click.prevent="updateIssuable"
> >
Save changes {{ __('Save changes') }}
<i v-if="formState.updateLoading" class="fa fa-spinner fa-spin" aria-hidden="true"> </i> </gl-button>
</button> <gl-button class="float-right" @click="closeForm">
<button class="btn btn-default float-right" type="button" @click="closeForm">
{{ __('Cancel') }} {{ __('Cancel') }}
</button> </gl-button>
<button <gl-button
v-if="shouldShowDeleteButton" v-if="shouldShowDeleteButton"
:class="{ disabled: deleteLoading }" :loading="deleteLoading"
:disabled="deleteLoading" :disabled="deleteLoading"
class="btn btn-danger float-right gl-mr-3 qa-delete-button" category="primary"
type="button" variant="danger"
class="float-right gl-mr-3 qa-delete-button"
@click="deleteIssuable" @click="deleteIssuable"
> >
Delete <i v-if="deleteLoading" class="fa fa-spinner fa-spin" aria-hidden="true"> </i> {{ __('Delete') }}
</button> </gl-button>
</div> </div>
</template> </template>
---
title: Update issue edit buttons
merge_request: 40298
author:
type: changed
...@@ -70,16 +70,6 @@ describe('Edit Actions components', () => { ...@@ -70,16 +70,6 @@ describe('Edit Actions components', () => {
expect(eventHub.$emit).toHaveBeenCalledWith('update.issuable'); expect(eventHub.$emit).toHaveBeenCalledWith('update.issuable');
}); });
it('shows loading icon after clicking save button', done => {
vm.$el.querySelector('.btn-success').click();
Vue.nextTick(() => {
expect(vm.$el.querySelector('.btn-success .fa')).not.toBeNull();
done();
});
});
it('disabled button after clicking save button', done => { it('disabled button after clicking save button', done => {
vm.$el.querySelector('.btn-success').click(); vm.$el.querySelector('.btn-success').click();
...@@ -107,17 +97,6 @@ describe('Edit Actions components', () => { ...@@ -107,17 +97,6 @@ describe('Edit Actions components', () => {
expect(eventHub.$emit).toHaveBeenCalledWith('delete.issuable', { destroy_confirm: true }); expect(eventHub.$emit).toHaveBeenCalledWith('delete.issuable', { destroy_confirm: true });
}); });
it('shows loading icon after clicking delete button', done => {
jest.spyOn(window, 'confirm').mockReturnValue(true);
vm.$el.querySelector('.btn-danger').click();
Vue.nextTick(() => {
expect(vm.$el.querySelector('.btn-danger .fa')).not.toBeNull();
done();
});
});
it('does no actions when confirm is false', done => { it('does no actions when confirm is false', done => {
jest.spyOn(window, 'confirm').mockReturnValue(false); jest.spyOn(window, 'confirm').mockReturnValue(false);
vm.$el.querySelector('.btn-danger').click(); vm.$el.querySelector('.btn-danger').click();
......
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