Welcome to mirror list, hosted at ThFree Co, Russian Federation.

getters.js « stores « boards « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: cd28b4a0ff7a78fb0e97349f3771411345576959 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import { find } from 'lodash';
import { inactiveId } from '../constants';

export default {
  labelToggleState: state => (state.isShowingLabels ? 'on' : 'off'),
  isSidebarOpen: state => state.activeId !== inactiveId,
  isSwimlanesOn: state => {
    if (!gon?.features?.boardsWithSwimlanes && !gon?.features?.swimlanes) {
      return false;
    }

    return state.isShowingEpicsSwimlanes;
  },
  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] || {};
  },

  projectPathForActiveIssue: (_, getters) => {
    const referencePath = getters.activeIssue.referencePath || '';
    return referencePath.slice(0, referencePath.indexOf('#'));
  },

  getListByLabelId: state => labelId => {
    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;
  },
};