From e57fd283db3b6501edad53a7acf45b5659f8a09d Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Fri, 1 May 2020 15:18:41 -0400 Subject: [PATCH] DEV: Rename `deprecated` to the more appropriate app-boot --- app/assets/javascripts/app-boot.js | 11 +++++++++++ app/assets/javascripts/application.js | 3 ++- app/assets/javascripts/deprecated.js | 4 ---- app/assets/javascripts/discourse/app/app.js | 17 +---------------- .../inject-discourse-objects.js | 5 ++--- lib/discourse_js_processor.rb | 1 + 6 files changed, 17 insertions(+), 24 deletions(-) create mode 100644 app/assets/javascripts/app-boot.js delete mode 100644 app/assets/javascripts/deprecated.js diff --git a/app/assets/javascripts/app-boot.js b/app/assets/javascripts/app-boot.js new file mode 100644 index 00000000000..d744e7f6493 --- /dev/null +++ b/app/assets/javascripts/app-boot.js @@ -0,0 +1,11 @@ +// discourse-skip-module + +(function() { + if (window.unsupportedBrowser) { + throw "Unsupported browser detected"; + } + let Discourse = requirejs("discourse/app").default; + + // ensure Discourse is added as a global + window.Discourse = Discourse; +})(); diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 489768d27db..d7f9c0d96b9 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -2,7 +2,7 @@ //= require ./polyfills //= require_tree ./select-kit //= require ./discourse/app/app -//= require ./deprecated +//= require ./app-boot // Stuff we need to load first //= require ./discourse/app/lib/to-markdown @@ -97,4 +97,5 @@ //= require_tree ./discourse/app/pre-initializers //= require_tree ./discourse/app/initializers //= require_tree ./discourse/app/services + //= require_tree ./discourse/app/widgets diff --git a/app/assets/javascripts/deprecated.js b/app/assets/javascripts/deprecated.js deleted file mode 100644 index 4ac91b826ac..00000000000 --- a/app/assets/javascripts/deprecated.js +++ /dev/null @@ -1,4 +0,0 @@ -// ensure Discourse is added as a global -(function() { - window.Discourse = requirejs("discourse/app").default; -})(); diff --git a/app/assets/javascripts/discourse/app/app.js b/app/assets/javascripts/discourse/app/app.js index 9de7c405380..8080da1af68 100644 --- a/app/assets/javascripts/discourse/app/app.js +++ b/app/assets/javascripts/discourse/app/app.js @@ -1,14 +1,9 @@ /*global Mousetrap:true*/ import Application from "@ember/application"; -import EmberObject, { computed } from "@ember/object"; +import { computed } from "@ember/object"; import { buildResolver } from "discourse-common/resolver"; import discourseComputed, { observes } from "discourse-common/utils/decorators"; import FocusEvent from "discourse-common/mixins/focus-event"; -import deprecated from "discourse-common/lib/deprecated"; - -if (window.unsupportedBrowser) { - throw "Unsupported browser detected"; -} const _pluginCallbacks = []; @@ -204,14 +199,4 @@ const Discourse = Application.extend(FocusEvent, { }) }).create(); -Object.defineProperty(Discourse, "Model", { - get() { - deprecated("Use an `@ember/object` instead of Discourse.Model", { - since: "2.4.0", - dropFrom: "2.5.0" - }); - return EmberObject; - } -}); - export default Discourse; diff --git a/app/assets/javascripts/discourse/app/pre-initializers/inject-discourse-objects.js b/app/assets/javascripts/discourse/app/pre-initializers/inject-discourse-objects.js index 58387204140..b41299712e2 100644 --- a/app/assets/javascripts/discourse/app/pre-initializers/inject-discourse-objects.js +++ b/app/assets/javascripts/discourse/app/pre-initializers/inject-discourse-objects.js @@ -2,7 +2,6 @@ import Session from "discourse/models/session"; import KeyValueStore from "discourse/lib/key-value-store"; import Store from "discourse/models/store"; import DiscourseLocation from "discourse/lib/discourse-location"; -import Discourse from "discourse/app"; import SearchService from "discourse/services/search"; import TopicTrackingState, { startTracking @@ -33,7 +32,7 @@ export default { const currentUser = User.current(); app.register("current-user:main", currentUser, { instantiate: false }); - Discourse.currentUser = currentUser; + app.currentUser = currentUser; const topicTrackingState = TopicTrackingState.create({ messageBus, @@ -46,7 +45,7 @@ export default { app.inject(t, "topicTrackingState", "topic-tracking-state:main") ); - const siteSettings = Discourse.SiteSettings; + const siteSettings = app.SiteSettings; app.register("site-settings:main", siteSettings, { instantiate: false }); ALL_TARGETS.forEach(t => app.inject(t, "siteSettings", "site-settings:main") diff --git a/lib/discourse_js_processor.rb b/lib/discourse_js_processor.rb index 08d271e8bc6..1aa140aebf1 100644 --- a/lib/discourse_js_processor.rb +++ b/lib/discourse_js_processor.rb @@ -57,6 +57,7 @@ class DiscourseJsProcessor activate-account auto-redirect embed-application + app-boot ).any? { |f| relative_path == "#{js_root}/#{f}.js" } return true if plugin_transpile_paths.any? { |prefix| relative_path.start_with?(prefix) }