2020-01-01 13:55:28 +05:30
|
|
|
import Vue from 'vue';
|
|
|
|
import VueApollo from 'vue-apollo';
|
|
|
|
import createDefaultClient from '~/lib/graphql';
|
|
|
|
|
2020-11-24 15:15:51 +05:30
|
|
|
import { SNIPPET_LEVELS_MAP, SNIPPET_VISIBILITY_PRIVATE } from '~/snippets/constants';
|
2021-03-11 19:13:27 +05:30
|
|
|
import Translate from '~/vue_shared/translate';
|
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-10-27 15:23:28 +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,
|
2021-11-18 22:05:49 +05:30
|
|
|
canReportSpam,
|
2021-10-27 15:23:28 +05:30
|
|
|
reportAbusePath,
|
2020-11-24 15:15:51 +05:30
|
|
|
...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,
|
2021-10-27 15:23:28 +05:30
|
|
|
reportAbusePath,
|
2021-11-18 22:05:49 +05:30
|
|
|
canReportSpam,
|
2020-11-24 15:15:51 +05:30
|
|
|
},
|
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
|
|
|
}
|