debian-mirror-gitlab/app/assets/javascripts/boards/stores/getters.js
2021-03-11 19:13:27 +05:30

44 lines
1.2 KiB
JavaScript

import { find } from 'lodash';
import { inactiveId } from '../constants';
export default {
isSidebarOpen: (state) => state.activeId !== inactiveId,
isSwimlanesOn: () => false,
getIssueById: (state) => (id) => {
return state.issues[id] || {};
},
getIssuesByList: (state, getters) => (listId) => {
const listIssueIds = state.issuesByListId[listId] || [];
return listIssueIds.map((id) => getters.getIssueById(id));
},
activeIssue: (state) => {
return state.issues[state.activeId] || {};
},
groupPathForActiveIssue: (_, getters) => {
const { referencePath = '' } = getters.activeIssue;
return referencePath.slice(0, referencePath.indexOf('/'));
},
projectPathForActiveIssue: (_, getters) => {
const { referencePath = '' } = getters.activeIssue;
return referencePath.slice(0, referencePath.indexOf('#'));
},
getListByLabelId: (state) => (labelId) => {
if (!labelId) {
return null;
}
return find(state.boardLists, (l) => l.label?.id === labelId);
},
getListByTitle: (state) => (title) => {
return find(state.boardLists, (l) => l.title === title);
},
shouldUseGraphQL: () => {
return gon?.features?.graphqlBoardLists;
},
};