Commit 3e5b8383 authored by Jose Ivan Vargas's avatar Jose Ivan Vargas

Merge branch 'ss/disable-create-list-button' into 'master'

Disable create list button when create list modal is already open

See merge request gitlab-org/gitlab!72048
parents 85b91c73 8d8de87a
<script>
import { GlButton } from '@gitlab/ui';
import { mapActions } from 'vuex';
import { GlButton, GlTooltipDirective } from '@gitlab/ui';
import { mapActions, mapState } from 'vuex';
import { __ } from '~/locale';
import Tracking from '~/tracking';
export default {
components: {
GlButton,
},
directives: {
GlTooltip: GlTooltipDirective,
},
mixins: [Tracking.mixin()],
computed: {
...mapState({ isNewListShowing: ({ addColumnForm }) => addColumnForm.visible }),
tooltip() {
return this.isNewListShowing ? __('The list creation wizard is already open') : '';
},
},
methods: {
...mapActions(['setAddColumnFormVisibility']),
handleClick() {
......@@ -19,7 +29,14 @@ export default {
</script>
<template>
<div class="gl-ml-3 gl-display-flex gl-align-items-center" data-testid="boards-create-list">
<gl-button variant="confirm" @click="handleClick">{{ __('Create list') }} </gl-button>
<div
v-gl-tooltip="tooltip"
:tabindex="isNewListShowing ? '0' : undefined"
class="gl-ml-3 gl-display-flex gl-align-items-center"
data-testid="boards-create-list"
>
<gl-button :disabled="isNewListShowing" variant="confirm" @click="handleClick"
>{{ __('Create list') }}
</gl-button>
</div>
</template>
......@@ -34065,6 +34065,9 @@ msgstr ""
msgid "The license was successfully uploaded and will be active from %{starts_at}. You can see the details below."
msgstr ""
msgid "The list creation wizard is already open"
msgstr ""
msgid "The maximum file size allowed is %{size}."
msgstr ""
......
import { GlButton } from '@gitlab/ui';
import Vue from 'vue';
import Vuex from 'vuex';
import { mountExtended } from 'helpers/vue_test_utils_helper';
import BoardAddNewColumnTrigger from '~/boards/components/board_add_new_column_trigger.vue';
import { createStore } from '~/boards/stores';
import { createMockDirective, getBinding } from 'helpers/vue_mock_directive';
Vue.use(Vuex);
describe('BoardAddNewColumnTrigger', () => {
let wrapper;
const findBoardsCreateList = () => wrapper.findByTestId('boards-create-list');
const findTooltipText = () => getBinding(findBoardsCreateList().element, 'gl-tooltip');
const mountComponent = () => {
wrapper = mountExtended(BoardAddNewColumnTrigger, {
directives: {
GlTooltip: createMockDirective(),
},
store: createStore(),
});
};
beforeEach(() => {
mountComponent();
});
afterEach(() => {
wrapper.destroy();
});
describe('when button is active', () => {
it('does not show the tooltip', () => {
const tooltip = findTooltipText();
expect(tooltip.value).toBe('');
});
it('renders an enabled button', () => {
const button = wrapper.find(GlButton);
expect(button.props('disabled')).toBe(false);
});
});
describe('when button is disabled', () => {
it('shows the tooltip', async () => {
wrapper.find(GlButton).vm.$emit('click');
await wrapper.vm.$nextTick();
const tooltip = findTooltipText();
expect(tooltip.value).toBe('The list creation wizard is already open');
});
});
});
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