2019-12-13 13:08:06 -05:00
|
|
|
import Vue from 'vue';
|
|
|
|
import VueApollo from 'vue-apollo';
|
|
|
|
import createDefaultClient from '~/lib/graphql';
|
|
|
|
|
2020-09-04 20:08:43 -04:00
|
|
|
import { SNIPPET_LEVELS_MAP, SNIPPET_VISIBILITY_PRIVATE } from '~/snippets/constants';
|
2021-02-14 13:09:20 -05:00
|
|
|
import Translate from '~/vue_shared/translate';
|
2019-12-13 13:08:06 -05:00
|
|
|
|
|
|
|
Vue.use(VueApollo);
|
|
|
|
Vue.use(Translate);
|
|
|
|
|
2020-10-19 08:09:20 -04:00
|
|
|
export default function appFactory(el, Component) {
|
2019-12-13 13:08:06 -05:00
|
|
|
if (!el) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
const apolloProvider = new VueApollo({
|
2021-08-04 08:10:30 -04:00
|
|
|
defaultClient: createDefaultClient(
|
|
|
|
{},
|
|
|
|
{
|
|
|
|
batchMax: 1,
|
|
|
|
},
|
|
|
|
),
|
2019-12-13 13:08:06 -05:00
|
|
|
});
|
|
|
|
|
2020-09-04 20:08:43 -04:00
|
|
|
const {
|
|
|
|
visibilityLevels = '[]',
|
|
|
|
selectedLevel,
|
|
|
|
multipleLevelsRestricted,
|
2021-10-08 02:11:46 -04:00
|
|
|
canReportSpam,
|
2021-08-09 20:10:29 -04:00
|
|
|
reportAbusePath,
|
2020-09-04 20:08:43 -04:00
|
|
|
...restDataset
|
|
|
|
} = el.dataset;
|
|
|
|
|
2020-11-03 10:09:05 -05:00
|
|
|
return new Vue({
|
|
|
|
el,
|
|
|
|
apolloProvider,
|
|
|
|
provide: {
|
2020-09-04 20:08:43 -04:00
|
|
|
visibilityLevels: JSON.parse(visibilityLevels),
|
|
|
|
selectedLevel: SNIPPET_LEVELS_MAP[selectedLevel] ?? SNIPPET_VISIBILITY_PRIVATE,
|
|
|
|
multipleLevelsRestricted: 'multipleLevelsRestricted' in el.dataset,
|
2021-08-09 20:10:29 -04:00
|
|
|
reportAbusePath,
|
2021-10-08 02:11:46 -04:00
|
|
|
canReportSpam,
|
2020-09-04 20:08:43 -04:00
|
|
|
},
|
2019-12-13 13:08:06 -05:00
|
|
|
render(createElement) {
|
2020-03-24 11:08:44 -04:00
|
|
|
return createElement(Component, {
|
2019-12-13 13:08:06 -05:00
|
|
|
props: {
|
2020-09-04 20:08:43 -04:00
|
|
|
...restDataset,
|
2019-12-13 13:08:06 -05:00
|
|
|
},
|
|
|
|
});
|
|
|
|
},
|
|
|
|
});
|
2020-03-24 11:08:44 -04:00
|
|
|
}
|