Commit 886a718d authored by Denys Mishunov's avatar Denys Mishunov

Merge branch 'sse-ux-submit-changes-loading' into 'master'

Update PublishToolbar with GlButton loading flag

See merge request gitlab-org/gitlab!30657
parents 1a9657f9 a4c18163
<script> <script>
import { GlButton, GlLoadingIcon } from '@gitlab/ui'; import { GlButton } from '@gitlab/ui';
export default { export default {
components: { components: {
GlButton, GlButton,
GlLoadingIcon,
}, },
props: { props: {
returnUrl: { returnUrl: {
...@@ -26,14 +25,18 @@ export default { ...@@ -26,14 +25,18 @@ export default {
}; };
</script> </script>
<template> <template>
<div class="d-flex bg-light border-top justify-content-between align-items-center py-3 px-4"> <div class="d-flex bg-light border-top justify-content-end align-items-center py-3 px-4">
<gl-loading-icon :class="{ invisible: !savingChanges }" size="md" />
<div> <div>
<gl-button v-if="returnUrl" ref="returnUrlLink" :href="returnUrl">{{ <gl-button v-if="returnUrl" ref="returnUrlLink" :href="returnUrl">{{
s__('StaticSiteEditor|Return to site') s__('StaticSiteEditor|Return to site')
}}</gl-button> }}</gl-button>
<gl-button variant="success" :disabled="!saveable || savingChanges" @click="$emit('submit')"> <gl-button
{{ __('Submit Changes') }} variant="success"
:disabled="!saveable"
:loading="savingChanges"
@click="$emit('submit')"
>
<span>{{ __('Submit Changes') }}</span>
</gl-button> </gl-button>
</div> </div>
</div> </div>
......
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import { GlButton, GlLoadingIcon } from '@gitlab/ui'; import { GlButton } from '@gitlab/ui';
import PublishToolbar from '~/static_site_editor/components/publish_toolbar.vue'; import PublishToolbar from '~/static_site_editor/components/publish_toolbar.vue';
...@@ -19,7 +19,6 @@ describe('Static Site Editor Toolbar', () => { ...@@ -19,7 +19,6 @@ describe('Static Site Editor Toolbar', () => {
const findReturnUrlLink = () => wrapper.find({ ref: 'returnUrlLink' }); const findReturnUrlLink = () => wrapper.find({ ref: 'returnUrlLink' });
const findSaveChangesButton = () => wrapper.find(GlButton); const findSaveChangesButton = () => wrapper.find(GlButton);
const findLoadingIndicator = () => wrapper.find(GlLoadingIcon);
beforeEach(() => { beforeEach(() => {
buildWrapper(); buildWrapper();
...@@ -37,8 +36,8 @@ describe('Static Site Editor Toolbar', () => { ...@@ -37,8 +36,8 @@ describe('Static Site Editor Toolbar', () => {
expect(findSaveChangesButton().attributes('disabled')).toBe('true'); expect(findSaveChangesButton().attributes('disabled')).toBe('true');
}); });
it('does not display saving changes indicator', () => { it('does not render the Submit Changes button with a loader', () => {
expect(findLoadingIndicator().classes()).toContain('invisible'); expect(findSaveChangesButton().props('loading')).toBe(false);
}); });
it('does not render returnUrl link', () => { it('does not render returnUrl link', () => {
...@@ -62,15 +61,11 @@ describe('Static Site Editor Toolbar', () => { ...@@ -62,15 +61,11 @@ describe('Static Site Editor Toolbar', () => {
describe('when saving changes', () => { describe('when saving changes', () => {
beforeEach(() => { beforeEach(() => {
buildWrapper({ saveable: true, savingChanges: true }); buildWrapper({ savingChanges: true });
}); });
it('disables Submit Changes button', () => { it('renders the Submit Changes button with a loading indicator', () => {
expect(findSaveChangesButton().attributes('disabled')).toBe('true'); expect(findSaveChangesButton().props('loading')).toBe(true);
});
it('displays saving changes indicator', () => {
expect(findLoadingIndicator().classes()).not.toContain('invisible');
}); });
}); });
......
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