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

113 lines
4.1 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';
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';
2019-12-26 22:10:19 +05:30
import store from '~/boards/stores';
2022-06-21 17:19:12 +05:30
import {
NavigationType,
isLoggedIn,
parseBoolean,
convertObjectPropsToCamelCase,
} from '~/lib/utils/common_utils';
import { queryToObject } from '~/lib/utils/url_utility';
2021-06-08 01:23:25 +05:30
import { fullBoardId } from './boards_util';
2021-11-18 22:05:49 +05:30
import { gqlClient } from './graphql';
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;
2022-06-21 17:19:12 +05:30
const rawFilterParams = queryToObject(window.location.search, { gatherArrays: true });
const initialFilterParams = {
...convertObjectPropsToCamelCase(rawFilterParams),
};
2022-05-07 20:08:51 +05:30
store.dispatch('fetchBoard', {
fullPath,
fullBoardId: fullBoardId(boardId),
boardType: el.dataset.parent,
});
2021-11-11 11:23:49 +05:30
store.dispatch('setInitialBoardData', {
boardId,
fullBoardId: fullBoardId(boardId),
fullPath,
boardType: el.dataset.parent,
disabled: parseBoolean(el.dataset.disabled) || true,
issuableType: issuableTypes.issue,
});
// eslint-disable-next-line no-new
new Vue({
el,
2022-04-04 11:22:00 +05:30
name: 'BoardAppRoot',
2021-11-11 11:23:49 +05:30
store,
apolloProvider,
provide: {
disabled: parseBoolean(el.dataset.disabled),
groupId: Number(groupId),
rootPath,
2022-06-21 17:19:12 +05:30
fullPath,
initialFilterParams,
boardBaseUrl: el.dataset.boardBaseUrl,
boardType: el.dataset.parent,
2021-11-11 11:23:49 +05:30
currentUserId: gon.current_user_id || null,
2022-06-21 17:19:12 +05:30
boardWeight: el.dataset.boardWeight ? parseInt(el.dataset.boardWeight, 10) : null,
2021-11-11 11:23:49 +05:30
labelsManagePath: el.dataset.labelsManagePath,
labelsFilterBasePath: el.dataset.labelsFilterBasePath,
2022-06-21 17:19:12 +05:30
releasesFetchPath: el.dataset.releasesFetchPath,
2021-11-11 11:23:49 +05:30
timeTrackingLimitToHours: parseBoolean(el.dataset.timeTrackingLimitToHours),
2022-06-21 17:19:12 +05:30
issuableType: issuableTypes.issue,
emailsDisabled: parseBoolean(el.dataset.emailsDisabled),
hasMissingBoards: parseBoolean(el.dataset.hasMissingBoards),
weights: el.dataset.weights ? JSON.parse(el.dataset.weights) : [],
// Permissions
canUpdate: parseBoolean(el.dataset.canUpdate),
canAdminList: parseBoolean(el.dataset.canAdminList),
canAdminBoard: parseBoolean(el.dataset.canAdminBoard),
allowLabelCreate: parseBoolean(el.dataset.canUpdate),
allowLabelEdit: parseBoolean(el.dataset.canUpdate),
isSignedIn: isLoggedIn(),
// Features
2021-11-11 11:23:49 +05:30
multipleAssigneesFeatureAvailable: parseBoolean(el.dataset.multipleAssigneesFeatureAvailable),
epicFeatureAvailable: parseBoolean(el.dataset.epicFeatureAvailable),
iterationFeatureAvailable: parseBoolean(el.dataset.iterationFeatureAvailable),
weightFeatureAvailable: parseBoolean(el.dataset.weightFeatureAvailable),
scopedLabelsAvailable: parseBoolean(el.dataset.scopedLabels),
milestoneListsAvailable: parseBoolean(el.dataset.milestoneListsAvailable),
assigneeListsAvailable: parseBoolean(el.dataset.assigneeListsAvailable),
iterationListsAvailable: parseBoolean(el.dataset.iterationListsAvailable),
2021-11-18 22:05:49 +05:30
allowScopedLabels: parseBoolean(el.dataset.scopedLabels),
2022-06-21 17:19:12 +05:30
swimlanesFeatureAvailable: gon.licensed_features?.swimlanes,
multipleIssueBoardsAvailable: parseBoolean(el.dataset.multipleBoardsAvailable),
scopedIssueBoardFeatureEnabled: parseBoolean(el.dataset.scopedIssueBoardFeatureEnabled),
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-11-11 11:23:49 +05:30
mountBoardApp($boardApp);
2018-03-27 19:54:05 +05:30
};