Commit af20774b authored by Paul Slaughter's avatar Paul Slaughter

Update IDE index.js with 'extendStore'

parent 435a3d2a
import Vue from 'vue'; import Vue from 'vue';
import { mapActions } from 'vuex'; import { mapActions } from 'vuex';
import _ from 'underscore';
import Translate from '~/vue_shared/translate'; import Translate from '~/vue_shared/translate';
import ide from './components/ide.vue'; import ide from './components/ide.vue';
import store from './stores'; import store from './stores';
...@@ -13,19 +14,19 @@ Vue.use(Translate); ...@@ -13,19 +14,19 @@ Vue.use(Translate);
* *
* @param {Element} el - The element that will contain the IDE. * @param {Element} el - The element that will contain the IDE.
* @param {Object} options - Extra options for the IDE (Used by EE). * @param {Object} options - Extra options for the IDE (Used by EE).
* @param {(e:Element) => Object} options.extraInitialData -
* Function that returns extra properties to seed initial data.
* @param {Component} options.rootComponent - * @param {Component} options.rootComponent -
* Component that overrides the root component. * Component that overrides the root component.
* @param {(store:Vuex.Store, el:Element) => Vuex.Store} options.extendStore -
* Function that receives the default store and returns an extended one.
*/ */
export function initIde(el, options = {}) { export function initIde(el, options = {}) {
if (!el) return null; if (!el) return null;
const { extraInitialData = () => ({}), rootComponent = ide } = options; const { rootComponent = ide, extendStore = _.identity } = options;
return new Vue({ return new Vue({
el, el,
store, store: extendStore(store, el),
router, router,
created() { created() {
this.setEmptyStateSvgs({ this.setEmptyStateSvgs({
...@@ -41,7 +42,6 @@ export function initIde(el, options = {}) { ...@@ -41,7 +42,6 @@ export function initIde(el, options = {}) {
}); });
this.setInitialData({ this.setInitialData({
clientsidePreviewEnabled: parseBoolean(el.dataset.clientsidePreviewEnabled), clientsidePreviewEnabled: parseBoolean(el.dataset.clientsidePreviewEnabled),
...extraInitialData(el),
}); });
}, },
methods: { methods: {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment