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:
Robin Ward
2020-06-01 16:33:43 -04:00
committed by GitHub
parent 9162cd8f3d
commit a95826f60c
26 changed files with 92 additions and 62 deletions

View File

@@ -1,9 +1,23 @@
export const INPUT_DELAY = 250;
let environment = Ember.testing ? "test" : "development";
let environment = "unknown";
export function isTesting() {
return environment === "test";
export function setEnvironment(e) {
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";
}

View File

@@ -1,10 +1,13 @@
import I18n from "I18n";
import { h } from "virtual-dom";
import attributeHook from "discourse-common/lib/attribute-hook";
import { isDevelopment } from "discourse-common/config/environment";
const SVG_NAMESPACE = "http://www.w3.org/2000/svg";
let _renderers = [];
let warnMissingIcons = true;
const REPLACEMENTS = {
"d-tracking": "bell",
"d-muted": "discourse-bell-slash",
@@ -45,6 +48,14 @@ export function replaceIcon(source, destination) {
REPLACEMENTS[source] = destination;
}
export function disableMissingIconWarning() {
warnMissingIcons = false;
}
export function enableMissingIconWarning() {
warnMissingIcons = false;
}
export function renderIcon(renderType, id, params) {
for (let i = 0; i < _renderers.length; i++) {
let renderer = _renderers[i];
@@ -105,8 +116,8 @@ function iconClasses(icon, params) {
function warnIfMissing(id) {
if (
typeof Discourse !== "undefined" &&
Discourse.Environment === "development" &&
!Discourse.disableMissingIconWarning &&
isDevelopment() &&
warnMissingIcons &&
Discourse.SvgIconList &&
Discourse.SvgIconList.indexOf(id) === -1
) {