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

0% Statements 0/21
0% Branches 0/24
0% Functions 0/5
0% Lines 0/21

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 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138                                                                                                                                                                                                                                                                                   
import { IntrospectionFragmentMatcher } from 'apollo-cache-inmemory';
import Vue from 'vue';
import VueApollo from 'vue-apollo';
 
import initFilteredSearch from 'ee/boards/epic_filtered_search';
import { fullEpicBoardId } from 'ee_component/boards/boards_util';
import toggleLabels from 'ee_component/boards/toggle_labels';
 
import BoardAddNewColumnTrigger from '~/boards/components/board_add_new_column_trigger.vue';
import BoardApp from '~/boards/components/board_app.vue';
import boardConfigToggle from '~/boards/config_toggle';
import { issuableTypes } from '~/boards/constants';
import mountMultipleBoardsSwitcher from '~/boards/mount_multiple_boards_switcher';
import store from '~/boards/stores';
import createDefaultClient from '~/lib/graphql';
 
import '~/boards/filters/due_date_filters';
import { NavigationType, parseBoolean } from '~/lib/utils/common_utils';
import introspectionQueryResultData from '~/sidebar/fragmentTypes.json';
 
Vue.use(VueApollo);
 
const fragmentMatcher = new IntrospectionFragmentMatcher({
  introspectionQueryResultData,
});
 
const apolloProvider = new VueApollo({
  defaultClient: createDefaultClient(
    {},
    {
      cacheConfig: {
        fragmentMatcher,
      },
    },
  ),
});
 
function mountBoardApp(el) {
  const { boardId, groupId, fullPath, rootPath } = el.dataset;
 
  store.dispatch('setInitialBoardData', {
    allowSubEpics: parseBoolean(el.dataset.subEpicsFeatureAvailable),
    boardType: el.dataset.parent,
    disabled: parseBoolean(el.dataset.disabled) || true,
    issuableType: issuableTypes.epic,
    boardId,
    fullBoardId: fullEpicBoardId(boardId),
    fullPath,
    boardConfig: {
      milestoneId: parseInt(el.dataset.boardMilestoneId, 10),
      milestoneTitle: el.dataset.boardMilestoneTitle || '',
      iterationId: parseInt(el.dataset.boardIterationId, 10),
      iterationTitle: el.dataset.boardIterationTitle || '',
      assigneeId: el.dataset.boardAssigneeId,
      assigneeUsername: el.dataset.boardAssigneeUsername,
      labels: el.dataset.labels ? JSON.parse(el.dataset.labels) : [],
      labelIds: el.dataset.labelIds ? JSON.parse(el.dataset.labelIds) : [],
      weight: el.dataset.boardWeight ? parseInt(el.dataset.boardWeight, 10) : null,
    },
  });
 
  // eslint-disable-next-line no-new
  new Vue({
    el,
    store,
    apolloProvider,
    provide: {
      disabled: parseBoolean(el.dataset.disabled),
      boardId,
      groupId: parseInt(groupId, 10),
      rootPath,
      currentUserId: gon.current_user_id || null,
      canUpdate: parseBoolean(el.dataset.canUpdate),
      canAdminList: parseBoolean(el.dataset.canAdminList),
      labelsFetchPath: el.dataset.labelsFetchPath,
      labelsManagePath: el.dataset.labelsManagePath,
      labelsFilterBasePath: el.dataset.labelsFilterBasePath,
      timeTrackingLimitToHours: parseBoolean(el.dataset.timeTrackingLimitToHours),
      multipleAssigneesFeatureAvailable: parseBoolean(el.dataset.multipleAssigneesFeatureAvailable),
      epicFeatureAvailable: parseBoolean(el.dataset.epicFeatureAvailable),
      iterationFeatureAvailable: parseBoolean(el.dataset.iterationFeatureAvailable),
      weightFeatureAvailable: parseBoolean(el.dataset.weightFeatureAvailable),
      boardWeight: el.dataset.boardWeight ? parseInt(el.dataset.boardWeight, 10) : null,
      scopedLabelsAvailable: parseBoolean(el.dataset.scopedLabels),
      milestoneListsAvailable: false,
      assigneeListsAvailable: false,
      iterationListsAvailable: false,
      issuableType: issuableTypes.epic,
      emailsDisabled: parseBoolean(el.dataset.emailsDisabled),
      allowLabelCreate: parseBoolean(el.dataset.canUpdate),
      allowLabelEdit: parseBoolean(el.dataset.canUpdate),
      allowScopedLabels: parseBoolean(el.dataset.scopedLabels),
    },
    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();
    }
  });
 
  initFilteredSearch(apolloProvider);
 
  mountBoardApp($boardApp);
 
  const createColumnTriggerEl = document.querySelector('.js-create-column-trigger');
  if (createColumnTriggerEl) {
    // eslint-disable-next-line no-new
    new Vue({
      el: createColumnTriggerEl,
      components: {
        BoardAddNewColumnTrigger,
      },
      store,
      render(createElement) {
        return createElement(BoardAddNewColumnTrigger);
      },
    });
  }
 
  toggleLabels();
  boardConfigToggle();
 
  mountMultipleBoardsSwitcher({
    fullPath: $boardApp.dataset.fullPath,
    rootPath: $boardApp.dataset.boardsEndpoint,
  });
};