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

64 lines
1.5 KiB
JavaScript
Raw Normal View History

2019-12-26 22:10:19 +05:30
import Vue from 'vue';
2020-05-24 23:13:21 +05:30
import VueApollo from 'vue-apollo';
import createDefaultClient from '~/lib/graphql';
import { parseBoolean } from '~/lib/utils/common_utils';
import IssuableListRootApp from './components/issuable_list_root_app.vue';
2019-12-26 22:10:19 +05:30
import IssuablesListApp from './components/issuables_list_app.vue';
2020-05-24 23:13:21 +05:30
function mountIssuableListRootApp() {
const el = document.querySelector('.js-projects-issues-root');
if (!el) {
return false;
}
Vue.use(VueApollo);
const defaultClient = createDefaultClient();
const apolloProvider = new VueApollo({
defaultClient,
});
return new Vue({
el,
apolloProvider,
render(createComponent) {
return createComponent(IssuableListRootApp, {
props: {
canEdit: parseBoolean(el.dataset.canEdit),
isJiraConfigured: parseBoolean(el.dataset.isJiraConfigured),
issuesPath: el.dataset.issuesPath,
projectPath: el.dataset.projectPath,
},
});
},
});
}
function mountIssuablesListApp() {
2020-07-28 23:09:34 +05:30
if (!gon.features?.vueIssuablesList && !gon.features?.jiraIssuesIntegration) {
2019-12-26 22:10:19 +05:30
return;
}
document.querySelectorAll('.js-issuables-list').forEach(el => {
const { canBulkEdit, ...data } = el.dataset;
return new Vue({
el,
render(createElement) {
2020-05-24 23:13:21 +05:30
return createElement(IssuablesListApp, {
props: {
...data,
canBulkEdit: Boolean(canBulkEdit),
},
});
2019-12-26 22:10:19 +05:30
},
});
});
}
2020-05-24 23:13:21 +05:30
export default function initIssuablesList() {
mountIssuableListRootApp();
mountIssuablesListApp();
}