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

65 lines
2.1 KiB
JavaScript
Raw Normal View History

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';
2021-03-11 19:13:27 +05:30
import { mapGetters } from 'vuex';
2021-04-17 20:07:23 +05:30
import BoardsSelector from 'ee_else_ce/boards/components/boards_selector.vue';
2021-03-11 19:13:27 +05:30
import BoardsSelectorDeprecated from '~/boards/components/boards_selector_deprecated.vue';
import store from '~/boards/stores';
2020-04-08 14:13:33 +05:30
import createDefaultClient from '~/lib/graphql';
2019-09-30 21:07:59 +05:30
import { parseBoolean } from '~/lib/utils/common_utils';
2021-03-11 19:13:27 +05:30
import glFeatureFlagMixin from '~/vue_shared/mixins/gl_feature_flags_mixin';
2019-09-30 21:07:59 +05:30
2020-04-08 14:13:33 +05:30
Vue.use(VueApollo);
const apolloProvider = new VueApollo({
defaultClient: createDefaultClient(),
});
2021-03-08 18:12:59 +05:30
export default (params = {}) => {
2019-09-30 21:07:59 +05:30
const boardsSwitcherElement = document.getElementById('js-multiple-boards-switcher');
return new Vue({
el: boardsSwitcherElement,
components: {
BoardsSelector,
2021-03-11 19:13:27 +05:30
BoardsSelectorDeprecated,
2019-09-30 21:07:59 +05:30
},
2021-03-11 19:13:27 +05:30
mixins: [glFeatureFlagMixin()],
2020-04-08 14:13:33 +05:30
apolloProvider,
2021-03-11 19:13:27 +05:30
store,
2021-03-08 18:12:59 +05:30
provide: {
fullPath: params.fullPath,
rootPath: params.rootPath,
2021-03-11 19:13:27 +05:30
recentBoardsEndpoint: params.recentBoardsEndpoint,
2021-03-08 18:12:59 +05:30
},
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-03-11 19:13:27 +05:30
computed: {
2021-04-17 20:07:23 +05:30
...mapGetters(['shouldUseGraphQL', 'isEpicBoard']),
2021-03-11 19:13:27 +05:30
},
2019-09-30 21:07:59 +05:30
render(createElement) {
2021-04-17 20:07:23 +05:30
if (this.shouldUseGraphQL || this.isEpicBoard) {
2021-03-11 19:13:27 +05:30
return createElement(BoardsSelector, {
props: this.boardsSelectorProps,
});
}
return createElement(BoardsSelectorDeprecated, {
2019-09-30 21:07:59 +05:30
props: this.boardsSelectorProps,
});
},
});
};