DEV: Import ember ENV instead of Ember.testing (#8305)
This commit is contained in:
parent
60a235d128
commit
9ffdbf912f
|
@ -9,6 +9,7 @@ import { outputExportResult } from "discourse/lib/export-result";
|
||||||
import { isNumeric } from "discourse/lib/utilities";
|
import { isNumeric } from "discourse/lib/utilities";
|
||||||
import { SCHEMA_VERSION, default as Report } from "admin/models/report";
|
import { SCHEMA_VERSION, default as Report } from "admin/models/report";
|
||||||
import computed from "ember-addons/ember-computed-decorators";
|
import computed from "ember-addons/ember-computed-decorators";
|
||||||
|
import ENV from "discourse-common/config/environment";
|
||||||
|
|
||||||
const TABLE_OPTIONS = {
|
const TABLE_OPTIONS = {
|
||||||
perPage: 8,
|
perPage: 8,
|
||||||
|
@ -162,8 +163,8 @@ export default Component.extend({
|
||||||
let reportKey = "reports:";
|
let reportKey = "reports:";
|
||||||
reportKey += [
|
reportKey += [
|
||||||
dataSourceName,
|
dataSourceName,
|
||||||
Ember.testing ? "start" : startDate.replace(/-/g, ""),
|
ENV.environment === "test" ? "start" : startDate.replace(/-/g, ""),
|
||||||
Ember.testing ? "end" : endDate.replace(/-/g, ""),
|
ENV.environment === "test" ? "end" : endDate.replace(/-/g, ""),
|
||||||
"[:prev_period]",
|
"[:prev_period]",
|
||||||
this.get("reportOptions.table.limit"),
|
this.get("reportOptions.table.limit"),
|
||||||
customFilters
|
customFilters
|
||||||
|
|
|
@ -7,6 +7,7 @@ import {
|
||||||
} from "ember-addons/ember-computed-decorators";
|
} from "ember-addons/ember-computed-decorators";
|
||||||
import { iconHTML } from "discourse-common/lib/icon-library";
|
import { iconHTML } from "discourse-common/lib/icon-library";
|
||||||
import { escape } from "pretty-text/sanitizer";
|
import { escape } from "pretty-text/sanitizer";
|
||||||
|
import ENV from "discourse-common/config/environment";
|
||||||
|
|
||||||
const MAX_COMPONENTS = 4;
|
const MAX_COMPONENTS = 4;
|
||||||
|
|
||||||
|
@ -43,7 +44,7 @@ export default Component.extend({
|
||||||
animate(isInitial) {
|
animate(isInitial) {
|
||||||
const $container = $(this.element);
|
const $container = $(this.element);
|
||||||
const $list = $(this.element.querySelector(".components-list"));
|
const $list = $(this.element.querySelector(".components-list"));
|
||||||
if ($list.length === 0 || Ember.testing) {
|
if ($list.length === 0 || ENV.environment === 'test') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const duration = 300;
|
const duration = 300;
|
||||||
|
|
|
@ -2,6 +2,7 @@ import { gt, equal } from "@ember/object/computed";
|
||||||
import Component from "@ember/component";
|
import Component from "@ember/component";
|
||||||
import { THEMES, COMPONENTS } from "admin/models/theme";
|
import { THEMES, COMPONENTS } from "admin/models/theme";
|
||||||
import { default as computed } from "ember-addons/ember-computed-decorators";
|
import { default as computed } from "ember-addons/ember-computed-decorators";
|
||||||
|
import { getOwner } from "@ember/application";
|
||||||
|
|
||||||
export default Component.extend({
|
export default Component.extend({
|
||||||
THEMES: THEMES,
|
THEMES: THEMES,
|
||||||
|
@ -70,7 +71,7 @@ export default Component.extend({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
navigateToTheme(theme) {
|
navigateToTheme(theme) {
|
||||||
Ember.getOwner(this)
|
getOwner(this)
|
||||||
.lookup("router:main")
|
.lookup("router:main")
|
||||||
.transitionTo("adminCustomizeThemes.show", theme);
|
.transitionTo("adminCustomizeThemes.show", theme);
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,7 +51,8 @@ export default Route.extend({
|
||||||
})
|
})
|
||||||
.catch(function(error) {
|
.catch(function(error) {
|
||||||
badge.set("preview_loading", false);
|
badge.set("preview_loading", false);
|
||||||
Ember.Logger.error(error);
|
// eslint-disable-next-line no-console
|
||||||
|
console.error(error);
|
||||||
bootbox.alert("Network error");
|
bootbox.alert("Network error");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
export default { environment: Ember.testing ? "test" : "development" };
|
|
@ -96,6 +96,9 @@ var define, requirejs;
|
||||||
},
|
},
|
||||||
"@ember/component/helper": {
|
"@ember/component/helper": {
|
||||||
default: Ember.Helper
|
default: Ember.Helper
|
||||||
|
},
|
||||||
|
"@ember/error": {
|
||||||
|
default: Ember.error
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,6 +48,7 @@ import {
|
||||||
INLINE_ONEBOX_LOADING_CSS_CLASS,
|
INLINE_ONEBOX_LOADING_CSS_CLASS,
|
||||||
INLINE_ONEBOX_CSS_CLASS
|
INLINE_ONEBOX_CSS_CLASS
|
||||||
} from "pretty-text/context/inline-onebox-css-classes";
|
} 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"];
|
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
|
// need to wait a bit for the "slide down" transition of the composer
|
||||||
later(
|
later(
|
||||||
() => this.appEvents.trigger("composer:closed"),
|
() => this.appEvents.trigger("composer:closed"),
|
||||||
Ember.testing ? 0 : 400
|
ENV.environment === "test" ? 0 : 400
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,7 @@ import { load } from "pretty-text/oneboxer";
|
||||||
import { lookupCache } from "pretty-text/oneboxer-cache";
|
import { lookupCache } from "pretty-text/oneboxer-cache";
|
||||||
import { ajax } from "discourse/lib/ajax";
|
import { ajax } from "discourse/lib/ajax";
|
||||||
import afterTransition from "discourse/lib/after-transition";
|
import afterTransition from "discourse/lib/after-transition";
|
||||||
|
import ENV from "discourse-common/config/environment";
|
||||||
|
|
||||||
export default Component.extend({
|
export default Component.extend({
|
||||||
classNames: ["title-input"],
|
classNames: ["title-input"],
|
||||||
|
@ -83,7 +84,7 @@ export default Component.extend({
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Ember.testing) {
|
if (ENV.environment === "test") {
|
||||||
next(() =>
|
next(() =>
|
||||||
// not ideal but we don't want to run this in current
|
// not ideal but we don't want to run this in current
|
||||||
// runloop to avoid an error in console
|
// runloop to avoid an error in console
|
||||||
|
|
|
@ -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 Component from "@ember/component";
|
||||||
import { default as computed } from "ember-addons/ember-computed-decorators";
|
import { default as computed } from "ember-addons/ember-computed-decorators";
|
||||||
import DiscourseURL from "discourse/lib/url";
|
import DiscourseURL from "discourse/lib/url";
|
||||||
|
@ -24,7 +24,7 @@ export default Component.extend({
|
||||||
|
|
||||||
btnIcon: notEmpty("icon"),
|
btnIcon: notEmpty("icon"),
|
||||||
|
|
||||||
btnLink: Ember.computed.equal("display", "link"),
|
btnLink: equal("display", "link"),
|
||||||
|
|
||||||
@computed("icon", "translatedLabel")
|
@computed("icon", "translatedLabel")
|
||||||
btnType(icon, translatedLabel) {
|
btnType(icon, translatedLabel) {
|
||||||
|
|
|
@ -30,6 +30,7 @@ import { emojiSearch, isSkinTonableEmoji } from "pretty-text/emoji";
|
||||||
import { emojiUrlFor } from "discourse/lib/text";
|
import { emojiUrlFor } from "discourse/lib/text";
|
||||||
import showModal from "discourse/lib/show-modal";
|
import showModal from "discourse/lib/show-modal";
|
||||||
import { Promise } from "rsvp";
|
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
|
// Our head can be a static string or a function that returns a string
|
||||||
// based on input (like for numbered lists).
|
// based on input (like for numbered lists).
|
||||||
|
@ -375,7 +376,7 @@ export default Component.extend({
|
||||||
}
|
}
|
||||||
|
|
||||||
// Debouncing in test mode is complicated
|
// Debouncing in test mode is complicated
|
||||||
if (Ember.testing) {
|
if (ENV.environment === "test") {
|
||||||
this._updatePreview();
|
this._updatePreview();
|
||||||
} else {
|
} else {
|
||||||
debounce(this, this._updatePreview, 30);
|
debounce(this, this._updatePreview, 30);
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import Component from "@ember/component";
|
import Component from "@ember/component";
|
||||||
|
|
||||||
export default Component.extend({
|
export default Component.extend({
|
||||||
classNames: ["d-date-time-input"],
|
classNames: ["d-date-time-input"],
|
||||||
date: null,
|
date: null,
|
||||||
|
|
|
@ -10,6 +10,8 @@ import {
|
||||||
emojiSearch
|
emojiSearch
|
||||||
} from "pretty-text/emoji";
|
} from "pretty-text/emoji";
|
||||||
import { safariHacksDisabled } from "discourse/lib/utilities";
|
import { safariHacksDisabled } from "discourse/lib/utilities";
|
||||||
|
import ENV from "discourse-common/config/environment";
|
||||||
|
|
||||||
const { run } = Ember;
|
const { run } = Ember;
|
||||||
|
|
||||||
const PER_ROW = 11;
|
const PER_ROW = 11;
|
||||||
|
@ -509,7 +511,7 @@ export default Component.extend({
|
||||||
this.$picker.css(_.merge(attributes, options));
|
this.$picker.css(_.merge(attributes, options));
|
||||||
};
|
};
|
||||||
|
|
||||||
if (Ember.testing || !this.automaticPositioning) {
|
if (ENV.environment === "test" || !this.automaticPositioning) {
|
||||||
desktopPositioning();
|
desktopPositioning();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@ import { bufferedRender } from "discourse-common/lib/buffered-render";
|
||||||
import Category from "discourse/models/category";
|
import Category from "discourse/models/category";
|
||||||
import computed from "ember-addons/ember-computed-decorators";
|
import computed from "ember-addons/ember-computed-decorators";
|
||||||
import { REMINDER_TYPE } from "discourse/controllers/edit-topic-timer";
|
import { REMINDER_TYPE } from "discourse/controllers/edit-topic-timer";
|
||||||
|
import ENV from "discourse-common/config/environment";
|
||||||
|
|
||||||
export default Component.extend(
|
export default Component.extend(
|
||||||
bufferedRender({
|
bufferedRender({
|
||||||
|
@ -86,7 +87,7 @@ export default Component.extend(
|
||||||
buffer.push("</h3>");
|
buffer.push("</h3>");
|
||||||
|
|
||||||
// TODO Sam: concerned this can cause a heavy rerender loop
|
// TODO Sam: concerned this can cause a heavy rerender loop
|
||||||
if (!Ember.testing) {
|
if (ENV.environment !== "test") {
|
||||||
this._delayedRerender = later(this, this.rerender, rerenderDelay);
|
this._delayedRerender = later(this, this.rerender, rerenderDelay);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,7 @@ import CardContentsBase from "discourse/mixins/card-contents-base";
|
||||||
import CleansUp from "discourse/mixins/cleans-up";
|
import CleansUp from "discourse/mixins/cleans-up";
|
||||||
import { prioritizeNameInUx } from "discourse/lib/settings";
|
import { prioritizeNameInUx } from "discourse/lib/settings";
|
||||||
import { set } from "@ember/object";
|
import { set } from "@ember/object";
|
||||||
|
import { getOwner } from "@ember/application";
|
||||||
|
|
||||||
export default Component.extend(CardContentsBase, CanCheckEmails, CleansUp, {
|
export default Component.extend(CardContentsBase, CanCheckEmails, CleansUp, {
|
||||||
elementId: "user-card",
|
elementId: "user-card",
|
||||||
|
@ -174,7 +175,7 @@ export default Component.extend(CardContentsBase, CanCheckEmails, CleansUp, {
|
||||||
composePM(user, post) {
|
composePM(user, post) {
|
||||||
this._close();
|
this._close();
|
||||||
|
|
||||||
Ember.getOwner(this)
|
getOwner(this)
|
||||||
.lookup("router:main")
|
.lookup("router:main")
|
||||||
.send("composePrivateMessage", user, post);
|
.send("composePrivateMessage", user, post);
|
||||||
},
|
},
|
||||||
|
|
|
@ -25,6 +25,7 @@ import { emojiUnescape } from "discourse/lib/text";
|
||||||
import { shortDate } from "discourse/lib/formatter";
|
import { shortDate } from "discourse/lib/formatter";
|
||||||
import { SAVE_LABELS, SAVE_ICONS } from "discourse/models/composer";
|
import { SAVE_LABELS, SAVE_ICONS } from "discourse/models/composer";
|
||||||
import { Promise } from "rsvp";
|
import { Promise } from "rsvp";
|
||||||
|
import ENV from "discourse-common/config/environment";
|
||||||
|
|
||||||
function loadDraft(store, opts) {
|
function loadDraft(store, opts) {
|
||||||
opts = opts || {};
|
opts = opts || {};
|
||||||
|
@ -67,7 +68,7 @@ function loadDraft(store, opts) {
|
||||||
|
|
||||||
const _popupMenuOptionsCallbacks = [];
|
const _popupMenuOptionsCallbacks = [];
|
||||||
|
|
||||||
let _checkDraftPopup = !Ember.testing;
|
let _checkDraftPopup = !ENV.environment === "test";
|
||||||
|
|
||||||
export function toggleCheckDraftPopup(enabled) {
|
export function toggleCheckDraftPopup(enabled) {
|
||||||
_checkDraftPopup = enabled;
|
_checkDraftPopup = enabled;
|
||||||
|
|
|
@ -1360,7 +1360,8 @@ export default Controller.extend(bufferedProperty("model"), {
|
||||||
if (callback) {
|
if (callback) {
|
||||||
callback(this, data);
|
callback(this, data);
|
||||||
} else {
|
} else {
|
||||||
Ember.Logger.warn("unknown topic bus message type", data);
|
// eslint-disable-next-line no-console
|
||||||
|
console.warn("unknown topic bus message type", data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import DiscourseURL from "discourse/lib/url";
|
import DiscourseURL from "discourse/lib/url";
|
||||||
import { currentThemeIds, refreshCSS } from "discourse/lib/theme-selector";
|
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.
|
// Use the message bus for live reloading of components for faster development.
|
||||||
export default {
|
export default {
|
||||||
|
@ -43,7 +44,7 @@ export default {
|
||||||
});
|
});
|
||||||
|
|
||||||
// Useful to export this for debugging purposes
|
// Useful to export this for debugging purposes
|
||||||
if (Discourse.Environment === "development" && !Ember.testing) {
|
if (Discourse.Environment === "development" && ENV.environment !== "test") {
|
||||||
window.DiscourseURL = DiscourseURL;
|
window.DiscourseURL = DiscourseURL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,7 @@ import {
|
||||||
isPushNotificationsEnabled
|
isPushNotificationsEnabled
|
||||||
} from "discourse/lib/push-notifications";
|
} from "discourse/lib/push-notifications";
|
||||||
import { set } from "@ember/object";
|
import { set } from "@ember/object";
|
||||||
|
import ENV from "discourse-common/config/environment";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "subscribe-user-notifications",
|
name: "subscribe-user-notifications",
|
||||||
|
@ -127,7 +128,7 @@ export default {
|
||||||
Discourse.set("assetVersion", data)
|
Discourse.set("assetVersion", data)
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!Ember.testing) {
|
if (ENV.environment !== "test") {
|
||||||
bus.subscribe(alertChannel(user), data => onNotification(data, user));
|
bus.subscribe(alertChannel(user), data => onNotification(data, user));
|
||||||
initDesktopNotifications(bus, appEvents);
|
initDesktopNotifications(bus, appEvents);
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@ import DiscourseURL from "discourse/lib/url";
|
||||||
import { wantsNewWindow } from "discourse/lib/intercept-click";
|
import { wantsNewWindow } from "discourse/lib/intercept-click";
|
||||||
import { selectedText } from "discourse/lib/utilities";
|
import { selectedText } from "discourse/lib/utilities";
|
||||||
import { Promise } from "rsvp";
|
import { Promise } from "rsvp";
|
||||||
|
import ENV from "discourse-common/config/environment";
|
||||||
|
|
||||||
export function isValidLink($link) {
|
export function isValidLink($link) {
|
||||||
// Do not track:
|
// Do not track:
|
||||||
|
@ -99,7 +100,7 @@ export default {
|
||||||
|
|
||||||
let trackPromise = Promise.resolve();
|
let trackPromise = Promise.resolve();
|
||||||
if (tracking) {
|
if (tracking) {
|
||||||
if (!Ember.testing && navigator.sendBeacon) {
|
if (ENV.environment !== "test" && navigator.sendBeacon) {
|
||||||
const data = new FormData();
|
const data = new FormData();
|
||||||
data.append("url", href);
|
data.append("url", href);
|
||||||
data.append("post_id", postId);
|
data.append("post_id", postId);
|
||||||
|
|
|
@ -28,14 +28,16 @@ function init(messageBus, appEvents) {
|
||||||
try {
|
try {
|
||||||
keyValueStore.getItem(focusTrackerKey);
|
keyValueStore.getItem(focusTrackerKey);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
Ember.Logger.info(
|
// eslint-disable-next-line no-console
|
||||||
|
console.info(
|
||||||
"Discourse desktop notifications are disabled - localStorage denied."
|
"Discourse desktop notifications are disabled - localStorage denied."
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!("Notification" in window)) {
|
if (!("Notification" in window)) {
|
||||||
Ember.Logger.info(
|
// eslint-disable-next-line no-console
|
||||||
|
console.info(
|
||||||
"Discourse desktop notifications are disabled - not supported by browser"
|
"Discourse desktop notifications are disabled - not supported by browser"
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
|
@ -49,7 +51,8 @@ function init(messageBus, appEvents) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} 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 " +
|
"Unexpected error, Notification is defined on window but not a responding correctly " +
|
||||||
e
|
e
|
||||||
);
|
);
|
||||||
|
@ -60,7 +63,8 @@ function init(messageBus, appEvents) {
|
||||||
// Preliminary checks passed, continue with setup
|
// Preliminary checks passed, continue with setup
|
||||||
setupNotifications(appEvents);
|
setupNotifications(appEvents);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
Ember.Logger.error(e);
|
// eslint-disable-next-line no-console
|
||||||
|
console.error(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,12 @@
|
||||||
|
import ENV from "discourse-common/config/environment";
|
||||||
|
|
||||||
// Track visible elemnts on the screen.
|
// Track visible elemnts on the screen.
|
||||||
const Eyeline = function Eyeline(selector) {
|
const Eyeline = function Eyeline(selector) {
|
||||||
this.selector = selector;
|
this.selector = selector;
|
||||||
};
|
};
|
||||||
|
|
||||||
Eyeline.prototype.update = function() {
|
Eyeline.prototype.update = function() {
|
||||||
if (Ember.testing) {
|
if (ENV.environment === "test") {
|
||||||
return;
|
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
|
// Call this when we know aren't loading any more elements. Mark the rest as seen
|
||||||
Eyeline.prototype.flushRest = function() {
|
Eyeline.prototype.flushRest = function() {
|
||||||
if (Ember.testing) {
|
if (ENV.environment === "test") {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import deprecated from "discourse-common/lib/deprecated";
|
import deprecated from "discourse-common/lib/deprecated";
|
||||||
|
import ENV from "discourse-common/config/environment";
|
||||||
|
|
||||||
let mobileForced = false;
|
let mobileForced = false;
|
||||||
|
|
||||||
|
@ -12,7 +13,7 @@ const Mobile = {
|
||||||
this.isMobileDevice = mobileForced || $html.hasClass("mobile-device");
|
this.isMobileDevice = mobileForced || $html.hasClass("mobile-device");
|
||||||
this.mobileView = mobileForced || $html.hasClass("mobile-view");
|
this.mobileView = mobileForced || $html.hasClass("mobile-view");
|
||||||
|
|
||||||
if (Ember.testing || mobileForced) {
|
if (ENV.environment === "test" || mobileForced) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
|
import error from "@ember/error";
|
||||||
|
|
||||||
let _topicFooterButtons = {};
|
let _topicFooterButtons = {};
|
||||||
|
|
||||||
export function registerTopicFooterButton(button) {
|
export function registerTopicFooterButton(button) {
|
||||||
if (!button.id) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,7 +54,7 @@ export function registerTopicFooterButton(button) {
|
||||||
!normalizedButton.title &&
|
!normalizedButton.title &&
|
||||||
!normalizedButton.translatedTitle
|
!normalizedButton.translatedTitle
|
||||||
) {
|
) {
|
||||||
Ember.error(
|
error(
|
||||||
`Attempted to register a topic button: ${button.id} with no icon or title.`
|
`Attempted to register a topic button: ${button.id} with no icon or title.`
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
import { defaultHomepage } from "discourse/lib/utilities";
|
import { defaultHomepage } from "discourse/lib/utilities";
|
||||||
import { rewritePath } from "discourse/lib/url";
|
import { rewritePath } from "discourse/lib/url";
|
||||||
|
import ENV from "discourse-common/config/environment";
|
||||||
|
|
||||||
const rootURL = Discourse.BaseUri;
|
const rootURL = Discourse.BaseUri;
|
||||||
|
|
||||||
const BareRouter = Ember.Router.extend({
|
const BareRouter = Ember.Router.extend({
|
||||||
rootURL,
|
rootURL,
|
||||||
location: Ember.testing ? "none" : "discourse-location",
|
location: ENV.environment === "test" ? "none" : "discourse-location",
|
||||||
|
|
||||||
handleURL(url) {
|
handleURL(url) {
|
||||||
url = rewritePath(url);
|
url = rewritePath(url);
|
||||||
|
|
|
@ -2,10 +2,11 @@ import { scheduleOnce } from "@ember/runloop";
|
||||||
import DiscourseURL from "discourse/lib/url";
|
import DiscourseURL from "discourse/lib/url";
|
||||||
import { deprecated } from "discourse/mixins/scroll-top";
|
import { deprecated } from "discourse/mixins/scroll-top";
|
||||||
import Mixin from "@ember/object/mixin";
|
import Mixin from "@ember/object/mixin";
|
||||||
|
import ENV from "discourse-common/config/environment";
|
||||||
|
|
||||||
const context = {
|
const context = {
|
||||||
_scrollTop() {
|
_scrollTop() {
|
||||||
if (Ember.testing) {
|
if (ENV.environment === "test") {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$(document).scrollTop(0);
|
$(document).scrollTop(0);
|
||||||
|
|
|
@ -3,6 +3,7 @@ import { scheduleOnce } from "@ember/runloop";
|
||||||
import DiscourseRoute from "discourse/routes/discourse";
|
import DiscourseRoute from "discourse/routes/discourse";
|
||||||
import DiscourseURL from "discourse/lib/url";
|
import DiscourseURL from "discourse/lib/url";
|
||||||
import Draft from "discourse/models/draft";
|
import Draft from "discourse/models/draft";
|
||||||
|
import ENV from "discourse-common/config/environment";
|
||||||
|
|
||||||
// This route is used for retrieving a topic based on params
|
// This route is used for retrieving a topic based on params
|
||||||
export default DiscourseRoute.extend({
|
export default DiscourseRoute.extend({
|
||||||
|
@ -80,7 +81,7 @@ export default DiscourseRoute.extend({
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(e => {
|
.catch(e => {
|
||||||
if (!Ember.testing) {
|
if (ENV.environment !== "test") {
|
||||||
// eslint-disable-next-line no-console
|
// eslint-disable-next-line no-console
|
||||||
console.log("Could not view topic", e);
|
console.log("Could not view topic", e);
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,8 +22,8 @@ export default class Connector {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const container = Ember.getOwner
|
const container = getOwner
|
||||||
? Ember.getOwner(mounted)
|
? getOwner(mounted)
|
||||||
: mounted.container;
|
: mounted.container;
|
||||||
|
|
||||||
let view;
|
let view;
|
||||||
|
|
|
@ -3,6 +3,7 @@ import { scheduleOnce } from "@ember/runloop";
|
||||||
import { diff, patch } from "virtual-dom";
|
import { diff, patch } from "virtual-dom";
|
||||||
import { queryRegistry } from "discourse/widgets/widget";
|
import { queryRegistry } from "discourse/widgets/widget";
|
||||||
import DirtyKeys from "discourse/lib/dirty-keys";
|
import DirtyKeys from "discourse/lib/dirty-keys";
|
||||||
|
import ENV from "discourse-common/config/environment";
|
||||||
|
|
||||||
export default class WidgetGlue {
|
export default class WidgetGlue {
|
||||||
constructor(name, register, attrs) {
|
constructor(name, register, attrs) {
|
||||||
|
@ -34,7 +35,7 @@ export default class WidgetGlue {
|
||||||
cancel(this._timeout);
|
cancel(this._timeout);
|
||||||
|
|
||||||
// in test mode return early if store cannot be found
|
// in test mode return early if store cannot be found
|
||||||
if (Ember.testing) {
|
if (ENV.environment === "test") {
|
||||||
try {
|
try {
|
||||||
this.register.lookup("service:store");
|
this.register.lookup("service:store");
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|
|
@ -5,11 +5,12 @@ import { avatarAtts } from "discourse/widgets/actions-summary";
|
||||||
import { h } from "virtual-dom";
|
import { h } from "virtual-dom";
|
||||||
import showModal from "discourse/lib/show-modal";
|
import showModal from "discourse/lib/show-modal";
|
||||||
import { Promise } from "rsvp";
|
import { Promise } from "rsvp";
|
||||||
|
import ENV from "discourse-common/config/environment";
|
||||||
|
|
||||||
const LIKE_ACTION = 2;
|
const LIKE_ACTION = 2;
|
||||||
|
|
||||||
function animateHeart($elem, start, end, complete) {
|
function animateHeart($elem, start, end, complete) {
|
||||||
if (Ember.testing) {
|
if (ENV.environment === "test") {
|
||||||
return run(this, complete);
|
return run(this, complete);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,7 @@ import {
|
||||||
import { h } from "virtual-dom";
|
import { h } from "virtual-dom";
|
||||||
import DecoratorHelper from "discourse/widgets/decorator-helper";
|
import DecoratorHelper from "discourse/widgets/decorator-helper";
|
||||||
import { Promise } from "rsvp";
|
import { Promise } from "rsvp";
|
||||||
|
import ENV from "discourse-common/config/environment";
|
||||||
|
|
||||||
const _registry = {};
|
const _registry = {};
|
||||||
|
|
||||||
|
@ -118,7 +119,7 @@ export default class Widget {
|
||||||
this.keyValueStore = register.lookup("key-value-store:main");
|
this.keyValueStore = register.lookup("key-value-store:main");
|
||||||
|
|
||||||
// Helps debug widgets
|
// Helps debug widgets
|
||||||
if (Discourse.Environment === "development" || Ember.testing) {
|
if (Discourse.Environment === "development" || ENV.environment === "test") {
|
||||||
const ds = this.defaultState(attrs);
|
const ds = this.defaultState(attrs);
|
||||||
if (typeof ds !== "object") {
|
if (typeof ds !== "object") {
|
||||||
throw new Error(`defaultState must return an object`);
|
throw new Error(`defaultState must return an object`);
|
||||||
|
|
|
@ -319,7 +319,8 @@ I18n.enableVerboseLocalization = function() {
|
||||||
if (!_.isEmpty(value)) {
|
if (!_.isEmpty(value)) {
|
||||||
message += ", parameters: " + JSON.stringify(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 + ")";
|
return t.apply(I18n, [scope, value]) + " (#" + current + ")";
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
import getUrl from "discourse-common/lib/get-url";
|
import getUrl from "discourse-common/lib/get-url";
|
||||||
|
import ENV from "discourse-common/config/environment";
|
||||||
|
|
||||||
const Router = Ember.Router.extend({
|
const Router = Ember.Router.extend({
|
||||||
rootURL: getUrl("/wizard/"),
|
rootURL: getUrl("/wizard/"),
|
||||||
location: Ember.testing ? "none" : "history"
|
location: ENV.environment === "test" ? "none" : "history"
|
||||||
});
|
});
|
||||||
|
|
||||||
Router.map(function() {
|
Router.map(function() {
|
||||||
|
|
Loading…
Reference in New Issue