Commit 3be5b42d authored by Justin Ho's avatar Justin Ho

Remove unused loading_button component

Since the epic to migrate away from this component
has been complete.
https://gitlab.com/groups/gitlab-org/-/epics/3907
parent e8fd0f30
......@@ -178,11 +178,7 @@ export default {
:key="pagePaginationStateKey"
@appear="fetchRepos"
/>
<gl-loading-icon
v-if="isLoading"
class="js-loading-button-icon import-projects-loading-icon"
size="md"
/>
<gl-loading-icon v-if="isLoading" class="import-projects-loading-icon" size="md" />
<div v-if="!isLoading && repositories.length === 0" class="text-center">
<strong>{{ emptyStateText }}</strong>
......
<script>
import { GlLoadingIcon } from '@gitlab/ui';
/* eslint-disable vue/require-default-prop */
/*
This component will be deprecated in favor of gl-deprecated-button.
https://gitlab-org.gitlab.io/gitlab-ui/?path=/story/base-button--loading-button
https://gitlab.com/gitlab-org/gitlab/issues/207412
*/
export default {
components: {
GlLoadingIcon,
},
props: {
loading: {
type: Boolean,
required: false,
default: false,
},
disabled: {
type: Boolean,
required: false,
default: false,
},
label: {
type: String,
required: false,
},
containerClass: {
type: [String, Array, Object],
required: false,
default: 'btn btn-align-content',
},
},
methods: {
onClick(e) {
this.$emit('click', e);
},
},
};
</script>
<template>
<button :class="containerClass" :disabled="loading || disabled" type="button" @click="onClick">
<transition name="fade-in">
<gl-loading-icon
v-if="loading"
:inline="true"
:class="{
'gl-mr-2': label,
}"
class="js-loading-button-icon"
/>
</transition>
<transition name="fade-in">
<slot>
<span v-if="label" class="js-loading-button-label"> {{ label }} </span>
</slot>
</transition>
</button>
</template>
import { shallowMount } from '@vue/test-utils';
import LoadingButton from '~/vue_shared/components/loading_button.vue';
const LABEL = 'Hello';
describe('LoadingButton', () => {
let wrapper;
afterEach(() => {
wrapper.destroy();
});
const buildWrapper = (propsData = {}) => {
wrapper = shallowMount(LoadingButton, {
propsData,
});
};
const findButtonLabel = () => wrapper.find('.js-loading-button-label');
const findButtonIcon = () => wrapper.find('.js-loading-button-icon');
describe('loading spinner', () => {
it('shown when loading', () => {
buildWrapper({ loading: true });
expect(findButtonIcon().exists()).toBe(true);
});
});
describe('disabled state', () => {
it('disabled when loading', () => {
buildWrapper({ loading: true });
expect(wrapper.attributes('disabled')).toBe('disabled');
});
it('not disabled when normal', () => {
buildWrapper({ loading: false });
expect(wrapper.attributes('disabled')).toBe(undefined);
});
});
describe('label', () => {
it('shown when normal', () => {
buildWrapper({ loading: false, label: LABEL });
expect(findButtonLabel().text()).toBe(LABEL);
});
it('shown when loading', () => {
buildWrapper({ loading: false, label: LABEL });
expect(findButtonLabel().text()).toBe(LABEL);
});
});
describe('container class', () => {
it('should default to btn btn-align-content', () => {
buildWrapper();
expect(wrapper.classes()).toContain('btn');
expect(wrapper.classes()).toContain('btn-align-content');
});
it('should be configurable through props', () => {
const containerClass = 'test-class';
buildWrapper({
containerClass,
});
expect(wrapper.classes()).not.toContain('btn');
expect(wrapper.classes()).not.toContain('btn-align-content');
expect(wrapper.classes()).toContain(containerClass);
});
});
describe('click callback prop', () => {
it('calls given callback when normal', () => {
buildWrapper({
loading: false,
});
wrapper.trigger('click');
return wrapper.vm.$nextTick().then(() => {
expect(wrapper.emitted('click')).toBeTruthy();
});
});
it('does not call given callback when disabled because of loading', () => {
buildWrapper({
loading: true,
});
wrapper.trigger('click');
return wrapper.vm.$nextTick().then(() => {
expect(wrapper.emitted('click')).toBeFalsy();
});
});
});
});
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