debian-mirror-gitlab/app/assets/javascripts/boards/index.js

151 lines
5.5 KiB
JavaScript
Raw Normal View History

2021-09-30 23:02:18 +05:30
import PortalVue from 'portal-vue';
2017-08-17 22:00:37 +05:30
import Vue from 'vue';
2021-03-11 19:13:27 +05:30
import VueApollo from 'vue-apollo';
2018-03-27 19:54:05 +05:30
2021-03-11 19:13:27 +05:30
import toggleEpicsSwimlanes from 'ee_else_ce/boards/toggle_epics_swimlanes';
import toggleLabels from 'ee_else_ce/boards/toggle_labels';
import BoardAddNewColumnTrigger from '~/boards/components/board_add_new_column_trigger.vue';
2021-11-11 11:23:49 +05:30
import BoardApp from '~/boards/components/board_app.vue';
2021-03-11 19:13:27 +05:30
import '~/boards/filters/due_date_filters';
2021-04-17 20:07:23 +05:30
import { issuableTypes } from '~/boards/constants';
2021-03-11 19:13:27 +05:30
import eventHub from '~/boards/eventhub';
import FilteredSearchBoards from '~/boards/filtered_search_boards';
2021-09-30 23:02:18 +05:30
import initBoardsFilteredSearch from '~/boards/mount_filtered_search_issue_boards';
2019-12-26 22:10:19 +05:30
import store from '~/boards/stores';
2021-03-11 19:13:27 +05:30
import toggleFocusMode from '~/boards/toggle_focus';
2021-12-11 22:18:48 +05:30
import { NavigationType, isLoggedIn, parseBoolean } from '~/lib/utils/common_utils';
2021-06-08 01:23:25 +05:30
import { fullBoardId } from './boards_util';
2021-04-17 20:07:23 +05:30
import boardConfigToggle from './config_toggle';
2021-12-11 22:18:48 +05:30
import initNewBoard from './new_board';
2021-11-18 22:05:49 +05:30
import { gqlClient } from './graphql';
2019-09-30 21:07:59 +05:30
import mountMultipleBoardsSwitcher from './mount_multiple_boards_switcher';
2020-05-24 23:13:21 +05:30
Vue.use(VueApollo);
2021-09-30 23:02:18 +05:30
Vue.use(PortalVue);
2020-05-24 23:13:21 +05:30
const apolloProvider = new VueApollo({
2021-11-18 22:05:49 +05:30
defaultClient: gqlClient,
2020-05-24 23:13:21 +05:30
});
2017-08-17 22:00:37 +05:30
2021-11-11 11:23:49 +05:30
function mountBoardApp(el) {
const { boardId, groupId, fullPath, rootPath } = el.dataset;
store.dispatch('setInitialBoardData', {
boardId,
fullBoardId: fullBoardId(boardId),
fullPath,
boardType: el.dataset.parent,
disabled: parseBoolean(el.dataset.disabled) || true,
issuableType: issuableTypes.issue,
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,
},
});
if (!gon?.features?.issueBoardsFilteredSearch) {
// Warning: FilteredSearchBoards has an implicit dependency on the Vuex state 'boardConfig'
// Improve this situation in the future.
const filterManager = new FilteredSearchBoards({ path: '' }, true, []);
filterManager.setup();
eventHub.$on('updateTokens', () => {
filterManager.updateTokens();
});
}
// eslint-disable-next-line no-new
new Vue({
el,
store,
apolloProvider,
provide: {
disabled: parseBoolean(el.dataset.disabled),
boardId,
groupId: Number(groupId),
rootPath,
currentUserId: gon.current_user_id || null,
canUpdate: parseBoolean(el.dataset.canUpdate),
canAdminList: parseBoolean(el.dataset.canAdminList),
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: parseBoolean(el.dataset.milestoneListsAvailable),
assigneeListsAvailable: parseBoolean(el.dataset.assigneeListsAvailable),
iterationListsAvailable: parseBoolean(el.dataset.iterationListsAvailable),
issuableType: issuableTypes.issue,
emailsDisabled: parseBoolean(el.dataset.emailsDisabled),
2021-11-18 22:05:49 +05:30
allowLabelCreate: parseBoolean(el.dataset.canUpdate),
allowLabelEdit: parseBoolean(el.dataset.canUpdate),
allowScopedLabels: parseBoolean(el.dataset.scopedLabels),
2021-11-11 11:23:49 +05:30
},
render: (createComponent) => createComponent(BoardApp),
});
}
2018-12-13 13:39:08 +05:30
2018-03-27 19:54:05 +05:30
export default () => {
2021-11-11 11:23:49 +05:30
const $boardApp = document.getElementById('js-issuable-board-app');
2018-12-05 23:21:45 +05:30
// check for browser back and trigger a hard reload to circumvent browser caching.
2021-03-08 18:12:59 +05:30
window.addEventListener('pageshow', (event) => {
2018-12-13 13:39:08 +05:30
const isNavTypeBackForward =
window.performance && window.performance.navigation.type === NavigationType.TYPE_BACK_FORWARD;
2018-12-05 23:21:45 +05:30
if (event.persisted || isNavTypeBackForward) {
window.location.reload();
}
});
2021-09-30 23:02:18 +05:30
if (gon?.features?.issueBoardsFilteredSearch) {
2021-12-11 22:18:48 +05:30
initBoardsFilteredSearch(apolloProvider, isLoggedIn());
2021-09-30 23:02:18 +05:30
}
2021-11-11 11:23:49 +05:30
mountBoardApp($boardApp);
2017-08-17 22:00:37 +05:30
2021-03-11 19:13:27 +05:30
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('board-add-new-column-trigger');
},
});
}
2021-11-11 11:23:49 +05:30
boardConfigToggle();
2021-12-11 22:18:48 +05:30
initNewBoard();
2019-09-30 21:07:59 +05:30
2021-04-29 21:17:54 +05:30
toggleFocusMode();
2019-12-26 22:10:19 +05:30
toggleLabels();
2021-01-03 14:25:43 +05:30
2021-04-17 20:07:23 +05:30
if (gon.licensed_features?.swimlanes) {
2021-01-03 14:25:43 +05:30
toggleEpicsSwimlanes();
}
2021-02-22 17:27:13 +05:30
mountMultipleBoardsSwitcher({
2021-03-08 18:12:59 +05:30
fullPath: $boardApp.dataset.fullPath,
rootPath: $boardApp.dataset.boardsEndpoint,
2021-03-11 19:13:27 +05:30
recentBoardsEndpoint: $boardApp.dataset.recentBoardsEndpoint,
2021-12-11 22:18:48 +05:30
allowScopedLabels: $boardApp.dataset.scopedLabels,
labelsManagePath: $boardApp.dataset.labelsManagePath,
2021-02-22 17:27:13 +05:30
});
2018-03-27 19:54:05 +05:30
};