Commit f85f8116 authored by Winnie Hellmann's avatar Winnie Hellmann Committed by Tim Zallmann

Extract setCurrentBoard() from BoardsSelector into BoardsStoreEE

parent b97227f8
......@@ -161,9 +161,7 @@ export default {
},
},
created() {
this.state.currentBoard = this.currentBoard;
boardsStore.state.assignees = [];
boardsStore.state.milestones = [];
boardsStore.setCurrentBoard(this.currentBoard);
$('#js-add-list').on('hide.bs.dropdown', this.handleDropdownHide);
$('.js-new-board-list-tabs').on('click', this.handleDropdownTabClick);
},
......
......@@ -16,6 +16,7 @@ class BoardsStoreEE {
this.addPromotion();
};
this.store.loadList = (listPath, listType) => this.loadList(listPath, listType);
this.store.setCurrentBoard = board => this.setCurrentBoard(board);
this.store.removePromotionState = () => {
this.removePromotion();
};
......@@ -156,6 +157,13 @@ class BoardsStoreEE {
return parseBoolean(Cookies.get('promotion_issue_board_hidden'));
}
setCurrentBoard(board) {
const { state } = this.store;
state.currentBoard = board;
state.assignees = [];
state.milestones = [];
}
updateWeight(newWeight, id) {
const { issue } = this.store.detail;
if (issue.id === id && issue.sidebarInfoEndpoint) {
......
......@@ -56,4 +56,35 @@ describe('BoardsStoreEE', () => {
});
});
});
describe('setCurrentBoard', () => {
const dummyBoard = 'skateboard';
it('sets the current board', () => {
const { state } = BoardsStoreEE.store;
state.currentBoard = null;
BoardsStoreEE.setCurrentBoard(dummyBoard);
expect(state.currentBoard).toEqual(dummyBoard);
});
it('resets assignees', () => {
const { state } = BoardsStoreEE.store;
state.assignees = 'some assignees';
BoardsStoreEE.setCurrentBoard(dummyBoard);
expect(state.assignees).toEqual([]);
});
it('resets milestones', () => {
const { state } = BoardsStoreEE.store;
state.milestones = 'some milestones';
BoardsStoreEE.setCurrentBoard(dummyBoard);
expect(state.milestones).toEqual([]);
});
});
});
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