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