2022-08-13 15:12:31 +05:30
|
|
|
import Vue from 'vue';
|
2022-08-27 11:52:29 +05:30
|
|
|
import VueApollo from 'vue-apollo';
|
2022-08-13 15:12:31 +05:30
|
|
|
import ResourceLinksBlock from 'ee_component/linked_resources/components/resource_links_block.vue';
|
2022-08-27 11:52:29 +05:30
|
|
|
import createDefaultClient from '~/lib/graphql';
|
2022-08-13 15:12:31 +05:30
|
|
|
import { parseBoolean } from '~/lib/utils/common_utils';
|
|
|
|
|
2022-08-27 11:52:29 +05:30
|
|
|
Vue.use(VueApollo);
|
|
|
|
|
2022-08-13 15:12:31 +05:30
|
|
|
export default function initLinkedResources() {
|
|
|
|
const linkedResourcesRootElement = document.querySelector('.js-linked-resources-root');
|
|
|
|
|
|
|
|
if (linkedResourcesRootElement) {
|
|
|
|
const { issuableId, canAddResourceLinks, helpPath } = linkedResourcesRootElement.dataset;
|
|
|
|
|
2022-08-27 11:52:29 +05:30
|
|
|
const apolloProvider = new VueApollo({
|
|
|
|
defaultClient: createDefaultClient(),
|
|
|
|
});
|
|
|
|
|
2022-08-13 15:12:31 +05:30
|
|
|
// eslint-disable-next-line no-new
|
|
|
|
new Vue({
|
|
|
|
el: linkedResourcesRootElement,
|
|
|
|
name: 'LinkedResourcesRoot',
|
2022-08-27 11:52:29 +05:30
|
|
|
apolloProvider,
|
2022-08-13 15:12:31 +05:30
|
|
|
components: {
|
|
|
|
resourceLinksBlock: ResourceLinksBlock,
|
|
|
|
},
|
|
|
|
render: (createElement) =>
|
|
|
|
createElement('resource-links-block', {
|
|
|
|
props: {
|
|
|
|
helpPath,
|
2022-08-27 11:52:29 +05:30
|
|
|
issuableId: parseInt(issuableId, 10),
|
2022-08-13 15:12:31 +05:30
|
|
|
canAddResourceLinks: parseBoolean(canAddResourceLinks),
|
|
|
|
},
|
|
|
|
}),
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|