From 48e3c385dc795db730cb4e9a4abf0800855b74b5 Mon Sep 17 00:00:00 2001 From: Angus McLeod Date: Tue, 1 Sep 2020 11:01:46 +1000 Subject: [PATCH] Require and setup the new Discourse initialization objects --- assets/javascripts/wizard-custom-lib.js | 6 +----- assets/javascripts/wizard-custom.js | 1 + .../javascripts/wizard/initializers/custom.js.es6 | 15 +++++++++++++-- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/assets/javascripts/wizard-custom-lib.js b/assets/javascripts/wizard-custom-lib.js index 14367cae..9767141d 100644 --- a/assets/javascripts/wizard-custom-lib.js +++ b/assets/javascripts/wizard-custom-lib.js @@ -4,8 +4,4 @@ Wizard.SiteSettings = {}; Wizard.RAW_TEMPLATES = {}; Discourse.__widget_helpers = {}; window.__DISCOURSE_RAW_TEMPLATES = {}; -Discourse.SiteSettings = Wizard.SiteSettings; - -define("bootbox", ["exports"], function(__exports__) { - __exports__.default = window.bootbox; -}); \ No newline at end of file +Discourse.SiteSettings = Wizard.SiteSettings; \ No newline at end of file diff --git a/assets/javascripts/wizard-custom.js b/assets/javascripts/wizard-custom.js index 1d400c20..7fedb2a2 100644 --- a/assets/javascripts/wizard-custom.js +++ b/assets/javascripts/wizard-custom.js @@ -124,6 +124,7 @@ //= require caret_position.js //= require popper.js //= require bootbox.js +//= require discourse-shims //= require ./wizard/custom-wizard //= require_tree ./wizard/components diff --git a/assets/javascripts/wizard/initializers/custom.js.es6 b/assets/javascripts/wizard/initializers/custom.js.es6 index 787d9903..8385e646 100644 --- a/assets/javascripts/wizard/initializers/custom.js.es6 +++ b/assets/javascripts/wizard/initializers/custom.js.es6 @@ -26,10 +26,13 @@ export default { const RawHandlebars = requirejs("discourse-common/lib/raw-handlebars").default; const Site = requirejs("discourse/plugins/discourse-custom-wizard/wizard/models/site").default; const RestAdapter = requirejs("discourse/adapters/rest").default; + const Session = requirejs("discourse/models/session").default; + const setDefaultOwner = requirejs("discourse-common/lib/get-owner").setDefaultOwner; + const container = app.__container__; Discourse.Model = EmberObject.extend(); - Discourse.__container__ = app.__container__; - + Discourse.__container__ = container; + setDefaultOwner(container); registerRawHelpers(RawHandlebars, Handlebars); // IE11 Polyfill - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/entries#Polyfill @@ -64,6 +67,14 @@ export default { targets.forEach(t => app.inject(t, "site", "site:main")); site.set('can_create_tag', false); + + let context = { + siteSettings: container.lookup("site-settings:main"), + currentUser: container.lookup("current-user:main"), + site: container.lookup("site:main"), + session: container.lookup("session:main"), + }; + createHelperContext(context); Router.reopen({ rootURL: getUrl('/w/')