debian-mirror-gitlab/app/assets/javascripts/boards/stores/getters.js

45 lines
1.2 KiB
JavaScript
Raw Normal View History

2021-01-03 14:25:43 +05:30
import { find } from 'lodash';
2020-11-24 15:15:51 +05:30
import { inactiveId } from '../constants';
2019-12-26 22:10:19 +05:30
export default {
2021-03-08 18:12:59 +05:30
isSidebarOpen: (state) => state.activeId !== inactiveId,
2021-02-22 17:27:13 +05:30
isSwimlanesOn: () => false,
2021-03-08 18:12:59 +05:30
getIssueById: (state) => (id) => {
2020-11-24 15:15:51 +05:30
return state.issues[id] || {};
},
2021-03-08 18:12:59 +05:30
getIssuesByList: (state, getters) => (listId) => {
2020-11-24 15:15:51 +05:30
const listIssueIds = state.issuesByListId[listId] || [];
2021-03-08 18:12:59 +05:30
return listIssueIds.map((id) => getters.getIssueById(id));
2020-11-24 15:15:51 +05:30
},
2021-03-08 18:12:59 +05:30
activeIssue: (state) => {
2020-11-24 15:15:51 +05:30
return state.issues[state.activeId] || {};
},
2021-01-03 14:25:43 +05:30
2021-03-11 19:13:27 +05:30
groupPathForActiveIssue: (_, getters) => {
const { referencePath = '' } = getters.activeIssue;
return referencePath.slice(0, referencePath.indexOf('/'));
},
2021-01-29 00:20:46 +05:30
projectPathForActiveIssue: (_, getters) => {
2021-03-11 19:13:27 +05:30
const { referencePath = '' } = getters.activeIssue;
2021-01-29 00:20:46 +05:30
return referencePath.slice(0, referencePath.indexOf('#'));
},
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
},
shouldUseGraphQL: () => {
return gon?.features?.graphqlBoardLists;
},
2019-12-26 22:10:19 +05:30
};