mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
Remove discourse constants (#9958)
* DEV: `Discourse.baseUri` does not exist This never could have worked - should have been `Discourse.BaseUri` if anything. * DEV: Remove Discourse.Environment * DEV: Remove `Discourse.disableMissingIconWarning` * DEV: A bunch more missing environment checks
This commit is contained in:
parent
9162cd8f3d
commit
a95826f60c
@ -9,8 +9,8 @@ import ReportLoader from "discourse/lib/reports-loader";
|
|||||||
import { exportEntity } from "discourse/lib/export-csv";
|
import { exportEntity } from "discourse/lib/export-csv";
|
||||||
import { outputExportResult } from "discourse/lib/export-result";
|
import { outputExportResult } from "discourse/lib/export-result";
|
||||||
import Report, { SCHEMA_VERSION } from "admin/models/report";
|
import Report, { SCHEMA_VERSION } from "admin/models/report";
|
||||||
import ENV from "discourse-common/config/environment";
|
|
||||||
import { isPresent } from "@ember/utils";
|
import { isPresent } from "@ember/utils";
|
||||||
|
import { isTesting } from "discourse-common/config/environment";
|
||||||
|
|
||||||
const TABLE_OPTIONS = {
|
const TABLE_OPTIONS = {
|
||||||
perPage: 8,
|
perPage: 8,
|
||||||
@ -167,8 +167,8 @@ export default Component.extend({
|
|||||||
let reportKey = "reports:";
|
let reportKey = "reports:";
|
||||||
reportKey += [
|
reportKey += [
|
||||||
dataSourceName,
|
dataSourceName,
|
||||||
ENV.environment === "test" ? "start" : startDate.replace(/-/g, ""),
|
isTesting() ? "start" : startDate.replace(/-/g, ""),
|
||||||
ENV.environment === "test" ? "end" : endDate.replace(/-/g, ""),
|
isTesting() ? "end" : endDate.replace(/-/g, ""),
|
||||||
"[:prev_period]",
|
"[:prev_period]",
|
||||||
this.get("reportOptions.table.limit"),
|
this.get("reportOptions.table.limit"),
|
||||||
// Convert all filter values to strings to ensure unique serialization
|
// Convert all filter values to strings to ensure unique serialization
|
||||||
|
@ -4,7 +4,7 @@ import Component from "@ember/component";
|
|||||||
import discourseComputed, { observes } from "discourse-common/utils/decorators";
|
import discourseComputed, { observes } from "discourse-common/utils/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";
|
import { isTesting } from "discourse-common/config/environment";
|
||||||
|
|
||||||
const MAX_COMPONENTS = 4;
|
const MAX_COMPONENTS = 4;
|
||||||
|
|
||||||
@ -41,7 +41,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 || ENV.environment === "test") {
|
if ($list.length === 0 || isTesting()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const duration = 300;
|
const duration = 300;
|
||||||
|
@ -1,9 +1,23 @@
|
|||||||
export const INPUT_DELAY = 250;
|
export const INPUT_DELAY = 250;
|
||||||
|
|
||||||
let environment = Ember.testing ? "test" : "development";
|
let environment = "unknown";
|
||||||
|
|
||||||
export function isTesting() {
|
export function setEnvironment(e) {
|
||||||
return environment === "test";
|
if (isTesting()) {
|
||||||
|
environment = "testing";
|
||||||
|
} else {
|
||||||
|
environment = e;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default { environment };
|
export function isTesting() {
|
||||||
|
return Ember.testing;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function isDevelopment() {
|
||||||
|
return environment === "development";
|
||||||
|
}
|
||||||
|
|
||||||
|
export function isProduction() {
|
||||||
|
return environment === "production";
|
||||||
|
}
|
||||||
|
@ -1,10 +1,13 @@
|
|||||||
import I18n from "I18n";
|
import I18n from "I18n";
|
||||||
import { h } from "virtual-dom";
|
import { h } from "virtual-dom";
|
||||||
import attributeHook from "discourse-common/lib/attribute-hook";
|
import attributeHook from "discourse-common/lib/attribute-hook";
|
||||||
|
import { isDevelopment } from "discourse-common/config/environment";
|
||||||
|
|
||||||
const SVG_NAMESPACE = "http://www.w3.org/2000/svg";
|
const SVG_NAMESPACE = "http://www.w3.org/2000/svg";
|
||||||
let _renderers = [];
|
let _renderers = [];
|
||||||
|
|
||||||
|
let warnMissingIcons = true;
|
||||||
|
|
||||||
const REPLACEMENTS = {
|
const REPLACEMENTS = {
|
||||||
"d-tracking": "bell",
|
"d-tracking": "bell",
|
||||||
"d-muted": "discourse-bell-slash",
|
"d-muted": "discourse-bell-slash",
|
||||||
@ -45,6 +48,14 @@ export function replaceIcon(source, destination) {
|
|||||||
REPLACEMENTS[source] = destination;
|
REPLACEMENTS[source] = destination;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function disableMissingIconWarning() {
|
||||||
|
warnMissingIcons = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function enableMissingIconWarning() {
|
||||||
|
warnMissingIcons = false;
|
||||||
|
}
|
||||||
|
|
||||||
export function renderIcon(renderType, id, params) {
|
export function renderIcon(renderType, id, params) {
|
||||||
for (let i = 0; i < _renderers.length; i++) {
|
for (let i = 0; i < _renderers.length; i++) {
|
||||||
let renderer = _renderers[i];
|
let renderer = _renderers[i];
|
||||||
@ -105,8 +116,8 @@ function iconClasses(icon, params) {
|
|||||||
function warnIfMissing(id) {
|
function warnIfMissing(id) {
|
||||||
if (
|
if (
|
||||||
typeof Discourse !== "undefined" &&
|
typeof Discourse !== "undefined" &&
|
||||||
Discourse.Environment === "development" &&
|
isDevelopment() &&
|
||||||
!Discourse.disableMissingIconWarning &&
|
warnMissingIcons &&
|
||||||
Discourse.SvgIconList &&
|
Discourse.SvgIconList &&
|
||||||
Discourse.SvgIconList.indexOf(id) === -1
|
Discourse.SvgIconList.indexOf(id) === -1
|
||||||
) {
|
) {
|
||||||
|
@ -44,7 +44,7 @@ import {
|
|||||||
cacheShortUploadUrl,
|
cacheShortUploadUrl,
|
||||||
resolveAllShortUrls
|
resolveAllShortUrls
|
||||||
} from "pretty-text/upload-short-url";
|
} from "pretty-text/upload-short-url";
|
||||||
import ENV from "discourse-common/config/environment";
|
import { isTesting } 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"];
|
||||||
|
|
||||||
@ -847,7 +847,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"),
|
||||||
ENV.environment === "test" ? 0 : 400
|
isTesting() ? 0 : 400
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ import discourseComputed, { observes } from "discourse-common/utils/decorators";
|
|||||||
import { load } from "pretty-text/oneboxer";
|
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 ENV from "discourse-common/config/environment";
|
import { isTesting } from "discourse-common/config/environment";
|
||||||
import EmberObject from "@ember/object";
|
import EmberObject from "@ember/object";
|
||||||
import putCursorAtEnd from "discourse/lib/put-cursor-at-end";
|
import putCursorAtEnd from "discourse/lib/put-cursor-at-end";
|
||||||
|
|
||||||
@ -76,7 +76,7 @@ export default Component.extend({
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ENV.environment === "test") {
|
if (isTesting()) {
|
||||||
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
|
||||||
|
@ -28,7 +28,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";
|
import { isTesting } 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).
|
||||||
@ -378,7 +378,7 @@ export default Component.extend({
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Debouncing in test mode is complicated
|
// Debouncing in test mode is complicated
|
||||||
if (ENV.environment === "test") {
|
if (isTesting()) {
|
||||||
this._updatePreview();
|
this._updatePreview();
|
||||||
} else {
|
} else {
|
||||||
debounce(this, this._updatePreview, 30);
|
debounce(this, this._updatePreview, 30);
|
||||||
|
@ -10,7 +10,7 @@ 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, { INPUT_DELAY } from "discourse-common/config/environment";
|
import { isTesting, INPUT_DELAY } from "discourse-common/config/environment";
|
||||||
|
|
||||||
const PER_ROW = 11;
|
const PER_ROW = 11;
|
||||||
function customEmojis() {
|
function customEmojis() {
|
||||||
@ -525,7 +525,7 @@ export default Component.extend({
|
|||||||
this.$picker.css(_.merge(attributes, options));
|
this.$picker.css(_.merge(attributes, options));
|
||||||
};
|
};
|
||||||
|
|
||||||
if (ENV.environment === "test" || !this.automaticPositioning) {
|
if (isTesting() || !this.automaticPositioning) {
|
||||||
desktopPositioning();
|
desktopPositioning();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ import {
|
|||||||
REMINDER_TYPE,
|
REMINDER_TYPE,
|
||||||
DELETE_REPLIES_TYPE
|
DELETE_REPLIES_TYPE
|
||||||
} from "discourse/controllers/edit-topic-timer";
|
} from "discourse/controllers/edit-topic-timer";
|
||||||
import ENV from "discourse-common/config/environment";
|
import { isTesting } from "discourse-common/config/environment";
|
||||||
|
|
||||||
export default Component.extend({
|
export default Component.extend({
|
||||||
classNames: ["topic-status-info"],
|
classNames: ["topic-status-info"],
|
||||||
@ -92,7 +92,7 @@ export default Component.extend({
|
|||||||
});
|
});
|
||||||
|
|
||||||
// TODO Sam: concerned this can cause a heavy rerender loop
|
// TODO Sam: concerned this can cause a heavy rerender loop
|
||||||
if (ENV.environment !== "test") {
|
if (!isTesting()) {
|
||||||
this._delayedRerender = later(() => {
|
this._delayedRerender = later(() => {
|
||||||
this.renderTopicTimer();
|
this.renderTopicTimer();
|
||||||
}, rerenderDelay);
|
}, rerenderDelay);
|
||||||
|
@ -23,7 +23,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";
|
import { isTesting } from "discourse-common/config/environment";
|
||||||
import EmberObject, { computed, action } from "@ember/object";
|
import EmberObject, { computed, action } from "@ember/object";
|
||||||
import deprecated from "discourse-common/lib/deprecated";
|
import deprecated from "discourse-common/lib/deprecated";
|
||||||
|
|
||||||
@ -71,7 +71,7 @@ function loadDraft(store, opts) {
|
|||||||
|
|
||||||
const _popupMenuOptionsCallbacks = [];
|
const _popupMenuOptionsCallbacks = [];
|
||||||
|
|
||||||
let _checkDraftPopup = ENV.environment !== "test";
|
let _checkDraftPopup = !isTesting();
|
||||||
|
|
||||||
export function toggleCheckDraftPopup(enabled) {
|
export function toggleCheckDraftPopup(enabled) {
|
||||||
_checkDraftPopup = enabled;
|
_checkDraftPopup = enabled;
|
||||||
@ -1109,7 +1109,7 @@ export default Controller.extend({
|
|||||||
if (model.draftSaving) {
|
if (model.draftSaving) {
|
||||||
// in test debounce is Ember.run, this will cause
|
// in test debounce is Ember.run, this will cause
|
||||||
// an infinite loop
|
// an infinite loop
|
||||||
if (ENV.environment !== "test") {
|
if (!isTesting()) {
|
||||||
this._saveDraftDebounce = debounce(this, this._saveDraft, 2000);
|
this._saveDraftDebounce = debounce(this, this._saveDraft, 2000);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -1,6 +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";
|
import { isDevelopment } from "discourse-common/config/environment";
|
||||||
import Handlebars from "handlebars";
|
import Handlebars from "handlebars";
|
||||||
|
|
||||||
// Use the message bus for live reloading of components for faster development.
|
// Use the message bus for live reloading of components for faster development.
|
||||||
@ -48,7 +48,7 @@ export default {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Useful to export this for debugging purposes
|
// Useful to export this for debugging purposes
|
||||||
if (Discourse.Environment === "development" && ENV.environment !== "test") {
|
if (isDevelopment()) {
|
||||||
window.DiscourseURL = DiscourseURL;
|
window.DiscourseURL = DiscourseURL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
// Initialize the message bus to receive messages.
|
// Initialize the message bus to receive messages.
|
||||||
import userPresent from "discourse/lib/user-presence";
|
import userPresent from "discourse/lib/user-presence";
|
||||||
import { handleLogoff } from "discourse/lib/ajax";
|
import { handleLogoff } from "discourse/lib/ajax";
|
||||||
|
import { isProduction } from "discourse-common/config/environment";
|
||||||
|
|
||||||
const LONG_POLL_AFTER_UNSEEN_TIME = 1200000; // 20 minutes
|
const LONG_POLL_AFTER_UNSEEN_TIME = 1200000; // 20 minutes
|
||||||
|
|
||||||
@ -32,7 +33,7 @@ export default {
|
|||||||
user = container.lookup("current-user:main"),
|
user = container.lookup("current-user:main"),
|
||||||
siteSettings = container.lookup("site-settings:main");
|
siteSettings = container.lookup("site-settings:main");
|
||||||
|
|
||||||
messageBus.alwaysLongPoll = Discourse.Environment === "development";
|
messageBus.alwaysLongPoll = !isProduction();
|
||||||
messageBus.shouldLongPollCallback = () =>
|
messageBus.shouldLongPollCallback = () =>
|
||||||
userPresent(LONG_POLL_AFTER_UNSEEN_TIME);
|
userPresent(LONG_POLL_AFTER_UNSEEN_TIME);
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ import {
|
|||||||
unsubscribe as unsubscribePushNotifications,
|
unsubscribe as unsubscribePushNotifications,
|
||||||
isPushNotificationsEnabled
|
isPushNotificationsEnabled
|
||||||
} from "discourse/lib/push-notifications";
|
} from "discourse/lib/push-notifications";
|
||||||
import ENV from "discourse-common/config/environment";
|
import { isTesting } from "discourse-common/config/environment";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "subscribe-user-notifications",
|
name: "subscribe-user-notifications",
|
||||||
@ -130,7 +130,7 @@ export default {
|
|||||||
Discourse.set("assetVersion", data)
|
Discourse.set("assetVersion", data)
|
||||||
);
|
);
|
||||||
|
|
||||||
if (ENV.environment !== "test") {
|
if (!isTesting()) {
|
||||||
bus.subscribe(alertChannel(user), data => onNotification(data, user));
|
bus.subscribe(alertChannel(user), data => onNotification(data, user));
|
||||||
initDesktopNotifications(bus, appEvents);
|
initDesktopNotifications(bus, appEvents);
|
||||||
|
|
||||||
|
@ -5,7 +5,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";
|
import { isTesting } from "discourse-common/config/environment";
|
||||||
import User from "discourse/models/user";
|
import User from "discourse/models/user";
|
||||||
|
|
||||||
export function isValidLink($link) {
|
export function isValidLink($link) {
|
||||||
@ -101,7 +101,7 @@ export default {
|
|||||||
|
|
||||||
let trackPromise = Promise.resolve();
|
let trackPromise = Promise.resolve();
|
||||||
if (tracking) {
|
if (tracking) {
|
||||||
if (ENV.environment !== "test" && navigator.sendBeacon) {
|
if (!isTesting() && 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);
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import ENV from "discourse-common/config/environment";
|
import { isTesting } from "discourse-common/config/environment";
|
||||||
import AppEvents from "discourse/services/app-events";
|
import AppEvents from "discourse/services/app-events";
|
||||||
|
|
||||||
let _skipUpdate;
|
let _skipUpdate;
|
||||||
@ -9,7 +9,7 @@ export function configureEyeline(opts) {
|
|||||||
_skipUpdate = opts.skipUpdate;
|
_skipUpdate = opts.skipUpdate;
|
||||||
_rootElement = opts.rootElement;
|
_rootElement = opts.rootElement;
|
||||||
} else {
|
} else {
|
||||||
_skipUpdate = ENV.environment === "test";
|
_skipUpdate = isTesting();
|
||||||
_rootElement = null;
|
_rootElement = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import ENV from "discourse-common/config/environment";
|
import { isTesting } from "discourse-common/config/environment";
|
||||||
|
|
||||||
let mobileForced = false;
|
let mobileForced = false;
|
||||||
|
|
||||||
@ -12,7 +12,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 (ENV.environment === "test" || mobileForced) {
|
if (isTesting() || mobileForced) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
import EmberRouter from "@ember/routing/router";
|
import EmberRouter from "@ember/routing/router";
|
||||||
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";
|
|
||||||
import Site from "discourse/models/site";
|
import Site from "discourse/models/site";
|
||||||
|
import { isTesting } from "discourse-common/config/environment";
|
||||||
|
|
||||||
const rootURL = Discourse.BaseUri;
|
const rootURL = Discourse.BaseUri;
|
||||||
|
|
||||||
const BareRouter = EmberRouter.extend({
|
const BareRouter = EmberRouter.extend({
|
||||||
rootURL,
|
rootURL,
|
||||||
location: ENV.environment === "test" ? "none" : "discourse-location",
|
location: isTesting() ? "none" : "discourse-location",
|
||||||
|
|
||||||
handleURL(url) {
|
handleURL(url) {
|
||||||
url = rewritePath(url);
|
url = rewritePath(url);
|
||||||
|
@ -2,11 +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";
|
import { isTesting } from "discourse-common/config/environment";
|
||||||
|
|
||||||
const context = {
|
const context = {
|
||||||
_scrollTop() {
|
_scrollTop() {
|
||||||
if (ENV.environment === "test") {
|
if (isTesting()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$(document).scrollTop(0);
|
$(document).scrollTop(0);
|
||||||
|
@ -80,11 +80,6 @@ const Site = RestModel.extend({
|
|||||||
return result;
|
return result;
|
||||||
},
|
},
|
||||||
|
|
||||||
@discourseComputed
|
|
||||||
baseUri() {
|
|
||||||
return Discourse.baseUri;
|
|
||||||
},
|
|
||||||
|
|
||||||
// Returns it in the correct order, by setting
|
// Returns it in the correct order, by setting
|
||||||
@discourseComputed("categories.[]")
|
@discourseComputed("categories.[]")
|
||||||
categoriesList() {
|
categoriesList() {
|
||||||
|
@ -2,7 +2,11 @@ import PreloadStore from "discourse/lib/preload-store";
|
|||||||
import I18n from "I18n";
|
import I18n from "I18n";
|
||||||
import Session from "discourse/models/session";
|
import Session from "discourse/models/session";
|
||||||
import RSVP from "rsvp";
|
import RSVP from "rsvp";
|
||||||
import { isTesting } from "discourse-common/config/environment";
|
import {
|
||||||
|
setEnvironment,
|
||||||
|
isTesting,
|
||||||
|
isProduction
|
||||||
|
} from "discourse-common/config/environment";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "discourse-bootstrap",
|
name: "discourse-bootstrap",
|
||||||
@ -33,7 +37,7 @@ export default {
|
|||||||
app.CDN = setupData.cdn;
|
app.CDN = setupData.cdn;
|
||||||
app.BaseUrl = setupData.baseUrl;
|
app.BaseUrl = setupData.baseUrl;
|
||||||
app.BaseUri = setupData.baseUri;
|
app.BaseUri = setupData.baseUri;
|
||||||
app.Environment = setupData.environment;
|
setEnvironment(setupData.environment);
|
||||||
app.SiteSettings = PreloadStore.get("siteSettings");
|
app.SiteSettings = PreloadStore.get("siteSettings");
|
||||||
app.ThemeSettings = PreloadStore.get("themeSettings");
|
app.ThemeSettings = PreloadStore.get("themeSettings");
|
||||||
app.LetterAvatarVersion = setupData.letterAvatarVersion;
|
app.LetterAvatarVersion = setupData.letterAvatarVersion;
|
||||||
@ -73,7 +77,7 @@ export default {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Discourse.Environment === "development") {
|
if (!isProduction()) {
|
||||||
/* eslint-disable no-console */
|
/* eslint-disable no-console */
|
||||||
if (e) {
|
if (e) {
|
||||||
if (e.message || e.stack) {
|
if (e.message || e.stack) {
|
||||||
|
@ -3,7 +3,7 @@ import { schedule } 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";
|
import { isTesting } 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({
|
||||||
@ -81,7 +81,7 @@ export default DiscourseRoute.extend({
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(e => {
|
.catch(e => {
|
||||||
if (ENV.environment !== "test") {
|
if (!isTesting()) {
|
||||||
// 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);
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@ import { cancel, 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";
|
import { isTesting } from "discourse-common/config/environment";
|
||||||
|
|
||||||
export default class WidgetGlue {
|
export default class WidgetGlue {
|
||||||
constructor(name, register, attrs) {
|
constructor(name, register, attrs) {
|
||||||
@ -34,7 +34,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 (ENV.environment === "test") {
|
if (isTesting()) {
|
||||||
try {
|
try {
|
||||||
this.register.lookup("service:store");
|
this.register.lookup("service:store");
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
@ -4,14 +4,14 @@ 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";
|
import { isTesting } from "discourse-common/config/environment";
|
||||||
import { formattedReminderTime } from "discourse/lib/bookmark";
|
import { formattedReminderTime } from "discourse/lib/bookmark";
|
||||||
|
|
||||||
const LIKE_ACTION = 2;
|
const LIKE_ACTION = 2;
|
||||||
const VIBRATE_DURATION = 5;
|
const VIBRATE_DURATION = 5;
|
||||||
|
|
||||||
function animateHeart($elem, start, end, complete) {
|
function animateHeart($elem, start, end, complete) {
|
||||||
if (ENV.environment === "test") {
|
if (isTesting()) {
|
||||||
return run(this, complete);
|
return run(this, complete);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,7 +16,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";
|
import { isProduction } from "discourse-common/config/environment";
|
||||||
import { get } from "@ember/object";
|
import { get } from "@ember/object";
|
||||||
|
|
||||||
const _registry = {};
|
const _registry = {};
|
||||||
@ -127,7 +127,7 @@ export default class Widget {
|
|||||||
this.init(this.attrs);
|
this.init(this.attrs);
|
||||||
|
|
||||||
// Helps debug widgets
|
// Helps debug widgets
|
||||||
if (Discourse.Environment === "development" || ENV.environment === "test") {
|
if (!isProduction()) {
|
||||||
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`);
|
||||||
|
@ -2,7 +2,12 @@ import MultiSelectComponent from "select-kit/components/multi-select";
|
|||||||
import { computed } from "@ember/object";
|
import { computed } from "@ember/object";
|
||||||
import { ajax } from "discourse/lib/ajax";
|
import { ajax } from "discourse/lib/ajax";
|
||||||
import { makeArray } from "discourse-common/lib/helpers";
|
import { makeArray } from "discourse-common/lib/helpers";
|
||||||
import { convertIconClass } from "discourse-common/lib/icon-library";
|
import {
|
||||||
|
convertIconClass,
|
||||||
|
disableMissingIconWarning,
|
||||||
|
enableMissingIconWarning
|
||||||
|
} from "discourse-common/lib/icon-library";
|
||||||
|
import { isDevelopment } from "discourse-common/config/environment";
|
||||||
|
|
||||||
export default MultiSelectComponent.extend({
|
export default MultiSelectComponent.extend({
|
||||||
pluginApiIdentifiers: ["icon-picker"],
|
pluginApiIdentifiers: ["icon-picker"],
|
||||||
@ -13,8 +18,8 @@ export default MultiSelectComponent.extend({
|
|||||||
|
|
||||||
this._cachedIconsList = null;
|
this._cachedIconsList = null;
|
||||||
|
|
||||||
if (Discourse.Environment === "development") {
|
if (isDevelopment()) {
|
||||||
Discourse.disableMissingIconWarning = true;
|
disableMissingIconWarning();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -75,8 +80,8 @@ export default MultiSelectComponent.extend({
|
|||||||
|
|
||||||
this._cachedIconsList = null;
|
this._cachedIconsList = null;
|
||||||
|
|
||||||
if (Discourse.Environment === "development") {
|
if (isDevelopment()) {
|
||||||
delete Discourse.disableMissingIconWarning;
|
enableMissingIconWarning();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
import EmberRouter from "@ember/routing/router";
|
import EmberRouter from "@ember/routing/router";
|
||||||
import getUrl from "discourse-common/lib/get-url";
|
import getUrl from "discourse-common/lib/get-url";
|
||||||
import ENV from "discourse-common/config/environment";
|
import { isTesting } from "discourse-common/config/environment";
|
||||||
|
|
||||||
const Router = EmberRouter.extend({
|
const Router = EmberRouter.extend({
|
||||||
rootURL: getUrl("/wizard/"),
|
rootURL: getUrl("/wizard/"),
|
||||||
location: ENV.environment === "test" ? "none" : "history"
|
location: isTesting() ? "none" : "history"
|
||||||
});
|
});
|
||||||
|
|
||||||
Router.map(function() {
|
Router.map(function() {
|
||||||
|
Loading…
Reference in New Issue
Block a user