2021-01-03 14:25:43 +05:30
|
|
|
import { find } from 'lodash';
|
2021-04-29 21:17:54 +05:30
|
|
|
import { BoardType, inactiveId, issuableTypes } from '../constants';
|
2020-11-24 15:15:51 +05:30
|
|
|
|
2019-12-26 22:10:19 +05:30
|
|
|
export default {
|
2021-04-17 20:07:23 +05:30
|
|
|
isGroupBoard: (state) => state.boardType === BoardType.group,
|
|
|
|
isProjectBoard: (state) => state.boardType === BoardType.project,
|
2021-03-08 18:12:59 +05:30
|
|
|
isSidebarOpen: (state) => state.activeId !== inactiveId,
|
2021-02-22 17:27:13 +05:30
|
|
|
isSwimlanesOn: () => false,
|
2021-04-17 20:07:23 +05:30
|
|
|
getBoardItemById: (state) => (id) => {
|
|
|
|
return state.boardItems[id] || {};
|
2020-11-24 15:15:51 +05:30
|
|
|
},
|
|
|
|
|
2021-04-17 20:07:23 +05:30
|
|
|
getBoardItemsByList: (state, getters) => (listId) => {
|
|
|
|
const listItemsIds = state.boardItemsByListId[listId] || [];
|
|
|
|
return listItemsIds.map((id) => getters.getBoardItemById(id));
|
2020-11-24 15:15:51 +05:30
|
|
|
},
|
|
|
|
|
2021-04-29 21:17:54 +05:30
|
|
|
activeBoardItem: (state) => {
|
2021-11-11 11:23:49 +05:30
|
|
|
return state.boardItems[state.activeId] || { iid: '', id: '' };
|
2020-11-24 15:15:51 +05:30
|
|
|
},
|
2021-01-03 14:25:43 +05:30
|
|
|
|
2021-03-11 19:13:27 +05:30
|
|
|
groupPathForActiveIssue: (_, getters) => {
|
2021-04-29 21:17:54 +05:30
|
|
|
const { referencePath = '' } = getters.activeBoardItem;
|
2021-06-08 01:23:25 +05:30
|
|
|
return referencePath.slice(0, referencePath.lastIndexOf('/'));
|
2021-03-11 19:13:27 +05:30
|
|
|
},
|
|
|
|
|
2021-01-29 00:20:46 +05:30
|
|
|
projectPathForActiveIssue: (_, getters) => {
|
2021-04-29 21:17:54 +05:30
|
|
|
const { referencePath = '' } = getters.activeBoardItem;
|
2021-01-29 00:20:46 +05:30
|
|
|
return referencePath.slice(0, referencePath.indexOf('#'));
|
|
|
|
},
|
|
|
|
|
2021-04-17 20:07:23 +05:30
|
|
|
activeGroupProjects: (state) => {
|
|
|
|
return state.groupProjects.filter((p) => !p.archived);
|
|
|
|
},
|
|
|
|
|
2021-03-08 18:12:59 +05:30
|
|
|
getListByLabelId: (state) => (labelId) => {
|
2021-03-11 19:13:27 +05:30
|
|
|
if (!labelId) {
|
|
|
|
return null;
|
|
|
|
}
|
2021-03-08 18:12:59 +05:30
|
|
|
return find(state.boardLists, (l) => l.label?.id === labelId);
|
2021-01-03 14:25:43 +05:30
|
|
|
},
|
|
|
|
|
2021-03-08 18:12:59 +05:30
|
|
|
getListByTitle: (state) => (title) => {
|
|
|
|
return find(state.boardLists, (l) => l.title === title);
|
2021-01-03 14:25:43 +05:30
|
|
|
},
|
|
|
|
|
2021-04-29 21:17:54 +05:30
|
|
|
isIssueBoard: (state) => {
|
|
|
|
return state.issuableType === issuableTypes.issue;
|
|
|
|
},
|
|
|
|
|
2021-04-17 20:07:23 +05:30
|
|
|
isEpicBoard: () => {
|
|
|
|
return false;
|
|
|
|
},
|
2019-12-26 22:10:19 +05:30
|
|
|
};
|