All files / ee/app/assets/javascripts/epic_boards index.js

0% Statements 0/14
0% Branches 0/10
0% Functions 0/4
0% Lines 0/14

Press n or j to go to the next uncovered block, b, p or k for the previous block.

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 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108                                                                                                                                                                                                                       
import Vue from 'vue';
import VueApollo from 'vue-apollo';
 
import { fullEpicBoardId } from 'ee_component/boards/boards_util';
 
import BoardApp from '~/boards/components/board_app.vue';
 
import '~/boards/filters/due_date_filters';
import {
  navigationType,
  isLoggedIn,
  parseBoolean,
  convertObjectPropsToCamelCase,
} from '~/lib/utils/common_utils';
import { defaultClient } from '~/graphql_shared/issuable_client';
import { TYPE_EPIC, WORKSPACE_GROUP, WORKSPACE_PROJECT } from '~/issues/constants';
import { queryToObject } from '~/lib/utils/url_utility';
 
Vue.use(VueApollo);
 
const apolloProvider = new VueApollo({
  defaultClient,
});
 
function mountBoardApp(el) {
  const { boardId, groupId, fullPath, rootPath } = el.dataset;
 
  const rawFilterParams = queryToObject(window.location.search, { gatherArrays: true });
 
  const initialFilterParams = {
    ...convertObjectPropsToCamelCase(rawFilterParams),
  };
 
  const boardType = el.dataset.parent;
 
  // eslint-disable-next-line no-new
  new Vue({
    el,
    name: 'BoardRoot',
    apolloProvider,
    provide: {
      initialBoardId: fullEpicBoardId(boardId),
      disabled: parseBoolean(el.dataset.disabled),
      boardId,
      groupId: parseInt(groupId, 10),
      rootPath,
      fullPath,
      initialFilterParams,
      boardBaseUrl: el.dataset.boardBaseUrl,
      boardType,
      isGroupBoard: boardType === WORKSPACE_GROUP,
      isProjectBoard: boardType === WORKSPACE_PROJECT,
      currentUserId: gon.current_user_id || null,
      labelsFetchPath: el.dataset.labelsFetchPath,
      labelsManagePath: el.dataset.labelsManagePath,
      labelsFilterBasePath: el.dataset.labelsFilterBasePath,
      timeTrackingLimitToHours: parseBoolean(el.dataset.timeTrackingLimitToHours),
      boardWeight: el.dataset.boardWeight ? parseInt(el.dataset.boardWeight, 10) : null,
      issuableType: TYPE_EPIC,
      emailsDisabled: parseBoolean(el.dataset.emailsDisabled),
      hasMissingBoards: parseBoolean(el.dataset.hasMissingBoards),
      weights: JSON.parse(el.dataset.weights),
      isIssueBoard: false,
      isEpicBoard: true,
      // Permissions
      canUpdate: parseBoolean(el.dataset.canUpdate),
      canAdminList: parseBoolean(el.dataset.canAdminList),
      canAdminBoard: parseBoolean(el.dataset.canAdminBoard),
      canCreateEpic: parseBoolean(el.dataset.canCreateEpic),
      allowLabelCreate: parseBoolean(el.dataset.canUpdate),
      allowLabelEdit: parseBoolean(el.dataset.canUpdate),
      allowScopedLabels: parseBoolean(el.dataset.scopedLabels),
      isSignedIn: isLoggedIn(),
      // Features
      multipleAssigneesFeatureAvailable: parseBoolean(el.dataset.multipleAssigneesFeatureAvailable),
      epicFeatureAvailable: parseBoolean(el.dataset.epicFeatureAvailable),
      iterationFeatureAvailable: parseBoolean(el.dataset.iterationFeatureAvailable),
      weightFeatureAvailable: parseBoolean(el.dataset.weightFeatureAvailable),
      healthStatusFeatureAvailable: parseBoolean(el.dataset.healthStatusFeatureAvailable),
      scopedLabelsAvailable: parseBoolean(el.dataset.scopedLabels),
      allowSubEpics: parseBoolean(el.dataset.subEpicsFeatureAvailable),
      milestoneListsAvailable: false,
      assigneeListsAvailable: false,
      iterationListsAvailable: false,
      swimlanesFeatureAvailable: false,
      multipleIssueBoardsAvailable: true,
      scopedIssueBoardFeatureEnabled: true,
    },
    render: (createComponent) => createComponent(BoardApp),
  });
}
 
export default () => {
  const $boardApp = document.getElementById('js-issuable-board-app');
 
  // check for browser back and trigger a hard reload to circumvent browser caching.
  window.addEventListener('pageshow', (event) => {
    const isNavTypeBackForward =
      window.performance && window.performance.navigation.type === navigationType.TYPE_BACK_FORWARD;
 
    if (event.persisted || isNavTypeBackForward) {
      window.location.reload();
    }
  });
 
  mountBoardApp($boardApp);
};