From 9ffdbf912f76dcc58d081ce1f0c41afa0e40d500 Mon Sep 17 00:00:00 2001 From: Mark VanLandingham Date: Thu, 7 Nov 2019 11:20:35 -0600 Subject: [PATCH] DEV: Import ember ENV instead of Ember.testing (#8305) --- .../javascripts/admin/components/admin-report.js.es6 | 5 +++-- .../admin/components/themes-list-item.js.es6 | 3 ++- .../javascripts/admin/components/themes-list.js.es6 | 3 ++- .../admin/routes/admin-badges-show.js.es6 | 3 ++- .../discourse-common/config/environment.js.es6 | 1 + app/assets/javascripts/discourse-loader.js | 3 +++ .../discourse/components/composer-editor.js.es6 | 3 ++- .../discourse/components/composer-title.js.es6 | 3 ++- .../javascripts/discourse/components/d-button.js.es6 | 4 ++-- .../javascripts/discourse/components/d-editor.js.es6 | 3 ++- .../discourse/components/date-time-input.js.es6 | 1 + .../discourse/components/emoji-picker.js.es6 | 4 +++- .../discourse/components/topic-timer-info.js.es6 | 3 ++- .../discourse/components/user-card-contents.js.es6 | 3 ++- .../discourse/controllers/composer.js.es6 | 3 ++- .../javascripts/discourse/controllers/topic.js.es6 | 3 ++- .../discourse/initializers/live-development.js.es6 | 3 ++- .../initializers/subscribe-user-notifications.js.es6 | 3 ++- .../javascripts/discourse/lib/click-track.js.es6 | 3 ++- .../discourse/lib/desktop-notifications.js.es6 | 12 ++++++++---- app/assets/javascripts/discourse/lib/eyeline.js.es6 | 6 ++++-- app/assets/javascripts/discourse/lib/mobile.js.es6 | 3 ++- .../lib/register-topic-footer-button.js.es6 | 6 ++++-- .../javascripts/discourse/mapping-router.js.es6 | 3 ++- .../javascripts/discourse/mixins/scroll-top.js.es6 | 3 ++- .../discourse/routes/topic-from-params.js.es6 | 3 ++- .../javascripts/discourse/widgets/connector.js.es6 | 4 ++-- app/assets/javascripts/discourse/widgets/glue.js.es6 | 3 ++- .../javascripts/discourse/widgets/post-menu.js.es6 | 3 ++- .../javascripts/discourse/widgets/widget.js.es6 | 3 ++- app/assets/javascripts/locales/i18n.js | 3 ++- app/assets/javascripts/wizard/router.js.es6 | 3 ++- 32 files changed, 75 insertions(+), 37 deletions(-) create mode 100644 app/assets/javascripts/discourse-common/config/environment.js.es6 diff --git a/app/assets/javascripts/admin/components/admin-report.js.es6 b/app/assets/javascripts/admin/components/admin-report.js.es6 index db06feecfce..59aaf29c3be 100644 --- a/app/assets/javascripts/admin/components/admin-report.js.es6 +++ b/app/assets/javascripts/admin/components/admin-report.js.es6 @@ -9,6 +9,7 @@ import { outputExportResult } from "discourse/lib/export-result"; import { isNumeric } from "discourse/lib/utilities"; import { SCHEMA_VERSION, default as Report } from "admin/models/report"; import computed from "ember-addons/ember-computed-decorators"; +import ENV from "discourse-common/config/environment"; const TABLE_OPTIONS = { perPage: 8, @@ -162,8 +163,8 @@ export default Component.extend({ let reportKey = "reports:"; reportKey += [ dataSourceName, - Ember.testing ? "start" : startDate.replace(/-/g, ""), - Ember.testing ? "end" : endDate.replace(/-/g, ""), + ENV.environment === "test" ? "start" : startDate.replace(/-/g, ""), + ENV.environment === "test" ? "end" : endDate.replace(/-/g, ""), "[:prev_period]", this.get("reportOptions.table.limit"), customFilters diff --git a/app/assets/javascripts/admin/components/themes-list-item.js.es6 b/app/assets/javascripts/admin/components/themes-list-item.js.es6 index af30e5a3987..06ee549d51a 100644 --- a/app/assets/javascripts/admin/components/themes-list-item.js.es6 +++ b/app/assets/javascripts/admin/components/themes-list-item.js.es6 @@ -7,6 +7,7 @@ import { } from "ember-addons/ember-computed-decorators"; import { iconHTML } from "discourse-common/lib/icon-library"; import { escape } from "pretty-text/sanitizer"; +import ENV from "discourse-common/config/environment"; const MAX_COMPONENTS = 4; @@ -43,7 +44,7 @@ export default Component.extend({ animate(isInitial) { const $container = $(this.element); const $list = $(this.element.querySelector(".components-list")); - if ($list.length === 0 || Ember.testing) { + if ($list.length === 0 || ENV.environment === 'test') { return; } const duration = 300; diff --git a/app/assets/javascripts/admin/components/themes-list.js.es6 b/app/assets/javascripts/admin/components/themes-list.js.es6 index 357e4f756c5..1a420eeba81 100644 --- a/app/assets/javascripts/admin/components/themes-list.js.es6 +++ b/app/assets/javascripts/admin/components/themes-list.js.es6 @@ -2,6 +2,7 @@ import { gt, equal } from "@ember/object/computed"; import Component from "@ember/component"; import { THEMES, COMPONENTS } from "admin/models/theme"; import { default as computed } from "ember-addons/ember-computed-decorators"; +import { getOwner } from "@ember/application"; export default Component.extend({ THEMES: THEMES, @@ -70,7 +71,7 @@ export default Component.extend({ } }, navigateToTheme(theme) { - Ember.getOwner(this) + getOwner(this) .lookup("router:main") .transitionTo("adminCustomizeThemes.show", theme); } diff --git a/app/assets/javascripts/admin/routes/admin-badges-show.js.es6 b/app/assets/javascripts/admin/routes/admin-badges-show.js.es6 index 36043f60964..64ef45aebe5 100644 --- a/app/assets/javascripts/admin/routes/admin-badges-show.js.es6 +++ b/app/assets/javascripts/admin/routes/admin-badges-show.js.es6 @@ -51,7 +51,8 @@ export default Route.extend({ }) .catch(function(error) { badge.set("preview_loading", false); - Ember.Logger.error(error); + // eslint-disable-next-line no-console + console.error(error); bootbox.alert("Network error"); }); } diff --git a/app/assets/javascripts/discourse-common/config/environment.js.es6 b/app/assets/javascripts/discourse-common/config/environment.js.es6 new file mode 100644 index 00000000000..3bfa2c38c58 --- /dev/null +++ b/app/assets/javascripts/discourse-common/config/environment.js.es6 @@ -0,0 +1 @@ +export default { environment: Ember.testing ? "test" : "development" }; diff --git a/app/assets/javascripts/discourse-loader.js b/app/assets/javascripts/discourse-loader.js index 5052771e910..cb402832e86 100644 --- a/app/assets/javascripts/discourse-loader.js +++ b/app/assets/javascripts/discourse-loader.js @@ -96,6 +96,9 @@ var define, requirejs; }, "@ember/component/helper": { default: Ember.Helper + }, + "@ember/error": { + default: Ember.error } }; } diff --git a/app/assets/javascripts/discourse/components/composer-editor.js.es6 b/app/assets/javascripts/discourse/components/composer-editor.js.es6 index 876851b6588..d1aa32d0463 100644 --- a/app/assets/javascripts/discourse/components/composer-editor.js.es6 +++ b/app/assets/javascripts/discourse/components/composer-editor.js.es6 @@ -48,6 +48,7 @@ import { INLINE_ONEBOX_LOADING_CSS_CLASS, INLINE_ONEBOX_CSS_CLASS } from "pretty-text/context/inline-onebox-css-classes"; +import ENV from "discourse-common/config/environment"; const REBUILD_SCROLL_MAP_EVENTS = ["composer:resized", "composer:typed-reply"]; @@ -911,7 +912,7 @@ export default Component.extend({ // need to wait a bit for the "slide down" transition of the composer later( () => this.appEvents.trigger("composer:closed"), - Ember.testing ? 0 : 400 + ENV.environment === "test" ? 0 : 400 ); }); diff --git a/app/assets/javascripts/discourse/components/composer-title.js.es6 b/app/assets/javascripts/discourse/components/composer-title.js.es6 index 556b24bda86..ecbe5216bc0 100644 --- a/app/assets/javascripts/discourse/components/composer-title.js.es6 +++ b/app/assets/javascripts/discourse/components/composer-title.js.es6 @@ -12,6 +12,7 @@ import { load } from "pretty-text/oneboxer"; import { lookupCache } from "pretty-text/oneboxer-cache"; import { ajax } from "discourse/lib/ajax"; import afterTransition from "discourse/lib/after-transition"; +import ENV from "discourse-common/config/environment"; export default Component.extend({ classNames: ["title-input"], @@ -83,7 +84,7 @@ export default Component.extend({ return; } - if (Ember.testing) { + if (ENV.environment === "test") { next(() => // not ideal but we don't want to run this in current // runloop to avoid an error in console diff --git a/app/assets/javascripts/discourse/components/d-button.js.es6 b/app/assets/javascripts/discourse/components/d-button.js.es6 index 359d058d24c..130e4ae4588 100644 --- a/app/assets/javascripts/discourse/components/d-button.js.es6 +++ b/app/assets/javascripts/discourse/components/d-button.js.es6 @@ -1,4 +1,4 @@ -import { notEmpty, empty } from "@ember/object/computed"; +import { notEmpty, empty, equal } from "@ember/object/computed"; import Component from "@ember/component"; import { default as computed } from "ember-addons/ember-computed-decorators"; import DiscourseURL from "discourse/lib/url"; @@ -24,7 +24,7 @@ export default Component.extend({ btnIcon: notEmpty("icon"), - btnLink: Ember.computed.equal("display", "link"), + btnLink: equal("display", "link"), @computed("icon", "translatedLabel") btnType(icon, translatedLabel) { diff --git a/app/assets/javascripts/discourse/components/d-editor.js.es6 b/app/assets/javascripts/discourse/components/d-editor.js.es6 index 3d926b97837..b60fdf88a30 100644 --- a/app/assets/javascripts/discourse/components/d-editor.js.es6 +++ b/app/assets/javascripts/discourse/components/d-editor.js.es6 @@ -30,6 +30,7 @@ import { emojiSearch, isSkinTonableEmoji } from "pretty-text/emoji"; import { emojiUrlFor } from "discourse/lib/text"; import showModal from "discourse/lib/show-modal"; import { Promise } from "rsvp"; +import ENV from "discourse-common/config/environment"; // Our head can be a static string or a function that returns a string // based on input (like for numbered lists). @@ -375,7 +376,7 @@ export default Component.extend({ } // Debouncing in test mode is complicated - if (Ember.testing) { + if (ENV.environment === "test") { this._updatePreview(); } else { debounce(this, this._updatePreview, 30); diff --git a/app/assets/javascripts/discourse/components/date-time-input.js.es6 b/app/assets/javascripts/discourse/components/date-time-input.js.es6 index 41b41a8d328..c83483bc7d2 100644 --- a/app/assets/javascripts/discourse/components/date-time-input.js.es6 +++ b/app/assets/javascripts/discourse/components/date-time-input.js.es6 @@ -1,4 +1,5 @@ import Component from "@ember/component"; + export default Component.extend({ classNames: ["d-date-time-input"], date: null, diff --git a/app/assets/javascripts/discourse/components/emoji-picker.js.es6 b/app/assets/javascripts/discourse/components/emoji-picker.js.es6 index 52f9e8add4e..6ad97bebc8c 100644 --- a/app/assets/javascripts/discourse/components/emoji-picker.js.es6 +++ b/app/assets/javascripts/discourse/components/emoji-picker.js.es6 @@ -10,6 +10,8 @@ import { emojiSearch } from "pretty-text/emoji"; import { safariHacksDisabled } from "discourse/lib/utilities"; +import ENV from "discourse-common/config/environment"; + const { run } = Ember; const PER_ROW = 11; @@ -509,7 +511,7 @@ export default Component.extend({ this.$picker.css(_.merge(attributes, options)); }; - if (Ember.testing || !this.automaticPositioning) { + if (ENV.environment === "test" || !this.automaticPositioning) { desktopPositioning(); return; } diff --git a/app/assets/javascripts/discourse/components/topic-timer-info.js.es6 b/app/assets/javascripts/discourse/components/topic-timer-info.js.es6 index bb26e0caba4..3f219f31432 100644 --- a/app/assets/javascripts/discourse/components/topic-timer-info.js.es6 +++ b/app/assets/javascripts/discourse/components/topic-timer-info.js.es6 @@ -6,6 +6,7 @@ import { bufferedRender } from "discourse-common/lib/buffered-render"; import Category from "discourse/models/category"; import computed from "ember-addons/ember-computed-decorators"; import { REMINDER_TYPE } from "discourse/controllers/edit-topic-timer"; +import ENV from "discourse-common/config/environment"; export default Component.extend( bufferedRender({ @@ -86,7 +87,7 @@ export default Component.extend( buffer.push(""); // TODO Sam: concerned this can cause a heavy rerender loop - if (!Ember.testing) { + if (ENV.environment !== "test") { this._delayedRerender = later(this, this.rerender, rerenderDelay); } } diff --git a/app/assets/javascripts/discourse/components/user-card-contents.js.es6 b/app/assets/javascripts/discourse/components/user-card-contents.js.es6 index d7c6eac7850..9163d36d537 100644 --- a/app/assets/javascripts/discourse/components/user-card-contents.js.es6 +++ b/app/assets/javascripts/discourse/components/user-card-contents.js.es6 @@ -14,6 +14,7 @@ import CardContentsBase from "discourse/mixins/card-contents-base"; import CleansUp from "discourse/mixins/cleans-up"; import { prioritizeNameInUx } from "discourse/lib/settings"; import { set } from "@ember/object"; +import { getOwner } from "@ember/application"; export default Component.extend(CardContentsBase, CanCheckEmails, CleansUp, { elementId: "user-card", @@ -174,7 +175,7 @@ export default Component.extend(CardContentsBase, CanCheckEmails, CleansUp, { composePM(user, post) { this._close(); - Ember.getOwner(this) + getOwner(this) .lookup("router:main") .send("composePrivateMessage", user, post); }, diff --git a/app/assets/javascripts/discourse/controllers/composer.js.es6 b/app/assets/javascripts/discourse/controllers/composer.js.es6 index df268122807..cbdba446231 100644 --- a/app/assets/javascripts/discourse/controllers/composer.js.es6 +++ b/app/assets/javascripts/discourse/controllers/composer.js.es6 @@ -25,6 +25,7 @@ import { emojiUnescape } from "discourse/lib/text"; import { shortDate } from "discourse/lib/formatter"; import { SAVE_LABELS, SAVE_ICONS } from "discourse/models/composer"; import { Promise } from "rsvp"; +import ENV from "discourse-common/config/environment"; function loadDraft(store, opts) { opts = opts || {}; @@ -67,7 +68,7 @@ function loadDraft(store, opts) { const _popupMenuOptionsCallbacks = []; -let _checkDraftPopup = !Ember.testing; +let _checkDraftPopup = !ENV.environment === "test"; export function toggleCheckDraftPopup(enabled) { _checkDraftPopup = enabled; diff --git a/app/assets/javascripts/discourse/controllers/topic.js.es6 b/app/assets/javascripts/discourse/controllers/topic.js.es6 index af63f140be8..730bd8fefec 100644 --- a/app/assets/javascripts/discourse/controllers/topic.js.es6 +++ b/app/assets/javascripts/discourse/controllers/topic.js.es6 @@ -1360,7 +1360,8 @@ export default Controller.extend(bufferedProperty("model"), { if (callback) { callback(this, data); } else { - Ember.Logger.warn("unknown topic bus message type", data); + // eslint-disable-next-line no-console + console.warn("unknown topic bus message type", data); } } } diff --git a/app/assets/javascripts/discourse/initializers/live-development.js.es6 b/app/assets/javascripts/discourse/initializers/live-development.js.es6 index 8104bdfd0ab..5c2d973d31b 100644 --- a/app/assets/javascripts/discourse/initializers/live-development.js.es6 +++ b/app/assets/javascripts/discourse/initializers/live-development.js.es6 @@ -1,5 +1,6 @@ import DiscourseURL from "discourse/lib/url"; import { currentThemeIds, refreshCSS } from "discourse/lib/theme-selector"; +import ENV from "discourse-common/config/environment"; // Use the message bus for live reloading of components for faster development. export default { @@ -43,7 +44,7 @@ export default { }); // Useful to export this for debugging purposes - if (Discourse.Environment === "development" && !Ember.testing) { + if (Discourse.Environment === "development" && ENV.environment !== "test") { window.DiscourseURL = DiscourseURL; } diff --git a/app/assets/javascripts/discourse/initializers/subscribe-user-notifications.js.es6 b/app/assets/javascripts/discourse/initializers/subscribe-user-notifications.js.es6 index c79a94ceaf1..8efb204c363 100644 --- a/app/assets/javascripts/discourse/initializers/subscribe-user-notifications.js.es6 +++ b/app/assets/javascripts/discourse/initializers/subscribe-user-notifications.js.es6 @@ -12,6 +12,7 @@ import { isPushNotificationsEnabled } from "discourse/lib/push-notifications"; import { set } from "@ember/object"; +import ENV from "discourse-common/config/environment"; export default { name: "subscribe-user-notifications", @@ -127,7 +128,7 @@ export default { Discourse.set("assetVersion", data) ); - if (!Ember.testing) { + if (ENV.environment !== "test") { bus.subscribe(alertChannel(user), data => onNotification(data, user)); initDesktopNotifications(bus, appEvents); diff --git a/app/assets/javascripts/discourse/lib/click-track.js.es6 b/app/assets/javascripts/discourse/lib/click-track.js.es6 index 12abc761528..aeb83f8fe9b 100644 --- a/app/assets/javascripts/discourse/lib/click-track.js.es6 +++ b/app/assets/javascripts/discourse/lib/click-track.js.es6 @@ -4,6 +4,7 @@ import DiscourseURL from "discourse/lib/url"; import { wantsNewWindow } from "discourse/lib/intercept-click"; import { selectedText } from "discourse/lib/utilities"; import { Promise } from "rsvp"; +import ENV from "discourse-common/config/environment"; export function isValidLink($link) { // Do not track: @@ -99,7 +100,7 @@ export default { let trackPromise = Promise.resolve(); if (tracking) { - if (!Ember.testing && navigator.sendBeacon) { + if (ENV.environment !== "test" && navigator.sendBeacon) { const data = new FormData(); data.append("url", href); data.append("post_id", postId); diff --git a/app/assets/javascripts/discourse/lib/desktop-notifications.js.es6 b/app/assets/javascripts/discourse/lib/desktop-notifications.js.es6 index 52c0449285c..ba40f8246fc 100644 --- a/app/assets/javascripts/discourse/lib/desktop-notifications.js.es6 +++ b/app/assets/javascripts/discourse/lib/desktop-notifications.js.es6 @@ -28,14 +28,16 @@ function init(messageBus, appEvents) { try { keyValueStore.getItem(focusTrackerKey); } catch (e) { - Ember.Logger.info( + // eslint-disable-next-line no-console + console.info( "Discourse desktop notifications are disabled - localStorage denied." ); return; } if (!("Notification" in window)) { - Ember.Logger.info( + // eslint-disable-next-line no-console + console.info( "Discourse desktop notifications are disabled - not supported by browser" ); return; @@ -49,7 +51,8 @@ function init(messageBus, appEvents) { return; } } catch (e) { - Ember.Logger.warn( + // eslint-disable-next-line no-console + console.warn( "Unexpected error, Notification is defined on window but not a responding correctly " + e ); @@ -60,7 +63,8 @@ function init(messageBus, appEvents) { // Preliminary checks passed, continue with setup setupNotifications(appEvents); } catch (e) { - Ember.Logger.error(e); + // eslint-disable-next-line no-console + console.error(e); } } diff --git a/app/assets/javascripts/discourse/lib/eyeline.js.es6 b/app/assets/javascripts/discourse/lib/eyeline.js.es6 index f49801f0996..03c8092cc57 100644 --- a/app/assets/javascripts/discourse/lib/eyeline.js.es6 +++ b/app/assets/javascripts/discourse/lib/eyeline.js.es6 @@ -1,10 +1,12 @@ +import ENV from "discourse-common/config/environment"; + // Track visible elemnts on the screen. const Eyeline = function Eyeline(selector) { this.selector = selector; }; Eyeline.prototype.update = function() { - if (Ember.testing) { + if (ENV.environment === "test") { return; } @@ -61,7 +63,7 @@ Eyeline.prototype.update = function() { // Call this when we know aren't loading any more elements. Mark the rest as seen Eyeline.prototype.flushRest = function() { - if (Ember.testing) { + if (ENV.environment === "test") { return; } diff --git a/app/assets/javascripts/discourse/lib/mobile.js.es6 b/app/assets/javascripts/discourse/lib/mobile.js.es6 index de9a10697b6..96ee5f7099d 100644 --- a/app/assets/javascripts/discourse/lib/mobile.js.es6 +++ b/app/assets/javascripts/discourse/lib/mobile.js.es6 @@ -1,4 +1,5 @@ import deprecated from "discourse-common/lib/deprecated"; +import ENV from "discourse-common/config/environment"; let mobileForced = false; @@ -12,7 +13,7 @@ const Mobile = { this.isMobileDevice = mobileForced || $html.hasClass("mobile-device"); this.mobileView = mobileForced || $html.hasClass("mobile-view"); - if (Ember.testing || mobileForced) { + if (ENV.environment === "test" || mobileForced) { return; } diff --git a/app/assets/javascripts/discourse/lib/register-topic-footer-button.js.es6 b/app/assets/javascripts/discourse/lib/register-topic-footer-button.js.es6 index b6e5c5c5e93..65b687ac7cb 100644 --- a/app/assets/javascripts/discourse/lib/register-topic-footer-button.js.es6 +++ b/app/assets/javascripts/discourse/lib/register-topic-footer-button.js.es6 @@ -1,8 +1,10 @@ +import error from "@ember/error"; + let _topicFooterButtons = {}; export function registerTopicFooterButton(button) { if (!button.id) { - Ember.error(`Attempted to register a topic button: ${button} with no id.`); + error(`Attempted to register a topic button: ${button} with no id.`); return; } @@ -52,7 +54,7 @@ export function registerTopicFooterButton(button) { !normalizedButton.title && !normalizedButton.translatedTitle ) { - Ember.error( + error( `Attempted to register a topic button: ${button.id} with no icon or title.` ); return; diff --git a/app/assets/javascripts/discourse/mapping-router.js.es6 b/app/assets/javascripts/discourse/mapping-router.js.es6 index 52d25f54792..f115ddf2397 100644 --- a/app/assets/javascripts/discourse/mapping-router.js.es6 +++ b/app/assets/javascripts/discourse/mapping-router.js.es6 @@ -1,11 +1,12 @@ import { defaultHomepage } from "discourse/lib/utilities"; import { rewritePath } from "discourse/lib/url"; +import ENV from "discourse-common/config/environment"; const rootURL = Discourse.BaseUri; const BareRouter = Ember.Router.extend({ rootURL, - location: Ember.testing ? "none" : "discourse-location", + location: ENV.environment === "test" ? "none" : "discourse-location", handleURL(url) { url = rewritePath(url); diff --git a/app/assets/javascripts/discourse/mixins/scroll-top.js.es6 b/app/assets/javascripts/discourse/mixins/scroll-top.js.es6 index 82ae1c0479f..d636c2333f5 100644 --- a/app/assets/javascripts/discourse/mixins/scroll-top.js.es6 +++ b/app/assets/javascripts/discourse/mixins/scroll-top.js.es6 @@ -2,10 +2,11 @@ import { scheduleOnce } from "@ember/runloop"; import DiscourseURL from "discourse/lib/url"; import { deprecated } from "discourse/mixins/scroll-top"; import Mixin from "@ember/object/mixin"; +import ENV from "discourse-common/config/environment"; const context = { _scrollTop() { - if (Ember.testing) { + if (ENV.environment === "test") { return; } $(document).scrollTop(0); diff --git a/app/assets/javascripts/discourse/routes/topic-from-params.js.es6 b/app/assets/javascripts/discourse/routes/topic-from-params.js.es6 index 08c46712366..dd2215520ff 100644 --- a/app/assets/javascripts/discourse/routes/topic-from-params.js.es6 +++ b/app/assets/javascripts/discourse/routes/topic-from-params.js.es6 @@ -3,6 +3,7 @@ import { scheduleOnce } from "@ember/runloop"; import DiscourseRoute from "discourse/routes/discourse"; import DiscourseURL from "discourse/lib/url"; import Draft from "discourse/models/draft"; +import ENV from "discourse-common/config/environment"; // This route is used for retrieving a topic based on params export default DiscourseRoute.extend({ @@ -80,7 +81,7 @@ export default DiscourseRoute.extend({ } }) .catch(e => { - if (!Ember.testing) { + if (ENV.environment !== "test") { // eslint-disable-next-line no-console console.log("Could not view topic", e); } diff --git a/app/assets/javascripts/discourse/widgets/connector.js.es6 b/app/assets/javascripts/discourse/widgets/connector.js.es6 index e3c0d9b6281..02d5ec6e9c1 100644 --- a/app/assets/javascripts/discourse/widgets/connector.js.es6 +++ b/app/assets/javascripts/discourse/widgets/connector.js.es6 @@ -22,8 +22,8 @@ export default class Connector { ); } - const container = Ember.getOwner - ? Ember.getOwner(mounted) + const container = getOwner + ? getOwner(mounted) : mounted.container; let view; diff --git a/app/assets/javascripts/discourse/widgets/glue.js.es6 b/app/assets/javascripts/discourse/widgets/glue.js.es6 index c3a6af4b802..93c5b35ec40 100644 --- a/app/assets/javascripts/discourse/widgets/glue.js.es6 +++ b/app/assets/javascripts/discourse/widgets/glue.js.es6 @@ -3,6 +3,7 @@ import { scheduleOnce } from "@ember/runloop"; import { diff, patch } from "virtual-dom"; import { queryRegistry } from "discourse/widgets/widget"; import DirtyKeys from "discourse/lib/dirty-keys"; +import ENV from "discourse-common/config/environment"; export default class WidgetGlue { constructor(name, register, attrs) { @@ -34,7 +35,7 @@ export default class WidgetGlue { cancel(this._timeout); // in test mode return early if store cannot be found - if (Ember.testing) { + if (ENV.environment === "test") { try { this.register.lookup("service:store"); } catch (e) { diff --git a/app/assets/javascripts/discourse/widgets/post-menu.js.es6 b/app/assets/javascripts/discourse/widgets/post-menu.js.es6 index 780cb20e1fb..2039ed446f5 100644 --- a/app/assets/javascripts/discourse/widgets/post-menu.js.es6 +++ b/app/assets/javascripts/discourse/widgets/post-menu.js.es6 @@ -5,11 +5,12 @@ import { avatarAtts } from "discourse/widgets/actions-summary"; import { h } from "virtual-dom"; import showModal from "discourse/lib/show-modal"; import { Promise } from "rsvp"; +import ENV from "discourse-common/config/environment"; const LIKE_ACTION = 2; function animateHeart($elem, start, end, complete) { - if (Ember.testing) { + if (ENV.environment === "test") { return run(this, complete); } diff --git a/app/assets/javascripts/discourse/widgets/widget.js.es6 b/app/assets/javascripts/discourse/widgets/widget.js.es6 index d24df979636..b131f2a4e28 100644 --- a/app/assets/javascripts/discourse/widgets/widget.js.es6 +++ b/app/assets/javascripts/discourse/widgets/widget.js.es6 @@ -11,6 +11,7 @@ import { import { h } from "virtual-dom"; import DecoratorHelper from "discourse/widgets/decorator-helper"; import { Promise } from "rsvp"; +import ENV from "discourse-common/config/environment"; const _registry = {}; @@ -118,7 +119,7 @@ export default class Widget { this.keyValueStore = register.lookup("key-value-store:main"); // Helps debug widgets - if (Discourse.Environment === "development" || Ember.testing) { + if (Discourse.Environment === "development" || ENV.environment === "test") { const ds = this.defaultState(attrs); if (typeof ds !== "object") { throw new Error(`defaultState must return an object`); diff --git a/app/assets/javascripts/locales/i18n.js b/app/assets/javascripts/locales/i18n.js index 68657e28b68..ec33b0c5238 100644 --- a/app/assets/javascripts/locales/i18n.js +++ b/app/assets/javascripts/locales/i18n.js @@ -319,7 +319,8 @@ I18n.enableVerboseLocalization = function() { if (!_.isEmpty(value)) { message += ", parameters: " + JSON.stringify(value); } - Ember.Logger.info(message); + // eslint-disable-next-line no-console + console.info(message); } return t.apply(I18n, [scope, value]) + " (#" + current + ")"; }; diff --git a/app/assets/javascripts/wizard/router.js.es6 b/app/assets/javascripts/wizard/router.js.es6 index 5a1596b8cd7..05921b0a5dc 100644 --- a/app/assets/javascripts/wizard/router.js.es6 +++ b/app/assets/javascripts/wizard/router.js.es6 @@ -1,8 +1,9 @@ import getUrl from "discourse-common/lib/get-url"; +import ENV from "discourse-common/config/environment"; const Router = Ember.Router.extend({ rootURL: getUrl("/wizard/"), - location: Ember.testing ? "none" : "history" + location: ENV.environment === "test" ? "none" : "history" }); Router.map(function() {