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