2019-09-30 21:07:59 +05:30
|
|
|
import Vue from 'vue';
|
2020-04-08 14:13:33 +05:30
|
|
|
import VueApollo from 'vue-apollo';
|
|
|
|
import createDefaultClient from '~/lib/graphql';
|
2019-09-30 21:07:59 +05:30
|
|
|
import { parseBoolean } from '~/lib/utils/common_utils';
|
|
|
|
import BoardsSelector from '~/boards/components/boards_selector.vue';
|
|
|
|
|
2020-04-08 14:13:33 +05:30
|
|
|
Vue.use(VueApollo);
|
|
|
|
|
|
|
|
const apolloProvider = new VueApollo({
|
|
|
|
defaultClient: createDefaultClient(),
|
|
|
|
});
|
|
|
|
|
2021-02-22 17:27:13 +05:30
|
|
|
export default (endpoints = {}) => {
|
2019-09-30 21:07:59 +05:30
|
|
|
const boardsSwitcherElement = document.getElementById('js-multiple-boards-switcher');
|
|
|
|
return new Vue({
|
|
|
|
el: boardsSwitcherElement,
|
|
|
|
components: {
|
|
|
|
BoardsSelector,
|
|
|
|
},
|
2020-04-08 14:13:33 +05:30
|
|
|
apolloProvider,
|
2019-09-30 21:07:59 +05:30
|
|
|
data() {
|
|
|
|
const { dataset } = boardsSwitcherElement;
|
|
|
|
|
|
|
|
const boardsSelectorProps = {
|
|
|
|
...dataset,
|
|
|
|
currentBoard: JSON.parse(dataset.currentBoard),
|
|
|
|
hasMissingBoards: parseBoolean(dataset.hasMissingBoards),
|
|
|
|
canAdminBoard: parseBoolean(dataset.canAdminBoard),
|
|
|
|
multipleIssueBoardsAvailable: parseBoolean(dataset.multipleIssueBoardsAvailable),
|
2020-11-24 15:15:51 +05:30
|
|
|
projectId: dataset.projectId ? Number(dataset.projectId) : 0,
|
2019-09-30 21:07:59 +05:30
|
|
|
groupId: Number(dataset.groupId),
|
|
|
|
scopedIssueBoardFeatureEnabled: parseBoolean(dataset.scopedIssueBoardFeatureEnabled),
|
|
|
|
weights: JSON.parse(dataset.weights),
|
|
|
|
};
|
|
|
|
|
|
|
|
return { boardsSelectorProps };
|
|
|
|
},
|
2021-02-22 17:27:13 +05:30
|
|
|
provide: {
|
|
|
|
endpoints,
|
|
|
|
},
|
2019-09-30 21:07:59 +05:30
|
|
|
render(createElement) {
|
|
|
|
return createElement(BoardsSelector, {
|
|
|
|
props: this.boardsSelectorProps,
|
|
|
|
});
|
|
|
|
},
|
|
|
|
});
|
|
|
|
};
|