summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhil Hughes <me@iamphill.com>2018-09-25 08:10:09 +0000
committerPhil Hughes <me@iamphill.com>2018-09-25 08:10:09 +0000
commit3d8ae6a8576dcac0fd3aa0e5b00ef735635fdb07 (patch)
treef3051030ee149fdd232c897b3bd585fb2441e839
parentbb28ffab9cb5ff703e170c0d41029abefd463bde (diff)
parentd9bb488a1e4f02995ce585fe7c5c8460d202e543 (diff)
downloadgitlab-ce-3d8ae6a8576dcac0fd3aa0e5b00ef735635fdb07.tar.gz
Merge branch 'ide-refactor-for-ee-specific' into 'master'
Refactor IDE index to support EE specific code See merge request gitlab-org/gitlab-ce!21895
-rw-r--r--app/assets/javascripts/ide/index.js30
-rw-r--r--app/assets/javascripts/pages/ide/index.js10
2 files changed, 31 insertions, 9 deletions
diff --git a/app/assets/javascripts/ide/index.js b/app/assets/javascripts/ide/index.js
index 79e38ae911e..c90f8694326 100644
--- a/app/assets/javascripts/ide/index.js
+++ b/app/assets/javascripts/ide/index.js
@@ -8,9 +8,21 @@ import { convertPermissionToBoolean } from '../lib/utils/common_utils';
Vue.use(Translate);
-export function initIde(el) {
+/**
+ * Initialize the IDE on the given element.
+ *
+ * @param {Element} el - The element that will contain the IDE.
+ * @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.
+ */
+export function initIde(el, options = {}) {
if (!el) return null;
+ const {
+ extraInitialData = () => ({}),
+ } = options;
+
return new Vue({
el,
store,
@@ -32,6 +44,7 @@ export function initIde(el) {
});
this.setInitialData({
clientsidePreviewEnabled: convertPermissionToBoolean(el.dataset.clientsidePreviewEnabled),
+ ...extraInitialData(el),
});
},
methods: {
@@ -52,3 +65,18 @@ export function resetServiceWorkersPublicPath() {
const webpackAssetPath = `${relativeRootPath}/assets/webpack/`;
__webpack_public_path__ = webpackAssetPath; // eslint-disable-line camelcase
}
+
+/**
+ * Start the IDE.
+ *
+ * @param {Objects} options - Extra options for the IDE (Used by EE).
+ */
+export function startIde(options) {
+ document.addEventListener('DOMContentLoaded', () => {
+ const ideElement = document.getElementById('ide');
+ if (ideElement) {
+ resetServiceWorkersPublicPath();
+ initIde(ideElement, options);
+ }
+ });
+}
diff --git a/app/assets/javascripts/pages/ide/index.js b/app/assets/javascripts/pages/ide/index.js
index efadf6967aa..d192df3561e 100644
--- a/app/assets/javascripts/pages/ide/index.js
+++ b/app/assets/javascripts/pages/ide/index.js
@@ -1,9 +1,3 @@
-import { initIde, resetServiceWorkersPublicPath } from '~/ide/index';
+import { startIde } from '~/ide/index';
-document.addEventListener('DOMContentLoaded', () => {
- const ideElement = document.getElementById('ide');
- if (ideElement) {
- resetServiceWorkersPublicPath();
- initIde(ideElement);
- }
-});
+startIde();