Commit ffa0944d authored by Natalia Tepluhina's avatar Natalia Tepluhina

Merge branch '215400-use-inactivelistid-constant-in-boards-state-initialization' into 'master'

Use `inactiveListId` constant in boards state

Closes #215400

See merge request gitlab-org/gitlab!30521
parents 771b3a1a 294e0583
import { inactiveListId } from '~/boards/constants';
export default () => ({ export default () => ({
isShowingLabels: true, isShowingLabels: true,
activeListId: 0, activeListId: inactiveListId,
}); });
...@@ -15,6 +15,7 @@ import boardsStoreEE from '../stores/boards_store_ee'; ...@@ -15,6 +15,7 @@ import boardsStoreEE from '../stores/boards_store_ee';
import eventHub from '~/sidebar/event_hub'; import eventHub from '~/sidebar/event_hub';
import flash from '~/flash'; import flash from '~/flash';
import { isScopedLabel } from '~/lib/utils/common_utils'; import { isScopedLabel } from '~/lib/utils/common_utils';
import { inactiveListId } from '~/boards/constants';
// NOTE: need to revisit how we handle headerHeight, because we have so many different header and footer options. // NOTE: need to revisit how we handle headerHeight, because we have so many different header and footer options.
export default { export default {
...@@ -60,7 +61,7 @@ export default { ...@@ -60,7 +61,7 @@ export default {
return boardsStoreEE.store.state.lists.find(({ id }) => id === this.activeListId); return boardsStoreEE.store.state.lists.find(({ id }) => id === this.activeListId);
}, },
isSidebarOpen() { isSidebarOpen() {
return this.activeListId > 0; return this.activeListId !== inactiveListId;
}, },
activeListLabel() { activeListLabel() {
return this.activeList.label; return this.activeList.label;
...@@ -110,7 +111,7 @@ export default { ...@@ -110,7 +111,7 @@ export default {
...mapActions(['setActiveListId', 'updateListWipLimit']), ...mapActions(['setActiveListId', 'updateListWipLimit']),
closeSidebar() { closeSidebar() {
this.edit = false; this.edit = false;
this.setActiveListId(0); this.setActiveListId(inactiveListId);
}, },
showInput() { showInput() {
this.edit = true; this.edit = true;
...@@ -136,7 +137,7 @@ export default { ...@@ -136,7 +137,7 @@ export default {
}) })
.catch(() => { .catch(() => {
this.resetStateAfterUpdate(); this.resetStateAfterUpdate();
this.setActiveListId(0); this.setActiveListId(inactiveListId);
flash(__('Something went wrong while updating your list settings')); flash(__('Something went wrong while updating your list settings'));
}); });
} else { } else {
...@@ -151,7 +152,7 @@ export default { ...@@ -151,7 +152,7 @@ export default {
}) })
.catch(() => { .catch(() => {
this.resetStateAfterUpdate(); this.resetStateAfterUpdate();
this.setActiveListId(0); this.setActiveListId(inactiveListId);
flash(__('Something went wrong while updating your list settings')); flash(__('Something went wrong while updating your list settings'));
}); });
}, },
......
...@@ -11,6 +11,7 @@ import bs from '~/boards/stores/boards_store'; ...@@ -11,6 +11,7 @@ import bs from '~/boards/stores/boards_store';
import sidebarEventHub from '~/sidebar/event_hub'; import sidebarEventHub from '~/sidebar/event_hub';
import flash from '~/flash'; import flash from '~/flash';
import waitForPromises from 'helpers/wait_for_promises'; import waitForPromises from 'helpers/wait_for_promises';
import { inactiveListId } from '~/boards/constants';
jest.mock('~/flash'); jest.mock('~/flash');
// NOTE: needed for calling boardsStore.addList // NOTE: needed for calling boardsStore.addList
...@@ -28,7 +29,11 @@ describe('BoardSettingsSideBar', () => { ...@@ -28,7 +29,11 @@ describe('BoardSettingsSideBar', () => {
const listId = 1; const listId = 1;
const currentWipLimit = 1; // Needs to be other than null to trigger requests. const currentWipLimit = 1; // Needs to be other than null to trigger requests.
const createComponent = (state = { activeListId: 0 }, actions = {}, localState = {}) => { const createComponent = (
state = { activeListId: inactiveListId },
actions = {},
localState = {},
) => {
storeActions = actions; storeActions = actions;
const store = new Vuex.Store({ const store = new Vuex.Store({
...@@ -88,28 +93,28 @@ describe('BoardSettingsSideBar', () => { ...@@ -88,28 +93,28 @@ describe('BoardSettingsSideBar', () => {
describe('on close', () => { describe('on close', () => {
it('calls closeSidebar', () => { it('calls closeSidebar', () => {
const spy = jest.fn(); const spy = jest.fn();
createComponent({ activeListId: 0 }, { setActiveListId: spy }); createComponent({ activeListId: inactiveListId }, { setActiveListId: spy });
wrapper.find(GlDrawer).vm.$emit('close'); wrapper.find(GlDrawer).vm.$emit('close');
return wrapper.vm.$nextTick().then(() => { return wrapper.vm.$nextTick().then(() => {
expect(storeActions.setActiveListId).toHaveBeenCalledWith( expect(storeActions.setActiveListId).toHaveBeenCalledWith(
expect.anything(), expect.anything(),
0, inactiveListId,
undefined, undefined,
); );
}); });
}); });
it('calls closeSidebar on sidebar.closeAll event', () => { it('calls closeSidebar on sidebar.closeAll event', () => {
createComponent({ activeListId: 0 }, { setActiveListId: jest.fn() }); createComponent({ activeListId: inactiveListId }, { setActiveListId: jest.fn() });
sidebarEventHub.$emit('sidebar.closeAll'); sidebarEventHub.$emit('sidebar.closeAll');
return wrapper.vm.$nextTick().then(() => { return wrapper.vm.$nextTick().then(() => {
expect(storeActions.setActiveListId).toHaveBeenCalledWith( expect(storeActions.setActiveListId).toHaveBeenCalledWith(
expect.anything(), expect.anything(),
0, inactiveListId,
undefined, undefined,
); );
}); });
...@@ -178,7 +183,7 @@ describe('BoardSettingsSideBar', () => { ...@@ -178,7 +183,7 @@ describe('BoardSettingsSideBar', () => {
boardsStore.store.addList({ id: listId, label: { title: labelTitle, color: labelColor } }); boardsStore.store.addList({ id: listId, label: { title: labelTitle, color: labelColor } });
createComponent({ activeListId: 0 }); createComponent({ activeListId: inactiveListId });
}); });
afterEach(() => { afterEach(() => {
......
...@@ -3,6 +3,7 @@ import boardsStoreEE from 'ee/boards/stores/boards_store_ee'; ...@@ -3,6 +3,7 @@ import boardsStoreEE from 'ee/boards/stores/boards_store_ee';
import actions from 'ee/boards/stores/actions'; import actions from 'ee/boards/stores/actions';
import * as types from 'ee/boards/stores/mutation_types'; import * as types from 'ee/boards/stores/mutation_types';
import testAction from 'helpers/vuex_action_helper'; import testAction from 'helpers/vuex_action_helper';
import { inactiveListId } from '~/boards/constants';
jest.mock('axios'); jest.mock('axios');
...@@ -25,7 +26,7 @@ describe('toggleShowLabels', () => { ...@@ -25,7 +26,7 @@ describe('toggleShowLabels', () => {
describe('setActiveListId', () => { describe('setActiveListId', () => {
it('should commit mutation SET_ACTIVE_LIST_ID', done => { it('should commit mutation SET_ACTIVE_LIST_ID', done => {
const state = { const state = {
activeListId: 0, activeListId: inactiveListId,
}; };
testAction( testAction(
......
import mutations from 'ee/boards/stores/mutations'; import mutations from 'ee/boards/stores/mutations';
import { inactiveListId } from '~/boards/constants';
const expectNotImplemented = action => { const expectNotImplemented = action => {
it('is not implemented', () => { it('is not implemented', () => {
...@@ -32,7 +33,7 @@ describe('SET_ACTIVE_LIST_ID', () => { ...@@ -32,7 +33,7 @@ describe('SET_ACTIVE_LIST_ID', () => {
it('updates aciveListId to be the value that is passed', () => { it('updates aciveListId to be the value that is passed', () => {
const expectedId = 1; const expectedId = 1;
const state = { const state = {
activeListId: 0, activeListId: inactiveListId,
}; };
mutations.SET_ACTIVE_LIST_ID(state, expectedId); mutations.SET_ACTIVE_LIST_ID(state, expectedId);
......
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