2020-01-01 13:55:28 +05:30
|
|
|
import Vue from 'vue';
|
|
|
|
import VueApollo from 'vue-apollo';
|
2020-10-24 23:57:45 +05:30
|
|
|
import Translate from '~/vue_shared/translate';
|
2020-01-01 13:55:28 +05:30
|
|
|
import createDefaultClient from '~/lib/graphql';
|
|
|
|
|
2020-11-24 15:15:51 +05:30
|
|
|
import { SNIPPET_LEVELS_MAP, SNIPPET_VISIBILITY_PRIVATE } from '~/snippets/constants';
|
2020-01-01 13:55:28 +05:30
|
|
|
|
|
|
|
Vue.use(VueApollo);
|
|
|
|
Vue.use(Translate);
|
|
|
|
|
2021-01-03 14:25:43 +05:30
|
|
|
export default function appFactory(el, Component) {
|
2020-01-01 13:55:28 +05:30
|
|
|
if (!el) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
const apolloProvider = new VueApollo({
|
2021-01-03 14:25:43 +05:30
|
|
|
defaultClient: createDefaultClient({}, { batchMax: 1 }),
|
2020-01-01 13:55:28 +05:30
|
|
|
});
|
|
|
|
|
2020-11-24 15:15:51 +05:30
|
|
|
const {
|
|
|
|
visibilityLevels = '[]',
|
|
|
|
selectedLevel,
|
|
|
|
multipleLevelsRestricted,
|
|
|
|
...restDataset
|
|
|
|
} = el.dataset;
|
|
|
|
|
2021-01-29 00:20:46 +05:30
|
|
|
return new Vue({
|
|
|
|
el,
|
|
|
|
apolloProvider,
|
|
|
|
provide: {
|
2020-11-24 15:15:51 +05:30
|
|
|
visibilityLevels: JSON.parse(visibilityLevels),
|
|
|
|
selectedLevel: SNIPPET_LEVELS_MAP[selectedLevel] ?? SNIPPET_VISIBILITY_PRIVATE,
|
|
|
|
multipleLevelsRestricted: 'multipleLevelsRestricted' in el.dataset,
|
|
|
|
},
|
2020-01-01 13:55:28 +05:30
|
|
|
render(createElement) {
|
2020-04-22 19:07:51 +05:30
|
|
|
return createElement(Component, {
|
2020-01-01 13:55:28 +05:30
|
|
|
props: {
|
2020-11-24 15:15:51 +05:30
|
|
|
...restDataset,
|
2020-01-01 13:55:28 +05:30
|
|
|
},
|
|
|
|
});
|
|
|
|
},
|
|
|
|
});
|
2020-04-22 19:07:51 +05:30
|
|
|
}
|