DEV: prettier 2.2.1 (#11862)

This commit is contained in:
Joffrey JAFFEUX 2021-01-27 12:39:20 +01:00 committed by GitHub
parent 7be556fc19
commit c6a1042950
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
117 changed files with 2495 additions and 2433 deletions

View File

@ -1,3 +1,4 @@
app/assets/javascripts/discourse-loader.js
app/assets/javascripts/env.js app/assets/javascripts/env.js
app/assets/javascripts/main_include_admin.js app/assets/javascripts/main_include_admin.js
app/assets/javascripts/vendor.js app/assets/javascripts/vendor.js

View File

@ -6,6 +6,7 @@ config/locales/**/*.yml
!config/locales/**/*.en*.yml !config/locales/**/*.en*.yml
script/import_scripts/**/*.yml script/import_scripts/**/*.yml
app/assets/javascripts/discourse-loader.js
app/assets/javascripts/env.js app/assets/javascripts/env.js
app/assets/javascripts/main_include_admin.js app/assets/javascripts/main_include_admin.js
app/assets/javascripts/vendor.js app/assets/javascripts/vendor.js

View File

@ -10,7 +10,7 @@ export default Component.extend({
const model = this.model; const model = this.model;
const rawData = this.get("model.data"); const rawData = this.get("model.data");
var data = { let data = {
labels: rawData.map((r) => r.x), labels: rawData.map((r) => r.x),
datasets: [ datasets: [
{ {

View File

@ -94,9 +94,9 @@ export default Component.extend({
_splitValues(values, delimiter) { _splitValues(values, delimiter) {
if (values && values.length) { if (values && values.length) {
const keys = ["key", "secret"]; const keys = ["key", "secret"];
var res = []; let res = [];
values.split(delimiter).forEach(function (str) { values.split(delimiter).forEach(function (str) {
var object = {}; let object = {};
str.split("|").forEach(function (a, i) { str.split("|").forEach(function (a, i) {
object[keys[i]] = a; object[keys[i]] = a;
}); });

View File

@ -110,7 +110,7 @@ export default Controller.extend(bufferedProperty("model"), {
const data = {}; const data = {};
const buffered = this.buffered; const buffered = this.buffered;
fields.forEach(function (field) { fields.forEach(function (field) {
var d = buffered.get(field); let d = buffered.get(field);
if (boolFields.includes(field)) { if (boolFields.includes(field)) {
d = !!d; d = !!d;
} }

View File

@ -53,9 +53,9 @@ export default Controller.extend({
// Only confirm if we already been saved // Only confirm if we already been saved
if (f.get("id")) { if (f.get("id")) {
bootbox.confirm(I18n.t("admin.user_fields.delete_confirm"), function ( bootbox.confirm(
result I18n.t("admin.user_fields.delete_confirm"),
) { function (result) {
if (result) { if (result) {
f.destroyRecord() f.destroyRecord()
.then(function () { .then(function () {
@ -63,7 +63,8 @@ export default Controller.extend({
}) })
.catch(popupAjaxError); .catch(popupAjaxError);
} }
}); }
);
} else { } else {
model.removeObject(f); model.removeObject(f);
} }

View File

@ -1,9 +1,9 @@
import { registerUnbound } from "discourse-common/lib/helpers"; import { registerUnbound } from "discourse-common/lib/helpers";
registerUnbound("value-at-tl", function (data, params) { registerUnbound("value-at-tl", function (data, params) {
var tl = parseInt(params.level, 10); let tl = parseInt(params.level, 10);
if (data) { if (data) {
var item = data.find(function (d) { let item = data.find(function (d) {
return parseInt(d.x, 10) === tl; return parseInt(d.x, 10) === tl;
}); });
if (item) { if (item) {

View File

@ -14,7 +14,7 @@ export default DiscourseRoute.extend({
Badge.findAll().then(function (badges) { Badge.findAll().then(function (badges) {
controller.set("badges", badges); controller.set("badges", badges);
if (badges.length > 0) { if (badges.length > 0) {
var grantableBadges = controller.get("grantableBadges"); let grantableBadges = controller.get("grantableBadges");
if (grantableBadges.length > 0) { if (grantableBadges.length > 0) {
controller.set("selectedBadgeId", grantableBadges[0].get("id")); controller.set("selectedBadgeId", grantableBadges[0].get("id"));
} }

View File

@ -2,10 +2,10 @@
//Copyright (c) 2007-2009, MIT Style License <browser-update.org/LICENSE.txt> //Copyright (c) 2007-2009, MIT Style License <browser-update.org/LICENSE.txt>
(function () { (function () {
var $buo = function () { let $buo = function () {
// Sometimes we have to resort to parsing the user agent string. :( // Sometimes we have to resort to parsing the user agent string. :(
if (navigator && navigator.userAgent) { if (navigator && navigator.userAgent) {
var ua = navigator.userAgent; let ua = navigator.userAgent;
// we don't ask Googlebot to update their browser // we don't ask Googlebot to update their browser
if ( if (
@ -22,10 +22,10 @@
} }
document.getElementsByTagName("body")[0].className += " crawler"; document.getElementsByTagName("body")[0].className += " crawler";
var mainElement = document.getElementById("main"); let mainElement = document.getElementById("main");
var noscriptElements = document.getElementsByTagName("noscript"); let noscriptElements = document.getElementsByTagName("noscript");
// find the element with the "data-path" attribute set // find the element with the "data-path" attribute set
for (var i = 0; i < noscriptElements.length; ++i) { for (let i = 0; i < noscriptElements.length; ++i) {
if (noscriptElements[i].getAttribute("data-path")) { if (noscriptElements[i].getAttribute("data-path")) {
// noscriptElements[i].innerHTML contains encoded HTML // noscriptElements[i].innerHTML contains encoded HTML
if (noscriptElements[i].childNodes.length > 0) { if (noscriptElements[i].childNodes.length > 0) {
@ -36,7 +36,7 @@
} }
// retrieve localized browser upgrade text // retrieve localized browser upgrade text
var t = I18n.t("browser_update"); // eslint-disable-line no-undef let t = I18n.t("browser_update"); // eslint-disable-line no-undef
if (t.indexOf(".browser_update]") !== -1) { if (t.indexOf(".browser_update]") !== -1) {
// very old browsers might fail to load even translations // very old browsers might fail to load even translations
t = t =
@ -44,13 +44,13 @@
} }
// create the notification div HTML // create the notification div HTML
var div = document.createElement("div"); let div = document.createElement("div");
div.className = "buorg"; div.className = "buorg";
div.innerHTML = "<div>" + t + "</div>"; div.innerHTML = "<div>" + t + "</div>";
// create the notification div stylesheet // create the notification div stylesheet
var sheet = document.createElement("style"); let sheet = document.createElement("style");
var style = let style =
".buorg {position:absolute; z-index:111111; width:100%; top:0px; left:0px; background:#FDF2AB; text-align:left; font-family: sans-serif; color:#000; font-size: 14px;} .buorg div {padding: 8px;} .buorg a, .buorg a:visited {color:#E25600; text-decoration: underline;} @media print { .buorg { display: none !important; } }"; ".buorg {position:absolute; z-index:111111; width:100%; top:0px; left:0px; background:#FDF2AB; text-align:left; font-family: sans-serif; color:#000; font-size: 14px;} .buorg div {padding: 8px;} .buorg a, .buorg a:visited {color:#E25600; text-decoration: underline;} @media print { .buorg { display: none !important; } }";
// insert the div and stylesheet into the DOM // insert the div and stylesheet into the DOM

View File

@ -32,8 +32,8 @@ AttributeHook.prototype.unhook = function (node, prop, next) {
return; return;
} }
var colonPosition = prop.indexOf(":"); let colonPosition = prop.indexOf(":");
var localName = colonPosition > -1 ? prop.substr(colonPosition + 1) : prop; let localName = colonPosition > -1 ? prop.substr(colonPosition + 1) : prop;
node.removeAttributeNS(this.namespace, localName); node.removeAttributeNS(this.namespace, localName);
}; };

View File

@ -22,7 +22,7 @@ const _helpers = {};
function rawGet(ctx, property, options) { function rawGet(ctx, property, options) {
if (options.types && options.data.view) { if (options.types && options.data.view) {
var view = options.data.view; let view = options.data.view;
return view.getStream return view.getStream
? view.getStream(property).value() ? view.getStream(property).value()
: view.getAttr(property); : view.getAttr(property);

View File

@ -47,7 +47,7 @@ export function deepEqual(obj1, obj2) {
if (Object.keys(obj1).length !== Object.keys(obj2).length) { if (Object.keys(obj1).length !== Object.keys(obj2).length) {
return false; return false;
} }
for (var prop in obj1) { for (let prop in obj1) {
if (!deepEqual(obj1[prop], obj2[prop])) { if (!deepEqual(obj1[prop], obj2[prop])) {
return false; return false;
} }

View File

@ -29,24 +29,22 @@ export function registerRawHelpers(hbs, handlebarsClass) {
}; };
// #each .. in support (as format is transformed to this) // #each .. in support (as format is transformed to this)
hbs.registerHelper("each", function ( hbs.registerHelper(
localName, "each",
inKeyword, function (localName, inKeyword, contextName, options) {
contextName,
options
) {
if (typeof contextName === "undefined") { if (typeof contextName === "undefined") {
return; return;
} }
var list = get(this, contextName); let list = get(this, contextName);
var output = []; let output = [];
for (var i = 0; i < list.length; i++) { for (let i = 0; i < list.length; i++) {
let innerContext = {}; let innerContext = {};
innerContext[localName] = list[i]; innerContext[localName] = list[i];
output.push(options.fn(innerContext)); output.push(options.fn(innerContext));
} }
return output.join(""); return output.join("");
}); }
);
function stringCompatHelper(fn) { function stringCompatHelper(fn) {
const old = hbs.helpers[fn]; const old = hbs.helpers[fn];

View File

@ -6,7 +6,7 @@ import Handlebars from "handlebars";
const RawHandlebars = Handlebars.create(); const RawHandlebars = Handlebars.create();
function buildPath(blk, args) { function buildPath(blk, args) {
var result = { let result = {
type: "PathExpression", type: "PathExpression",
data: false, data: false,
depth: blk.path.depth, depth: blk.path.depth,
@ -22,7 +22,7 @@ function buildPath(blk, args) {
} }
function replaceGet(ast) { function replaceGet(ast) {
var visitor = new Handlebars.Visitor(); let visitor = new Handlebars.Visitor();
visitor.mutating = true; visitor.mutating = true;
visitor.MustacheStatement = function (mustache) { visitor.MustacheStatement = function (mustache) {
@ -42,7 +42,7 @@ function replaceGet(ast) {
// This allows us to use the same syntax in all templates // This allows us to use the same syntax in all templates
visitor.BlockStatement = function (block) { visitor.BlockStatement = function (block) {
if (block.path.original === "each" && block.params.length === 1) { if (block.path.original === "each" && block.params.length === 1) {
var paramName = block.program.blockParams[0]; let paramName = block.program.blockParams[0];
block.params = [ block.params = [
buildPath(block, { original: paramName }), buildPath(block, { original: paramName }),
{ type: "CommentStatement", value: "in" }, { type: "CommentStatement", value: "in" },
@ -74,10 +74,10 @@ if (Handlebars.Compiler) {
RawHandlebars.JavaScriptCompiler.prototype.namespace = "RawHandlebars"; RawHandlebars.JavaScriptCompiler.prototype.namespace = "RawHandlebars";
RawHandlebars.precompile = function (value, asObject) { RawHandlebars.precompile = function (value, asObject) {
var ast = Handlebars.parse(value); let ast = Handlebars.parse(value);
replaceGet(ast); replaceGet(ast);
var options = { let options = {
knownHelpers: { knownHelpers: {
get: true, get: true,
}, },
@ -87,7 +87,7 @@ if (Handlebars.Compiler) {
asObject = asObject === undefined ? true : asObject; asObject = asObject === undefined ? true : asObject;
var environment = new RawHandlebars.Compiler().compile(ast, options); let environment = new RawHandlebars.Compiler().compile(ast, options);
return new RawHandlebars.JavaScriptCompiler().compile( return new RawHandlebars.JavaScriptCompiler().compile(
environment, environment,
options, options,
@ -97,20 +97,20 @@ if (Handlebars.Compiler) {
}; };
RawHandlebars.compile = function (string) { RawHandlebars.compile = function (string) {
var ast = Handlebars.parse(string); let ast = Handlebars.parse(string);
replaceGet(ast); replaceGet(ast);
// this forces us to rewrite helpers // this forces us to rewrite helpers
var options = { data: true, stringParams: true }; let options = { data: true, stringParams: true };
var environment = new RawHandlebars.Compiler().compile(ast, options); let environment = new RawHandlebars.Compiler().compile(ast, options);
var templateSpec = new RawHandlebars.JavaScriptCompiler().compile( let templateSpec = new RawHandlebars.JavaScriptCompiler().compile(
environment, environment,
options, options,
undefined, undefined,
true true
); );
var t = RawHandlebars.template(templateSpec); let t = RawHandlebars.template(templateSpec);
t.isMethod = false; t.isMethod = false;
return t; return t;

View File

@ -111,7 +111,7 @@ export function buildResolver(baseName) {
); );
}); });
var module; let module;
if (moduleName) { if (moduleName) {
module = requirejs(moduleName, null, null, true /* force sync */); module = requirejs(moduleName, null, null, true /* force sync */);
if (module && module["default"]) { if (module && module["default"]) {
@ -200,7 +200,7 @@ export function buildResolver(baseName) {
findPluginMobileTemplate(parsedName) { findPluginMobileTemplate(parsedName) {
if (_options.mobileView) { if (_options.mobileView) {
var pluginParsedName = this.parseName( let pluginParsedName = this.parseName(
parsedName.fullName.replace( parsedName.fullName.replace(
"template:", "template:",
"template:javascripts/mobile/" "template:javascripts/mobile/"
@ -212,7 +212,7 @@ export function buildResolver(baseName) {
findMobileTemplate(parsedName) { findMobileTemplate(parsedName) {
if (_options.mobileView) { if (_options.mobileView) {
var mobileParsedName = this.parseName( let mobileParsedName = this.parseName(
parsedName.fullName.replace("template:", "template:mobile/") parsedName.fullName.replace("template:", "template:mobile/")
); );
return this.findTemplate(mobileParsedName); return this.findTemplate(mobileParsedName);
@ -241,15 +241,15 @@ export function buildResolver(baseName) {
}, },
findUnderscoredTemplate(parsedName) { findUnderscoredTemplate(parsedName) {
var decamelized = parsedName.fullNameWithoutType.decamelize(); let decamelized = parsedName.fullNameWithoutType.decamelize();
var underscored = decamelized.replace(/\-/g, "_"); let underscored = decamelized.replace(/\-/g, "_");
return Ember.TEMPLATES[underscored]; return Ember.TEMPLATES[underscored];
}, },
// Try to find a template within a special admin namespace, e.g. adminEmail => admin/templates/email // Try to find a template within a special admin namespace, e.g. adminEmail => admin/templates/email
// (similar to how discourse lays out templates) // (similar to how discourse lays out templates)
findAdminTemplate(parsedName) { findAdminTemplate(parsedName) {
var decamelized = parsedName.fullNameWithoutType.decamelize(); let decamelized = parsedName.fullNameWithoutType.decamelize();
if (decamelized.indexOf("components") === 0) { if (decamelized.indexOf("components") === 0) {
let comPath = `admin/templates/${decamelized}`; let comPath = `admin/templates/${decamelized}`;
const compTemplate = const compTemplate =

View File

@ -12,7 +12,7 @@ export default function decoratorAlias(fn, errorMessage) {
configurable: desc.configurable, configurable: desc.configurable,
writable: desc.writable, writable: desc.writable,
initializer: function () { initializer: function () {
var value = extractValue(desc); let value = extractValue(desc);
return fn.apply(null, params.concat(value)); return fn.apply(null, params.concat(value));
}, },
}; };

View File

@ -51,7 +51,7 @@ export function readOnly(target, name, desc) {
enumerable: desc.enumerable, enumerable: desc.enumerable,
configurable: desc.configurable, configurable: desc.configurable,
initializer: function () { initializer: function () {
var value = extractValue(desc); let value = extractValue(desc);
return value.readOnly(); return value.readOnly();
}, },
}; };

View File

@ -10,7 +10,7 @@ export default function handleDescriptor(target, key, desc, params = []) {
let computedDescriptor; let computedDescriptor;
if (desc.writable) { if (desc.writable) {
var val = extractValue(desc); let val = extractValue(desc);
if (typeof val === "object") { if (typeof val === "object") {
let value = {}; let value = {};
if (val.get) { if (val.get) {

View File

@ -6,7 +6,7 @@ const Handlebars = require("handlebars");
const RawHandlebars = Handlebars.create(); const RawHandlebars = Handlebars.create();
function buildPath(blk, args) { function buildPath(blk, args) {
var result = { let result = {
type: "PathExpression", type: "PathExpression",
data: false, data: false,
depth: blk.path.depth, depth: blk.path.depth,
@ -22,7 +22,7 @@ function buildPath(blk, args) {
} }
function replaceGet(ast) { function replaceGet(ast) {
var visitor = new Handlebars.Visitor(); let visitor = new Handlebars.Visitor();
visitor.mutating = true; visitor.mutating = true;
visitor.MustacheStatement = function (mustache) { visitor.MustacheStatement = function (mustache) {
@ -42,7 +42,7 @@ function replaceGet(ast) {
// This allows us to use the same syntax in all templates // This allows us to use the same syntax in all templates
visitor.BlockStatement = function (block) { visitor.BlockStatement = function (block) {
if (block.path.original === "each" && block.params.length === 1) { if (block.path.original === "each" && block.params.length === 1) {
var paramName = block.program.blockParams[0]; let paramName = block.program.blockParams[0];
block.params = [ block.params = [
buildPath(block, { original: paramName }), buildPath(block, { original: paramName }),
{ type: "CommentStatement", value: "in" }, { type: "CommentStatement", value: "in" },
@ -71,10 +71,10 @@ RawHandlebars.JavaScriptCompiler.prototype.compiler =
RawHandlebars.JavaScriptCompiler.prototype.namespace = "RawHandlebars"; RawHandlebars.JavaScriptCompiler.prototype.namespace = "RawHandlebars";
RawHandlebars.precompile = function (value, asObject) { RawHandlebars.precompile = function (value, asObject) {
var ast = Handlebars.parse(value); let ast = Handlebars.parse(value);
replaceGet(ast); replaceGet(ast);
var options = { let options = {
knownHelpers: { knownHelpers: {
get: true, get: true,
}, },
@ -84,7 +84,7 @@ RawHandlebars.precompile = function (value, asObject) {
asObject = asObject === undefined ? true : asObject; asObject = asObject === undefined ? true : asObject;
var environment = new RawHandlebars.Compiler().compile(ast, options); let environment = new RawHandlebars.Compiler().compile(ast, options);
return new RawHandlebars.JavaScriptCompiler().compile( return new RawHandlebars.JavaScriptCompiler().compile(
environment, environment,
options, options,
@ -94,20 +94,20 @@ RawHandlebars.precompile = function (value, asObject) {
}; };
RawHandlebars.compile = function (string) { RawHandlebars.compile = function (string) {
var ast = Handlebars.parse(string); let ast = Handlebars.parse(string);
replaceGet(ast); replaceGet(ast);
// this forces us to rewrite helpers // this forces us to rewrite helpers
var options = { data: true, stringParams: true }; let options = { data: true, stringParams: true };
var environment = new RawHandlebars.Compiler().compile(ast, options); let environment = new RawHandlebars.Compiler().compile(ast, options);
var templateSpec = new RawHandlebars.JavaScriptCompiler().compile( let templateSpec = new RawHandlebars.JavaScriptCompiler().compile(
environment, environment,
options, options,
undefined, undefined,
true true
); );
var t = RawHandlebars.template(templateSpec); let t = RawHandlebars.template(templateSpec);
t.isMethod = false; t.isMethod = false;
return t; return t;

View File

@ -5,12 +5,12 @@ import discourseComputed from "discourse-common/utils/decorators";
// https://developer.mozilla.org/en-US/docs/Web/API/WindowBase64/Base64_encoding_and_decoding // https://developer.mozilla.org/en-US/docs/Web/API/WindowBase64/Base64_encoding_and_decoding
function b64EncodeUnicode(str) { function b64EncodeUnicode(str) {
return btoa( return btoa(
encodeURIComponent(str).replace(/%([0-9A-F]{2})/g, function toSolidBytes( encodeURIComponent(str).replace(
match, /%([0-9A-F]{2})/g,
p1 function toSolidBytes(match, p1) {
) {
return String.fromCharCode("0x" + p1); return String.fromCharCode("0x" + p1);
}) }
)
); );
} }

View File

@ -10,7 +10,7 @@ export default Component.extend({
@discourseComputed("topicList.loaded") @discourseComputed("topicList.loaded")
loaded() { loaded() {
var topicList = this.topicList; let topicList = this.topicList;
if (topicList) { if (topicList) {
return topicList.get("loaded"); return topicList.get("loaded");
} else { } else {

View File

@ -536,10 +536,10 @@ export default Component.extend({
_warnMentionedGroups($preview) { _warnMentionedGroups($preview) {
schedule("afterRender", () => { schedule("afterRender", () => {
var found = this.warnedGroupMentions || []; let found = this.warnedGroupMentions || [];
$preview.find(".mention-group.notify").each((idx, e) => { $preview.find(".mention-group.notify").each((idx, e) => {
const $e = $(e); const $e = $(e);
var name = $e.data("name"); let name = $e.data("name");
if (found.indexOf(name) === -1) { if (found.indexOf(name) === -1) {
this.groupsMentioned([ this.groupsMentioned([
{ {

View File

@ -184,7 +184,7 @@ class Toolbar {
if (button.shortcut) { if (button.shortcut) {
const mac = /Mac|iPod|iPhone|iPad/.test(navigator.platform); const mac = /Mac|iPod|iPhone|iPad/.test(navigator.platform);
const mod = mac ? "Meta" : "Ctrl"; const mod = mac ? "Meta" : "Ctrl";
var shortcutTitle = `${mod}+${button.shortcut}`; let shortcutTitle = `${mod}+${button.shortcut}`;
// Mac users are used to glyphs for shortcut keys // Mac users are used to glyphs for shortcut keys
if (mac) { if (mac) {

View File

@ -28,7 +28,7 @@ export default Component.extend({
@observes("lastShownAt") @observes("lastShownAt")
bounce() { bounce() {
if (this.lastShownAt) { if (this.lastShownAt) {
var $elem = $(this.element); let $elem = $(this.element);
if (!this.animateAttribute) { if (!this.animateAttribute) {
this.animateAttribute = $elem.css("left") === "auto" ? "right" : "left"; this.animateAttribute = $elem.css("left") === "auto" ? "right" : "left";
} }
@ -51,7 +51,7 @@ export default Component.extend({
}, },
bounceLeft($elem) { bounceLeft($elem) {
for (var i = 0; i < 5; i++) { for (let i = 0; i < 5; i++) {
$elem $elem
.animate({ left: "+=" + this.bouncePixels }, this.bounceDelay) .animate({ left: "+=" + this.bouncePixels }, this.bounceDelay)
.animate({ left: "-=" + this.bouncePixels }, this.bounceDelay); .animate({ left: "-=" + this.bouncePixels }, this.bounceDelay);
@ -59,7 +59,7 @@ export default Component.extend({
}, },
bounceRight($elem) { bounceRight($elem) {
for (var i = 0; i < 5; i++) { for (let i = 0; i < 5; i++) {
$elem $elem
.animate({ right: "-=" + this.bouncePixels }, this.bounceDelay) .animate({ right: "-=" + this.bouncePixels }, this.bounceDelay)
.animate({ right: "+=" + this.bouncePixels }, this.bounceDelay); .animate({ right: "+=" + this.bouncePixels }, this.bounceDelay);

View File

@ -163,9 +163,9 @@ export default Component.extend(LoadMore, {
}, },
click(e) { click(e) {
var self = this; let self = this;
var onClick = function (sel, callback) { let onClick = function (sel, callback) {
var target = $(e.target).closest(sel); let target = $(e.target).closest(sel);
if (target.length === 1) { if (target.length === 1) {
callback.apply(self, [target]); callback.apply(self, [target]);

View File

@ -12,7 +12,7 @@ export default Component.extend({
@discourseComputed("badge", "user") @discourseComputed("badge", "user")
badgeUrl() { badgeUrl() {
// NOTE: I tried using a link-to helper here but the queryParams mean it fails // NOTE: I tried using a link-to helper here but the queryParams mean it fails
var username = this.get("user.username_lower") || ""; let username = this.get("user.username_lower") || "";
username = username !== "" ? "?username=" + username : ""; username = username !== "" ? "?username=" + username : "";
return this.get("badge.url") + username; return this.get("badge.url") + username;
}, },

View File

@ -727,7 +727,7 @@ export default Controller.extend({
} }
} }
var staged = false; let staged = false;
// TODO: This should not happen in model // TODO: This should not happen in model
const imageSizes = {}; const imageSizes = {};

View File

@ -77,9 +77,9 @@ export default Controller.extend({
@discourseComputed("context", "context_id") @discourseComputed("context", "context_id")
searchContextDescription(context, id) { searchContextDescription(context, id) {
var name = id; let name = id;
if (context === "category") { if (context === "category") {
var category = Category.findById(id); let category = Category.findById(id);
if (!category) { if (!category) {
return; return;
} }
@ -322,7 +322,7 @@ export default Controller.extend({
}, },
loadMore() { loadMore() {
var page = this.page; let page = this.page;
if ( if (
this.get("model.grouped_search_result.more_full_page_results") && this.get("model.grouped_search_result.more_full_page_results") &&
!this.loading && !this.loading &&

View File

@ -17,7 +17,7 @@ import { sanitizeAsync } from "discourse/lib/text";
function customTagArray(fieldName) { function customTagArray(fieldName) {
return computed(fieldName, function () { return computed(fieldName, function () {
var val = this.get(fieldName); let val = this.get(fieldName);
if (!val) { if (!val) {
return val; return val;
} }
@ -194,7 +194,7 @@ export default Controller.extend(ModalFunctionality, {
if (displayingInline) { if (displayingInline) {
return this.isEitherRevisionHidden ? "hidden-revision-either" : null; return this.isEitherRevisionHidden ? "hidden-revision-either" : null;
} else { } else {
var result = []; let result = [];
if (prevHidden) { if (prevHidden) {
result.push("hidden-revision-previous"); result.push("hidden-revision-previous");
} }
@ -227,7 +227,7 @@ export default Controller.extend(ModalFunctionality, {
@discourseComputed("model.category_id_changes") @discourseComputed("model.category_id_changes")
previousCategory(changes) { previousCategory(changes) {
if (changes) { if (changes) {
var category = Category.findById(changes["previous"]); let category = Category.findById(changes["previous"]);
return categoryBadgeHTML(category, { allowUncategorized: true }); return categoryBadgeHTML(category, { allowUncategorized: true });
} }
}, },
@ -235,7 +235,7 @@ export default Controller.extend(ModalFunctionality, {
@discourseComputed("model.category_id_changes") @discourseComputed("model.category_id_changes")
currentCategory(changes) { currentCategory(changes) {
if (changes) { if (changes) {
var category = Category.findById(changes["current"]); let category = Category.findById(changes["current"]);
return categoryBadgeHTML(category, { allowUncategorized: true }); return categoryBadgeHTML(category, { allowUncategorized: true });
} }
}, },

View File

@ -62,7 +62,7 @@ export default Controller.extend({
@discourseComputed() @discourseComputed()
frequencyEstimate() { frequencyEstimate() {
var estimate = this.get("model.mailing_list_posts_per_day"); let estimate = this.get("model.mailing_list_posts_per_day");
if (!estimate || estimate < 2) { if (!estimate || estimate < 2) {
return I18n.t("user.mailing_list_mode.few_per_day"); return I18n.t("user.mailing_list_mode.few_per_day");
} else { } else {

View File

@ -72,7 +72,7 @@ export default Controller.extend({
} }
const joinedTags = tags.slice(0, displayN).join(", "); const joinedTags = tags.slice(0, displayN).join(", ");
var more = Math.max(0, tags.length - displayN); let more = Math.max(0, tags.length - displayN);
const tagsString = const tagsString =
more === 0 more === 0

View File

@ -16,7 +16,7 @@ export default Controller.extend({
@observes("userActionType", "model.stream.itemsLoaded") @observes("userActionType", "model.stream.itemsLoaded")
_showFooter: function () { _showFooter: function () {
var showFooter; let showFooter;
if (this.userActionType) { if (this.userActionType) {
const stat = (this.get("model.stats") || []).find( const stat = (this.get("model.stats") || []).find(
(s) => s.action_type === this.userActionType (s) => s.action_type === this.userActionType

View File

@ -40,7 +40,7 @@ export default Controller.extend({
bulkOperation(operation) { bulkOperation(operation) {
const selected = this.selected; const selected = this.selected;
var params = { type: operation }; let params = { type: operation };
if (this.isGroup) { if (this.isGroup) {
params.group = this.groupFilter; params.group = this.groupFilter;
} }

View File

@ -16,7 +16,7 @@ export function replaceCategoryLinkRenderer(fn) {
} }
function categoryStripe(color, classes) { function categoryStripe(color, classes) {
var style = color ? "style='background-color: #" + color + ";'" : ""; let style = color ? "style='background-color: #" + color + ";'" : "";
return "<span class='" + classes + "' " + style + "></span>"; return "<span class='" + classes + "' " + style + "></span>";
} }
@ -65,7 +65,7 @@ export function categoryBadgeHTML(category, opts) {
} }
export function categoryLinkHTML(category, options) { export function categoryLinkHTML(category, options) {
var categoryOptions = {}; let categoryOptions = {};
// TODO: This is a compatibility layer with the old helper structure. // TODO: This is a compatibility layer with the old helper structure.
// Can be removed once we migrate to `registerUnbound` fully // Can be removed once we migrate to `registerUnbound` fully

View File

@ -7,7 +7,7 @@ import { registerUnbound } from "discourse-common/lib/helpers";
update the dates on a regular interval. update the dates on a regular interval.
**/ **/
registerUnbound("format-date", function (val, params) { registerUnbound("format-date", function (val, params) {
var leaveAgo, let leaveAgo,
format = "medium", format = "medium",
title = true; title = true;
@ -22,7 +22,7 @@ registerUnbound("format-date", function (val, params) {
} }
if (val) { if (val) {
var date = new Date(val); let date = new Date(val);
return htmlSafe( return htmlSafe(
autoUpdatingRelativeAge(date, { autoUpdatingRelativeAge(date, {
format: format, format: format,

View File

@ -1,13 +1,13 @@
import { htmlHelper } from "discourse-common/lib/helpers"; import { htmlHelper } from "discourse-common/lib/helpers";
function renderSpinner(cssClass) { function renderSpinner(cssClass) {
var html = "<div class='spinner"; let html = "<div class='spinner";
if (cssClass) { if (cssClass) {
html += " " + cssClass; html += " " + cssClass;
} }
return html + "'></div>"; return html + "'></div>";
} }
var spinnerHTML = renderSpinner(); let spinnerHTML = renderSpinner();
export default htmlHelper((params) => { export default htmlHelper((params) => {
const hash = params.hash; const hash = params.hash;

View File

@ -1,7 +1,7 @@
import { registerUnbound } from "discourse-common/lib/helpers"; import { registerUnbound } from "discourse-common/lib/helpers";
registerUnbound("shorten-url", function (url) { registerUnbound("shorten-url", function (url) {
var matches = url.match(/\//g); let matches = url.match(/\//g);
if (matches && matches.length === 3) { if (matches && matches.length === 3) {
url = url.replace(/\/$/, ""); url = url.replace(/\/$/, "");

View File

@ -4,7 +4,7 @@
SO: http://stackoverflow.com/questions/9943435/css3-animation-end-techniques SO: http://stackoverflow.com/questions/9943435/css3-animation-end-techniques
**/ **/
var dummy = document.createElement("div"), let dummy = document.createElement("div"),
eventNameHash = { eventNameHash = {
webkit: "webkitTransitionEnd", webkit: "webkitTransitionEnd",
Moz: "transitionend", Moz: "transitionend",
@ -12,8 +12,8 @@ var dummy = document.createElement("div"),
ms: "MSTransitionEnd", ms: "MSTransitionEnd",
}; };
var transitionEnd = (function () { let transitionEnd = (function () {
var retValue; let retValue;
retValue = "transitionend"; retValue = "transitionend";
Object.keys(eventNameHash).some(function (vendor) { Object.keys(eventNameHash).some(function (vendor) {
if (vendor + "TransitionProperty" in dummy.style) { if (vendor + "TransitionProperty" in dummy.style) {

View File

@ -15,8 +15,8 @@ export function replaceSpan($elem, categorySlug, categoryLink, type) {
export function categoryHashtagTriggerRule(textarea, opts) { export function categoryHashtagTriggerRule(textarea, opts) {
const result = caretRowCol(textarea); const result = caretRowCol(textarea);
const row = result.rowNum; const row = result.rowNum;
var col = result.colNum; let col = result.colNum;
var line = textarea.value.split("\n")[row - 1]; let line = textarea.value.split("\n")[row - 1];
if (opts && opts.backSpace) { if (opts && opts.backSpace) {
col = col - 1; col = col - 1;

View File

@ -37,7 +37,7 @@ function searchTags(term, categories, limit) {
data: { limit: limit, q }, data: { limit: limit, q },
}); });
var returnVal = CANCELLED_STATUS; let returnVal = CANCELLED_STATUS;
oldSearch oldSearch
.then((r) => { .then((r) => {
@ -91,8 +91,8 @@ export function search(term, siteSettings) {
} }
const limit = 5; const limit = 5;
var categories = Category.search(term, { limit }); let categories = Category.search(term, { limit });
var numOfCategories = categories.length; let numOfCategories = categories.length;
categories = categories.map((category) => { categories = categories.map((category) => {
return { model: category, text: Category.slugFor(category, SEPARATOR, 2) }; return { model: category, text: Category.slugFor(category, SEPARATOR, 2) };

View File

@ -27,7 +27,7 @@ const Mobile = {
localStorage.removeItem("mobileView"); localStorage.removeItem("mobileView");
} }
if (localStorage.mobileView) { if (localStorage.mobileView) {
var savedValue = localStorage.mobileView === "true"; let savedValue = localStorage.mobileView === "true";
if (savedValue !== this.mobileView) { if (savedValue !== this.mobileView) {
this.reloadPage(savedValue); this.reloadPage(savedValue);
} }

View File

@ -1,5 +1,5 @@
// for android we test webkit // for android we test webkit
var hiddenProperty = let hiddenProperty =
document.hidden !== undefined document.hidden !== undefined
? "hidden" ? "hidden"
: document.webkitHidden !== undefined : document.webkitHidden !== undefined

View File

@ -1227,11 +1227,11 @@ let _pluginv01;
// from http://stackoverflow.com/questions/6832596/how-to-compare-software-version-number-using-js-only-number // from http://stackoverflow.com/questions/6832596/how-to-compare-software-version-number-using-js-only-number
function cmpVersions(a, b) { function cmpVersions(a, b) {
var i, diff; let i, diff;
var regExStrip0 = /(\.0+)+$/; let regExStrip0 = /(\.0+)+$/;
var segmentsA = a.replace(regExStrip0, "").split("."); let segmentsA = a.replace(regExStrip0, "").split(".");
var segmentsB = b.replace(regExStrip0, "").split("."); let segmentsB = b.replace(regExStrip0, "").split(".");
var l = Math.min(segmentsA.length, segmentsB.length); let l = Math.min(segmentsA.length, segmentsB.length);
for (i = 0; i < l; i++) { for (i = 0; i < l; i++) {
diff = parseInt(segmentsA[i], 10) - parseInt(segmentsB[i], 10); diff = parseInt(segmentsA[i], 10) - parseInt(segmentsB[i], 10);

View File

@ -93,7 +93,7 @@ function positioningWorkaround($fixedElement) {
const fixedElement = $fixedElement[0]; const fixedElement = $fixedElement[0];
const oldHeight = fixedElement.style.height; const oldHeight = fixedElement.style.height;
var originalScrollTop = 0; let originalScrollTop = 0;
let lastTouchedElement = null; let lastTouchedElement = null;
positioningWorkaround.blur = function (evt) { positioningWorkaround.blur = function (evt) {
@ -114,7 +114,7 @@ function positioningWorkaround($fixedElement) {
} }
}; };
var blurredNow = function (evt) { let blurredNow = function (evt) {
// we cannot use evt.relatedTarget to get the last focused element in safari iOS // we cannot use evt.relatedTarget to get the last focused element in safari iOS
// document.activeElement is also unreliable (iOS does not mark buttons as focused) // document.activeElement is also unreliable (iOS does not mark buttons as focused)
// so instead, we store the last touched element and check against it // so instead, we store the last touched element and check against it
@ -145,11 +145,11 @@ function positioningWorkaround($fixedElement) {
positioningWorkaround.blur(evt); positioningWorkaround.blur(evt);
}; };
var blurred = function (evt) { let blurred = function (evt) {
discourseDebounce(this, blurredNow, evt, INPUT_DELAY); discourseDebounce(this, blurredNow, evt, INPUT_DELAY);
}; };
var positioningHack = function (evt) { let positioningHack = function (evt) {
let _this = this; let _this = this;
if (evt === undefined) { if (evt === undefined) {
@ -203,7 +203,7 @@ function positioningWorkaround($fixedElement) {
}, delay); }, delay);
}; };
var lastTouched = function (evt) { let lastTouched = function (evt) {
if (evt && evt.target) { if (evt && evt.target) {
lastTouchedElement = evt.target; lastTouchedElement = evt.target;
} }
@ -231,7 +231,7 @@ function positioningWorkaround($fixedElement) {
}; };
positioningWorkaround.touchstartEvent = function (element) { positioningWorkaround.touchstartEvent = function (element) {
var triggerHack = positioningHack.bind(element); let triggerHack = positioningHack.bind(element);
triggerHack(); triggerHack();
}; };

View File

@ -6,7 +6,7 @@ import { emailValid } from "discourse/lib/utilities";
import { isTesting } from "discourse-common/config/environment"; import { isTesting } from "discourse-common/config/environment";
import { userPath } from "discourse/lib/url"; import { userPath } from "discourse/lib/url";
var cache = {}, let cache = {},
cacheKey, cacheKey,
cacheTime, cacheTime,
currentTerm, currentTerm,
@ -23,7 +23,7 @@ function performSearch(
groupMembersOf, groupMembersOf,
resultsFn resultsFn
) { ) {
var cached = cache[term]; let cached = cache[term];
if (cached) { if (cached) {
resultsFn(cached); resultsFn(cached);
return; return;
@ -52,7 +52,7 @@ function performSearch(
}, },
}); });
var returnVal = CANCELLED_STATUS; let returnVal = CANCELLED_STATUS;
oldSearch oldSearch
.then(function (r) { .then(function (r) {
@ -81,7 +81,7 @@ function performSearch(
}); });
} }
var debouncedSearch = function ( let debouncedSearch = function (
term, term,
topicId, topicId,
categoryId, categoryId,
@ -113,7 +113,7 @@ function organizeResults(r, options) {
return r; return r;
} }
var exclude = options.exclude || [], let exclude = options.exclude || [],
limit = options.limit || 5, limit = options.limit || 5,
users = [], users = [],
emails = [], emails = [],
@ -182,7 +182,7 @@ export default function userSearch(options) {
options.term = options.term.substring(1); options.term = options.term.substring(1);
} }
var term = options.term || "", let term = options.term || "",
includeGroups = options.includeGroups, includeGroups = options.includeGroups,
includeMentionableGroups = options.includeMentionableGroups, includeMentionableGroups = options.includeMentionableGroups,
includeMessageableGroups = options.includeMessageableGroups, includeMessageableGroups = options.includeMessageableGroups,

View File

@ -97,7 +97,7 @@ export function tinyAvatar(avatarTemplate, options) {
} }
export function postUrl(slug, topicId, postNumber) { export function postUrl(slug, topicId, postNumber) {
var url = getURL("/t/"); let url = getURL("/t/");
if (slug) { if (slug) {
url += slug + "/"; url += slug + "/";
} else { } else {
@ -190,11 +190,11 @@ export function selectedElement() {
// Determine the row and col of the caret in an element // Determine the row and col of the caret in an element
export function caretRowCol(el) { export function caretRowCol(el) {
var cp = caretPosition(el); let cp = caretPosition(el);
var rows = el.value.slice(0, cp).split("\n"); let rows = el.value.slice(0, cp).split("\n");
var rowNum = rows.length; let rowNum = rows.length;
var colNum = let colNum =
cp - cp -
rows.splice(0, rowNum - 1).reduce(function (sum, row) { rows.splice(0, rowNum - 1).reduce(function (sum, row) {
return sum + row.length + 1; return sum + row.length + 1;
@ -205,7 +205,7 @@ export function caretRowCol(el) {
// Determine the position of the caret in an element // Determine the position of the caret in an element
export function caretPosition(el) { export function caretPosition(el) {
var r, rc, re; let r, rc, re;
if (el.selectionStart) { if (el.selectionStart) {
return el.selectionStart; return el.selectionStart;
} }
@ -227,7 +227,7 @@ export function caretPosition(el) {
// Set the caret's position // Set the caret's position
export function setCaretPosition(ctrl, pos) { export function setCaretPosition(ctrl, pos) {
var range; let range;
if (ctrl.setSelectionRange) { if (ctrl.setSelectionRange) {
ctrl.focus(); ctrl.focus();
ctrl.setSelectionRange(pos, pos); ctrl.setSelectionRange(pos, pos);
@ -421,7 +421,7 @@ export function areCookiesEnabled() {
// see: https://github.com/Modernizr/Modernizr/blob/400db4043c22af98d46e1d2b9cbc5cb062791192/feature-detects/cookies.js // see: https://github.com/Modernizr/Modernizr/blob/400db4043c22af98d46e1d2b9cbc5cb062791192/feature-detects/cookies.js
try { try {
document.cookie = "cookietest=1"; document.cookie = "cookietest=1";
var ret = document.cookie.indexOf("cookietest=") !== -1; let ret = document.cookie.indexOf("cookietest=") !== -1;
document.cookie = "cookietest=1; expires=Thu, 01-Jan-1970 00:00:01 GMT"; document.cookie = "cookietest=1; expires=Thu, 01-Jan-1970 00:00:01 GMT";
return ret; return ret;
} catch (e) { } catch (e) {

View File

@ -113,7 +113,7 @@ export function mapRoutes() {
// can define admin routes. // can define admin routes.
Object.keys(requirejs._eak_seen).forEach(function (key) { Object.keys(requirejs._eak_seen).forEach(function (key) {
if (/route-map$/.test(key)) { if (/route-map$/.test(key)) {
var module = requirejs(key, null, null, true); let module = requirejs(key, null, null, true);
if (!module || !module.default) { if (!module || !module.default) {
throw new Error(key + " must export a route map."); throw new Error(key + " must export a route map.");
} }

View File

@ -67,7 +67,7 @@ const Singleton = Mixin.create({
// Returns OR sets a property on the singleton instance. // Returns OR sets a property on the singleton instance.
currentProp(property, value) { currentProp(property, value) {
var instance = this.current(); let instance = this.current();
if (!instance) { if (!instance) {
return; return;
} }

View File

@ -312,7 +312,7 @@ const Category = RestModel.extend({
}, },
}); });
var _uncategorized; let _uncategorized;
Category.reopenClass({ Category.reopenClass({
slugEncoded() { slugEncoded() {
@ -508,7 +508,7 @@ Category.reopenClass({
}, },
search(term, opts) { search(term, opts) {
var limit = 5; let limit = 5;
if (opts) { if (opts) {
if (opts.limit === 0) { if (opts.limit === 0) {
@ -529,8 +529,8 @@ Category.reopenClass({
const categories = Category.listByActivity(); const categories = Category.listByActivity();
const length = categories.length; const length = categories.length;
var i; let i;
var data = []; let data = [];
const done = () => { const done = () => {
return data.length === limit; return data.length === limit;

View File

@ -177,7 +177,7 @@ NavItem.reopenClass({
return null; return null;
} }
var args = { name: filterType, hasIcon: filterType === "unread" }; let args = { name: filterType, hasIcon: filterType === "unread" };
if (opts.category) { if (opts.category) {
args.category = opts.category; args.category = opts.category;
} }

View File

@ -114,9 +114,9 @@ export default EmberObject.extend({
}, },
find(type, findArgs, opts) { find(type, findArgs, opts) {
var adapter = this.adapterFor(type); let adapter = this.adapterFor(type);
return adapter.find(this, type, findArgs, opts).then((result) => { return adapter.find(this, type, findArgs, opts).then((result) => {
var hydrated = this._hydrateFindResults(result, type, findArgs, opts); let hydrated = this._hydrateFindResults(result, type, findArgs, opts);
if (result.extras) { if (result.extras) {
hydrated.set("extras", result.extras); hydrated.set("extras", result.extras);
@ -139,7 +139,7 @@ export default EmberObject.extend({
hydrated.set( hydrated.set(
"content", "content",
hydrated.get("content").map((item) => { hydrated.get("content").map((item) => {
var staleItem = stale.content.findBy(primaryKey, item.get(primaryKey)); let staleItem = stale.content.findBy(primaryKey, item.get(primaryKey));
if (staleItem) { if (staleItem) {
staleItem.setProperties(item); staleItem.setProperties(item);
} else { } else {

View File

@ -291,7 +291,7 @@ const TopicTrackingState = EmberObject.extend({
if (split.length >= 4) { if (split.length >= 4) {
filter = split[split.length - 1]; filter = split[split.length - 1];
// c/cat/subcat/6/l/latest // c/cat/subcat/6/l/latest
var category = Category.findSingleBySlug( let category = Category.findSingleBySlug(
split.splice(1, split.length - 4).join("/") split.splice(1, split.length - 4).join("/")
); );
this.set("filterCategory", category); this.set("filterCategory", category);

View File

@ -27,7 +27,7 @@ UserBadge.reopenClass({
if (json.users === undefined) { if (json.users === undefined) {
json.users = []; json.users = [];
} }
var users = {}; let users = {};
json.users.forEach(function (userJson) { json.users.forEach(function (userJson) {
users[userJson.id] = User.create(userJson); users[userJson.id] = User.create(userJson);
}); });
@ -36,7 +36,7 @@ UserBadge.reopenClass({
if (json.topics === undefined) { if (json.topics === undefined) {
json.topics = []; json.topics = [];
} }
var topics = {}; let topics = {};
json.topics.forEach(function (topicJson) { json.topics.forEach(function (topicJson) {
topics[topicJson.id] = Topic.create(topicJson); topics[topicJson.id] = Topic.create(topicJson);
}); });
@ -45,13 +45,13 @@ UserBadge.reopenClass({
if (json.badges === undefined) { if (json.badges === undefined) {
json.badges = []; json.badges = [];
} }
var badges = {}; let badges = {};
Badge.createFromJson(json).forEach(function (badge) { Badge.createFromJson(json).forEach(function (badge) {
badges[badge.get("id")] = badge; badges[badge.get("id")] = badge;
}); });
// Create UserBadge object(s). // Create UserBadge object(s).
var userBadges = []; let userBadges = [];
if ("user_badge" in json) { if ("user_badge" in json) {
userBadges = [json.user_badge]; userBadges = [json.user_badge];
} else { } else {
@ -61,9 +61,9 @@ UserBadge.reopenClass({
} }
userBadges = userBadges.map(function (userBadgeJson) { userBadges = userBadges.map(function (userBadgeJson) {
var userBadge = UserBadge.create(userBadgeJson); let userBadge = UserBadge.create(userBadgeJson);
var grantedAtDate = Date.parse(userBadge.get("granted_at")); let grantedAtDate = Date.parse(userBadge.get("granted_at"));
userBadge.set("grantedAt", grantedAtDate); userBadge.set("grantedAt", grantedAtDate);
userBadge.set("badge", badges[userBadge.get("badge_id")]); userBadge.set("badge", badges[userBadge.get("badge_id")]);
@ -102,7 +102,7 @@ UserBadge.reopenClass({
if (!username) { if (!username) {
return Promise.resolve([]); return Promise.resolve([]);
} }
var url = "/user-badges/" + username + ".json"; let url = "/user-badges/" + username + ".json";
if (options && options.grouped) { if (options && options.grouped) {
url += "?grouped=true"; url += "?grouped=true";
} }

View File

@ -342,7 +342,7 @@ const User = RestModel.extend({
data[s] = this.get(`user_option.${s}`); data[s] = this.get(`user_option.${s}`);
}); });
var updatedState = {}; let updatedState = {};
["muted", "regular", "watched", "tracked", "watched_first_post"].forEach( ["muted", "regular", "watched", "tracked", "watched_first_post"].forEach(
(s) => { (s) => {

View File

@ -3,8 +3,8 @@ export default {
initialize: function () { initialize: function () {
$('script[type="text/x-handlebars"]').each(function () { $('script[type="text/x-handlebars"]').each(function () {
var $this = $(this); let $this = $(this);
var name = $this.attr("name") || $this.data("template-name"); let name = $this.attr("name") || $this.data("template-name");
if (window.console) { if (window.console) {
window.console.log( window.console.log(

View File

@ -157,7 +157,7 @@ export default (filterArg, params) => {
canCreateTopic: canCreateTopic, canCreateTopic: canCreateTopic,
}); });
var topicOpts = { let topicOpts = {
model: topics, model: topics,
category, category,
period: period:

View File

@ -30,7 +30,7 @@ export default DiscourseRoute.extend({
model(params) { model(params) {
const cached = getTransient("lastSearch"); const cached = getTransient("lastSearch");
var args = { q: params.q }; let args = { q: params.q };
if (params.context_id && !args.skip_context) { if (params.context_id && !args.skip_context) {
args.search_context = { args.search_context = {
type: params.context, type: params.context,

View File

@ -5,7 +5,7 @@ const SignupRoute = buildStaticRoute("signup");
SignupRoute.reopen({ SignupRoute.reopen({
beforeModel() { beforeModel() {
var canSignUp = this.controllerFor("application").get("canSignUp"); let canSignUp = this.controllerFor("application").get("canSignUp");
if (!this.siteSettings.login_required) { if (!this.siteSettings.login_required) {
this.replaceWith("discovery.latest").then((e) => { this.replaceWith("discovery.latest").then((e) => {

View File

@ -29,7 +29,7 @@ createWidget("avatar-flair", {
}, },
buildAttributes(attrs) { buildAttributes(attrs) {
var style = ""; let style = "";
if (!this.isIcon(attrs)) { if (!this.isIcon(attrs)) {
style += style +=
"background-image: url(" + "background-image: url(" +

View File

@ -12,7 +12,7 @@ export function actionDescriptionHtml(actionCode, createdAt, username) {
const dt = new Date(createdAt); const dt = new Date(createdAt);
const when = autoUpdatingRelativeAge(dt, { format: "medium-with-ago" }); const when = autoUpdatingRelativeAge(dt, { format: "medium-with-ago" });
var who = ""; let who = "";
if (username) { if (username) {
if (actionCode === "invited_group" || actionCode === "removed_group") { if (actionCode === "invited_group" || actionCode === "removed_group") {
who = `<a class="mention-group" href="/g/${username}">@${username}</a>`; who = `<a class="mention-group" href="/g/${username}">@${username}</a>`;

View File

@ -6,9 +6,9 @@ import {
import { click, visit } from "@ember/test-helpers"; import { click, visit } from "@ember/test-helpers";
import { test } from "qunit"; import { test } from "qunit";
acceptance("Opening the hamburger menu with some reviewables", function ( acceptance(
needs "Opening the hamburger menu with some reviewables",
) { function (needs) {
needs.user(); needs.user();
needs.pretender((server, helper) => { needs.pretender((server, helper) => {
server.get("/review/count.json", () => helper.response({ count: 3 })); server.get("/review/count.json", () => helper.response({ count: 3 }));
@ -24,4 +24,5 @@ acceptance("Opening the hamburger menu with some reviewables", function (
"3" "3"
); );
}); });
}); }
);

View File

@ -290,9 +290,9 @@ acceptance("Second Factor Backups", function (needs) {
}); });
}); });
acceptance("Avatar selector when selectable avatars is enabled", function ( acceptance(
needs "Avatar selector when selectable avatars is enabled",
) { function (needs) {
needs.user(); needs.user();
needs.settings({ selectable_avatars_enabled: true }); needs.settings({ selectable_avatars_enabled: true });
needs.pretender((server, helper) => { needs.pretender((server, helper) => {
@ -311,7 +311,8 @@ acceptance("Avatar selector when selectable avatars is enabled", function (
exists(".selectable-avatars", "opens the avatar selection modal") exists(".selectable-avatars", "opens the avatar selection modal")
); );
}); });
}); }
);
acceptance("User Preferences when badges are disabled", function (needs) { acceptance("User Preferences when badges are disabled", function (needs) {
needs.user(); needs.user();

View File

@ -1,9 +1,9 @@
import { import {
acceptance, acceptance,
exists, exists,
invisible,
queryAll, queryAll,
updateCurrentUser, updateCurrentUser,
invisible,
} from "discourse/tests/helpers/qunit-helpers"; } from "discourse/tests/helpers/qunit-helpers";
import { click, currentURL, visit } from "@ember/test-helpers"; import { click, currentURL, visit } from "@ember/test-helpers";
import { test } from "qunit"; import { test } from "qunit";

View File

@ -6,9 +6,9 @@ import {
queryAll, queryAll,
} from "discourse/tests/helpers/qunit-helpers"; } from "discourse/tests/helpers/qunit-helpers";
discourseModule("Integration | Component | activation-controls", function ( discourseModule(
hooks "Integration | Component | activation-controls",
) { function (hooks) {
setupRenderingTest(hooks); setupRenderingTest(hooks);
componentTest("hides change email button", { componentTest("hides change email button", {
@ -22,4 +22,5 @@ discourseModule("Integration | Component | activation-controls", function (
assert.equal(queryAll("button.edit-email").length, 0); assert.equal(queryAll("button.edit-email").length, 0);
}, },
}); });
}); }
);

View File

@ -97,10 +97,9 @@ discourseModule("Integration | Component | d-editor", function (hooks) {
}); });
} }
testCase(`selecting the space before a word`, async function ( testCase(
assert, `selecting the space before a word`,
textarea async function (assert, textarea) {
) {
textarea.selectionStart = 5; textarea.selectionStart = 5;
textarea.selectionEnd = 7; textarea.selectionEnd = 7;
@ -109,12 +108,12 @@ discourseModule("Integration | Component | d-editor", function (hooks) {
assert.equal(this.value, `hello **w**orld.`); assert.equal(this.value, `hello **w**orld.`);
assert.equal(textarea.selectionStart, 8); assert.equal(textarea.selectionStart, 8);
assert.equal(textarea.selectionEnd, 9); assert.equal(textarea.selectionEnd, 9);
}); }
);
testCase(`selecting the space after a word`, async function ( testCase(
assert, `selecting the space after a word`,
textarea async function (assert, textarea) {
) {
textarea.selectionStart = 0; textarea.selectionStart = 0;
textarea.selectionEnd = 6; textarea.selectionEnd = 6;
@ -123,7 +122,8 @@ discourseModule("Integration | Component | d-editor", function (hooks) {
assert.equal(this.value, `**hello** world.`); assert.equal(this.value, `**hello** world.`);
assert.equal(textarea.selectionStart, 2); assert.equal(textarea.selectionStart, 2);
assert.equal(textarea.selectionEnd, 7); assert.equal(textarea.selectionEnd, 7);
}); }
);
testCase(`bold button with no selection`, async function (assert, textarea) { testCase(`bold button with no selection`, async function (assert, textarea) {
await click(`button.bold`); await click(`button.bold`);
@ -149,10 +149,9 @@ discourseModule("Integration | Component | d-editor", function (hooks) {
assert.equal(textarea.selectionEnd, 11); assert.equal(textarea.selectionEnd, 11);
}); });
testCase(`bold with a multiline selection`, async function ( testCase(
assert, `bold with a multiline selection`,
textarea async function (assert, textarea) {
) {
this.set("value", "hello\n\nworld\n\ntest."); this.set("value", "hello\n\nworld\n\ntest.");
textarea.selectionStart = 0; textarea.selectionStart = 0;
@ -167,19 +166,20 @@ discourseModule("Integration | Component | d-editor", function (hooks) {
assert.equal(this.value, `hello\n\nworld\n\ntest.`); assert.equal(this.value, `hello\n\nworld\n\ntest.`);
assert.equal(textarea.selectionStart, 0); assert.equal(textarea.selectionStart, 0);
assert.equal(textarea.selectionEnd, 12); assert.equal(textarea.selectionEnd, 12);
}); }
);
testCase(`italic button with no selection`, async function ( testCase(
assert, `italic button with no selection`,
textarea async function (assert, textarea) {
) {
await click(`button.italic`); await click(`button.italic`);
const example = I18n.t(`composer.italic_text`); const example = I18n.t(`composer.italic_text`);
assert.equal(this.value, `hello world.*${example}*`); assert.equal(this.value, `hello world.*${example}*`);
assert.equal(textarea.selectionStart, 13); assert.equal(textarea.selectionStart, 13);
assert.equal(textarea.selectionEnd, 13 + example.length); assert.equal(textarea.selectionEnd, 13 + example.length);
}); }
);
testCase(`italic button with a selection`, async function (assert, textarea) { testCase(`italic button with a selection`, async function (assert, textarea) {
textarea.selectionStart = 6; textarea.selectionStart = 6;
@ -196,10 +196,9 @@ discourseModule("Integration | Component | d-editor", function (hooks) {
assert.equal(textarea.selectionEnd, 11); assert.equal(textarea.selectionEnd, 11);
}); });
testCase(`italic with a multiline selection`, async function ( testCase(
assert, `italic with a multiline selection`,
textarea async function (assert, textarea) {
) {
this.set("value", "hello\n\nworld\n\ntest."); this.set("value", "hello\n\nworld\n\ntest.");
textarea.selectionStart = 0; textarea.selectionStart = 0;
@ -214,7 +213,8 @@ discourseModule("Integration | Component | d-editor", function (hooks) {
assert.equal(this.value, `hello\n\nworld\n\ntest.`); assert.equal(this.value, `hello\n\nworld\n\ntest.`);
assert.equal(textarea.selectionStart, 0); assert.equal(textarea.selectionStart, 0);
assert.equal(textarea.selectionEnd, 12); assert.equal(textarea.selectionEnd, 12);
}); }
);
componentTest("advanced code", { componentTest("advanced code", {
template: "{{d-editor value=value}}", template: "{{d-editor value=value}}",
@ -508,10 +508,9 @@ third line`
assert.equal(this.value, "hello\n\nwor\n\nld.\n\n> Blockquote"); assert.equal(this.value, "hello\n\nwor\n\nld.\n\n> Blockquote");
}); });
testCase(`bullet button with no selection`, async function ( testCase(
assert, `bullet button with no selection`,
textarea async function (assert, textarea) {
) {
const example = I18n.t("composer.list_item"); const example = I18n.t("composer.list_item");
await click(`button.bullet`); await click(`button.bullet`);
@ -521,7 +520,8 @@ third line`
await click(`button.bullet`); await click(`button.bullet`);
assert.equal(this.value, `hello world.\n\n${example}`); assert.equal(this.value, `hello world.\n\n${example}`);
}); }
);
testCase(`bullet button with a selection`, async function (assert, textarea) { testCase(`bullet button with a selection`, async function (assert, textarea) {
textarea.selectionStart = 6; textarea.selectionStart = 6;
@ -538,10 +538,9 @@ third line`
assert.equal(textarea.selectionEnd, 12); assert.equal(textarea.selectionEnd, 12);
}); });
testCase(`bullet button with a multiple line selection`, async function ( testCase(
assert, `bullet button with a multiple line selection`,
textarea async function (assert, textarea) {
) {
this.set("value", "* Hello\n\nWorld\n\nEvil"); this.set("value", "* Hello\n\nWorld\n\nEvil");
textarea.selectionStart = 0; textarea.selectionStart = 0;
@ -556,7 +555,8 @@ third line`
assert.equal(this.value, "* Hello\n\n* World\n\n* Evil"); assert.equal(this.value, "* Hello\n\n* World\n\n* Evil");
assert.equal(textarea.selectionStart, 0); assert.equal(textarea.selectionStart, 0);
assert.equal(textarea.selectionEnd, 24); assert.equal(textarea.selectionEnd, 24);
}); }
);
testCase(`list button with no selection`, async function (assert, textarea) { testCase(`list button with no selection`, async function (assert, textarea) {
const example = I18n.t("composer.list_item"); const example = I18n.t("composer.list_item");
@ -633,10 +633,9 @@ third line`
}, },
}); });
testCase(`doesn't jump to bottom with long text`, async function ( testCase(
assert, `doesn't jump to bottom with long text`,
textarea async function (assert, textarea) {
) {
let longText = "hello world."; let longText = "hello world.";
for (let i = 0; i < 8; i++) { for (let i = 0; i < 8; i++) {
longText = longText + longText; longText = longText + longText;
@ -649,7 +648,8 @@ third line`
await click("button.bold"); await click("button.bold");
assert.equal($(textarea).scrollTop(), 0, "it stays scrolled up"); assert.equal($(textarea).scrollTop(), 0, "it stays scrolled up");
}); }
);
componentTest("emoji", { componentTest("emoji", {
template: "{{d-editor value=value}}", template: "{{d-editor value=value}}",

View File

@ -24,9 +24,9 @@ function toTimeInput() {
const DEFAULT_DATE_TIME = moment("2019-01-29 14:45"); const DEFAULT_DATE_TIME = moment("2019-01-29 14:45");
discourseModule("Integration | Component | date-time-input-range", function ( discourseModule(
hooks "Integration | Component | date-time-input-range",
) { function (hooks) {
setupRenderingTest(hooks); setupRenderingTest(hooks);
componentTest("default", { componentTest("default", {
@ -43,4 +43,5 @@ discourseModule("Integration | Component | date-time-input-range", function (
assert.equal(toTimeInput().dataset.name, "--:--"); assert.equal(toTimeInput().dataset.name, "--:--");
}, },
}); });
}); }
);

View File

@ -8,9 +8,9 @@ import {
} from "discourse/tests/helpers/qunit-helpers"; } from "discourse/tests/helpers/qunit-helpers";
import I18n from "I18n"; import I18n from "I18n";
discourseModule("Integration | Component | secret-value-list", function ( discourseModule(
hooks "Integration | Component | secret-value-list",
) { function (hooks) {
setupRenderingTest(hooks); setupRenderingTest(hooks);
componentTest("adding a value", { componentTest("adding a value", {
@ -102,4 +102,5 @@ discourseModule("Integration | Component | secret-value-list", function (
); );
}, },
}); });
}); }
);

View File

@ -47,9 +47,9 @@ function template(options = []) {
`; `;
} }
discourseModule("Integration | Component | select-kit/category-drop", function ( discourseModule(
hooks "Integration | Component | select-kit/category-drop",
) { function (hooks) {
setupRenderingTest(hooks); setupRenderingTest(hooks);
hooks.beforeEach(function () { hooks.beforeEach(function () {
@ -356,4 +356,5 @@ discourseModule("Integration | Component | select-kit/category-drop", function (
); );
}, },
}); });
}); }
);

View File

@ -24,9 +24,9 @@ const setDefaultState = (ctx, options) => {
ctx.setProperties(properties); ctx.setProperties(properties);
}; };
discourseModule("Integration | Component | select-kit/combo-box", function ( discourseModule(
hooks "Integration | Component | select-kit/combo-box",
) { function (hooks) {
setupRenderingTest(hooks); setupRenderingTest(hooks);
hooks.beforeEach(function () { hooks.beforeEach(function () {
@ -106,4 +106,5 @@ discourseModule("Integration | Component | select-kit/combo-box", function (
); );
}, },
}); });
}); }
);

View File

@ -16,9 +16,9 @@ function template(options = []) {
`; `;
} }
discourseModule("Integration | Component | select-kit/list-setting", function ( discourseModule(
hooks "Integration | Component | select-kit/list-setting",
) { function (hooks) {
setupRenderingTest(hooks); setupRenderingTest(hooks);
hooks.beforeEach(function () { hooks.beforeEach(function () {
@ -43,4 +43,5 @@ discourseModule("Integration | Component | select-kit/list-setting", function (
assert.equal(this.subject.rowByIndex(0).value(), "underline"); assert.equal(this.subject.rowByIndex(0).value(), "underline");
}, },
}); });
}); }
);

View File

@ -33,9 +33,9 @@ const setDefaultState = (ctx, options) => {
ctx.setProperties(properties); ctx.setProperties(properties);
}; };
discourseModule("Integration | Component | select-kit/multi-select", function ( discourseModule(
hooks "Integration | Component | select-kit/multi-select",
) { function (hooks) {
setupRenderingTest(hooks); setupRenderingTest(hooks);
hooks.beforeEach(function () { hooks.beforeEach(function () {
@ -71,4 +71,5 @@ discourseModule("Integration | Component | select-kit/multi-select", function (
); );
}, },
}); });
}); }
);

View File

@ -44,9 +44,9 @@ const setDefaultState = (ctx, options) => {
ctx.setProperties(properties); ctx.setProperties(properties);
}; };
discourseModule("Integration | Component | select-kit/single-select", function ( discourseModule(
hooks "Integration | Component | select-kit/single-select",
) { function (hooks) {
setupRenderingTest(hooks); setupRenderingTest(hooks);
hooks.beforeEach(function () { hooks.beforeEach(function () {
@ -121,7 +121,10 @@ discourseModule("Integration | Component | select-kit/single-select", function (
}); });
componentTest("options.limitMatches", { componentTest("options.limitMatches", {
template: template(["limitMatches=limitMatches", "filterable=filterable"]), template: template([
"limitMatches=limitMatches",
"filterable=filterable",
]),
beforeEach() { beforeEach() {
setDefaultState(this, { limitMatches: 1, filterable: true }); setDefaultState(this, { limitMatches: 1, filterable: true });
@ -344,4 +347,5 @@ discourseModule("Integration | Component | select-kit/single-select", function (
); );
}, },
}); });
}); }
);

View File

@ -36,9 +36,9 @@ function template(options = []) {
`; `;
} }
discourseModule("Integration | Component | select-kit/tag-drop", function ( discourseModule(
hooks "Integration | Component | select-kit/tag-drop",
) { function (hooks) {
setupRenderingTest(hooks); setupRenderingTest(hooks);
hooks.beforeEach(function () { hooks.beforeEach(function () {
@ -95,4 +95,5 @@ discourseModule("Integration | Component | select-kit/tag-drop", function (
); );
}, },
}); });
}); }
);

View File

@ -4,9 +4,9 @@ import componentTest, {
import { discourseModule } from "discourse/tests/helpers/qunit-helpers"; import { discourseModule } from "discourse/tests/helpers/qunit-helpers";
import selectKit from "discourse/tests/helpers/select-kit-helper"; import selectKit from "discourse/tests/helpers/select-kit-helper";
discourseModule("Integration | Component | select-kit/user-chooser", function ( discourseModule(
hooks "Integration | Component | select-kit/user-chooser",
) { function (hooks) {
setupRenderingTest(hooks); setupRenderingTest(hooks);
hooks.beforeEach(function () { hooks.beforeEach(function () {
@ -37,4 +37,5 @@ discourseModule("Integration | Component | select-kit/user-chooser", function (
assert.equal(this.subject.header().name(), "martin"); assert.equal(this.subject.header().name(), "martin");
}, },
}); });
}); }
);

View File

@ -6,9 +6,9 @@ import {
queryAll, queryAll,
} from "discourse/tests/helpers/qunit-helpers"; } from "discourse/tests/helpers/qunit-helpers";
discourseModule("Integration | Component | Widget | actions-summary", function ( discourseModule(
hooks "Integration | Component | Widget | actions-summary",
) { function (hooks) {
setupRenderingTest(hooks); setupRenderingTest(hooks);
componentTest("post deleted", { componentTest("post deleted", {
@ -31,4 +31,5 @@ discourseModule("Integration | Component | Widget | actions-summary", function (
); );
}, },
}); });
}); }
);

View File

@ -6,9 +6,9 @@ import {
queryAll, queryAll,
} from "discourse/tests/helpers/qunit-helpers"; } from "discourse/tests/helpers/qunit-helpers";
discourseModule("Integration | Component | Widget | avatar-flair", function ( discourseModule(
hooks "Integration | Component | Widget | avatar-flair",
) { function (hooks) {
setupRenderingTest(hooks); setupRenderingTest(hooks);
componentTest("avatar flair with an icon", { componentTest("avatar flair with an icon", {
@ -43,4 +43,5 @@ discourseModule("Integration | Component | Widget | avatar-flair", function (
assert.ok(queryAll("svg").length === 0, "it does not have an svg icon"); assert.ok(queryAll("svg").length === 0, "it does not have an svg icon");
}, },
}); });
}); }
);

View File

@ -12,9 +12,9 @@ let mutedCategoryIds = [];
let unreadCategoryIds = []; let unreadCategoryIds = [];
let categoriesByCount = []; let categoriesByCount = [];
discourseModule("Integration | Component | Widget | hamburger-menu", function ( discourseModule(
hooks "Integration | Component | Widget | hamburger-menu",
) { function (hooks) {
setupRenderingTest(hooks); setupRenderingTest(hooks);
componentTest("prioritize faq", { componentTest("prioritize faq", {
@ -158,7 +158,8 @@ discourseModule("Integration | Component | Widget | hamburger-menu", function (
beforeEach() { beforeEach() {
this.siteSettings.header_dropdown_category_count = 8; this.siteSettings.header_dropdown_category_count = 8;
maxCategoriesToDisplay = this.siteSettings.header_dropdown_category_count; maxCategoriesToDisplay = this.siteSettings
.header_dropdown_category_count;
categoriesByCount = this.site.get("categoriesByCount").slice(); categoriesByCount = this.site.get("categoriesByCount").slice();
categoriesByCount.every((c) => { categoriesByCount.every((c) => {
if (!topCategoryIds.includes(c.id)) { if (!topCategoryIds.includes(c.id)) {
@ -207,7 +208,9 @@ discourseModule("Integration | Component | Widget | hamburger-menu", function (
assert.equal( assert.equal(
queryAll(".category-link .category-name").text(), queryAll(".category-link .category-name").text(),
ids.map((i) => categoriesByCount.find((c) => c.id === i).name).join("") ids
.map((i) => categoriesByCount.find((c) => c.id === i).name)
.join("")
); );
}, },
}); });
@ -260,4 +263,5 @@ discourseModule("Integration | Component | Widget | hamburger-menu", function (
assert.ok(queryAll(".keyboard-shortcuts-link").length); assert.ok(queryAll(".keyboard-shortcuts-link").length);
}, },
}); });
}); }
);

View File

@ -14,9 +14,9 @@ const darkLogo = "/images/d-logo-sketch.png?dark";
const title = "Cool Forum"; const title = "Cool Forum";
const prefersDark = "(prefers-color-scheme: dark)"; const prefersDark = "(prefers-color-scheme: dark)";
discourseModule("Integration | Component | Widget | home-logo", function ( discourseModule(
hooks "Integration | Component | Widget | home-logo",
) { function (hooks) {
setupRenderingTest(hooks); setupRenderingTest(hooks);
componentTest("basics", { componentTest("basics", {
@ -250,4 +250,5 @@ discourseModule("Integration | Component | Widget | home-logo", function (
); );
}, },
}); });
}); }
);

View File

@ -7,9 +7,9 @@ import {
} from "discourse/tests/helpers/qunit-helpers"; } from "discourse/tests/helpers/qunit-helpers";
import { click } from "@ember/test-helpers"; import { click } from "@ember/test-helpers";
discourseModule("Integration | Component | Widget | post-links", function ( discourseModule(
hooks "Integration | Component | Widget | post-links",
) { function (hooks) {
setupRenderingTest(hooks); setupRenderingTest(hooks);
componentTest("duplicate links", { componentTest("duplicate links", {
@ -46,20 +46,52 @@ discourseModule("Integration | Component | Widget | post-links", function (
this.set("args", { this.set("args", {
id: 1, id: 1,
links: [ links: [
{ title: "Link 1", url: "http://eviltrout.com?1", reflection: true }, {
{ title: "Link 2", url: "http://eviltrout.com?2", reflection: true }, title: "Link 1",
{ title: "Link 3", url: "http://eviltrout.com?3", reflection: true }, url: "http://eviltrout.com?1",
{ title: "Link 4", url: "http://eviltrout.com?4", reflection: true }, reflection: true,
{ title: "Link 5", url: "http://eviltrout.com?5", reflection: true }, },
{ title: "Link 6", url: "http://eviltrout.com?6", reflection: true }, {
{ title: "Link 7", url: "http://eviltrout.com?7", reflection: true }, title: "Link 2",
url: "http://eviltrout.com?2",
reflection: true,
},
{
title: "Link 3",
url: "http://eviltrout.com?3",
reflection: true,
},
{
title: "Link 4",
url: "http://eviltrout.com?4",
reflection: true,
},
{
title: "Link 5",
url: "http://eviltrout.com?5",
reflection: true,
},
{
title: "Link 6",
url: "http://eviltrout.com?6",
reflection: true,
},
{
title: "Link 7",
url: "http://eviltrout.com?7",
reflection: true,
},
], ],
}); });
}, },
async test(assert) { async test(assert) {
assert.ok(queryAll(".expand-links").length === 1, "collapsed by default"); assert.ok(
queryAll(".expand-links").length === 1,
"collapsed by default"
);
await click("a.expand-links"); await click("a.expand-links");
assert.equal(queryAll(".post-links a.track-link").length, 7); assert.equal(queryAll(".post-links a.track-link").length, 7);
}, },
}); });
}); }
);

View File

@ -7,9 +7,9 @@ import {
} from "discourse/tests/helpers/qunit-helpers"; } from "discourse/tests/helpers/qunit-helpers";
import { withPluginApi } from "discourse/lib/plugin-api"; import { withPluginApi } from "discourse/lib/plugin-api";
discourseModule("Integration | Component | Widget | post-menu", function ( discourseModule(
hooks "Integration | Component | Widget | post-menu",
) { function (hooks) {
setupRenderingTest(hooks); setupRenderingTest(hooks);
componentTest("add extra button", { componentTest("add extra button", {
@ -51,4 +51,5 @@ discourseModule("Integration | Component | Widget | post-menu", function (
); );
}, },
}); });
}); }
);

View File

@ -21,9 +21,9 @@ function postStreamTest(name, attrs) {
}); });
} }
discourseModule("Integration | Component | Widget | post-stream", function ( discourseModule(
hooks "Integration | Component | Widget | post-stream",
) { function (hooks) {
setupRenderingTest(hooks); setupRenderingTest(hooks);
postStreamTest("basics", { postStreamTest("basics", {
@ -153,4 +153,5 @@ discourseModule("Integration | Component | Widget | post-stream", function (
); );
}, },
}); });
}); }
);

View File

@ -6,9 +6,9 @@ import {
queryAll, queryAll,
} from "discourse/tests/helpers/qunit-helpers"; } from "discourse/tests/helpers/qunit-helpers";
discourseModule("Integration | Component | Widget | poster-name", function ( discourseModule(
hooks "Integration | Component | Widget | poster-name",
) { function (hooks) {
setupRenderingTest(hooks); setupRenderingTest(hooks);
componentTest("basic rendering", { componentTest("basic rendering", {
@ -76,4 +76,5 @@ discourseModule("Integration | Component | Widget | poster-name", function (
assert.equal(queryAll(".second").length, 0); assert.equal(queryAll(".second").length, 0);
}, },
}); });
}); }
);

View File

@ -6,9 +6,9 @@ import {
queryAll, queryAll,
} from "discourse/tests/helpers/qunit-helpers"; } from "discourse/tests/helpers/qunit-helpers";
discourseModule("Integration | Component | Widget | small-user-list", function ( discourseModule(
hooks "Integration | Component | Widget | small-user-list",
) { function (hooks) {
setupRenderingTest(hooks); setupRenderingTest(hooks);
componentTest("renders avatars and support for unknown", { componentTest("renders avatars and support for unknown", {
@ -27,4 +27,5 @@ discourseModule("Integration | Component | Widget | small-user-list", function (
assert.ok(queryAll(".unknown").length, "includes unkown user"); assert.ok(queryAll(".unknown").length, "includes unkown user");
}, },
}); });
}); }
);

View File

@ -7,9 +7,9 @@ import {
} from "discourse/tests/helpers/qunit-helpers"; } from "discourse/tests/helpers/qunit-helpers";
import TopicStatusIcons from "discourse/helpers/topic-status-icons"; import TopicStatusIcons from "discourse/helpers/topic-status-icons";
discourseModule("Integration | Component | Widget | topic-status", function ( discourseModule(
hooks "Integration | Component | Widget | topic-status",
) { function (hooks) {
setupRenderingTest(hooks); setupRenderingTest(hooks);
componentTest("basics", { componentTest("basics", {
@ -44,4 +44,5 @@ discourseModule("Integration | Component | Widget | topic-status", function (
assert.ok(queryAll(".topic-status .d-icon-far-check-square").length); assert.ok(queryAll(".topic-status .d-icon-far-check-square").length);
}, },
}); });
}); }
);

View File

@ -10,9 +10,9 @@ import I18n from "I18n";
import { click } from "@ember/test-helpers"; import { click } from "@ember/test-helpers";
import sinon from "sinon"; import sinon from "sinon";
discourseModule("Integration | Component | Widget | user-menu", function ( discourseModule(
hooks "Integration | Component | Widget | user-menu",
) { function (hooks) {
setupRenderingTest(hooks); setupRenderingTest(hooks);
componentTest("basics", { componentTest("basics", {
@ -232,4 +232,5 @@ discourseModule("Integration | Component | Widget | user-menu", function (
assert.notOk(this.anonymous); assert.notOk(this.anonymous);
}, },
}); });
}); }
);

View File

@ -60,9 +60,9 @@ const TEMPLATE = `
) )
}}`; }}`;
discourseModule("Integration | Component | Widget | widget-dropdown", function ( discourseModule(
hooks "Integration | Component | Widget | widget-dropdown",
) { function (hooks) {
setupRenderingTest(hooks); setupRenderingTest(hooks);
componentTest("dropdown id", { componentTest("dropdown id", {
@ -345,4 +345,5 @@ discourseModule("Integration | Component | Widget | widget-dropdown", function (
); );
}, },
}); });
}); }
);

View File

@ -33,9 +33,9 @@ const Modal = Plugin.Constructor;
function AcceptanceModal(option, _relatedTarget) { function AcceptanceModal(option, _relatedTarget) {
return this.each(function () { return this.each(function () {
var $this = $(this); let $this = $(this);
var data = $this.data("bs.modal"); let data = $this.data("bs.modal");
var options = $.extend( let options = $.extend(
{}, {},
Modal.DEFAULTS, Modal.DEFAULTS,
$this.data(), $this.data(),
@ -202,8 +202,8 @@ export default function setupTests(app, container) {
// Load ES6 tests // Load ES6 tests
function getUrlParameter(name) { function getUrlParameter(name) {
name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]"); name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"); let regex = new RegExp("[\\?&]" + name + "=([^&#]*)");
var results = regex.exec(location.search); let results = regex.exec(location.search);
return results === null return results === null
? "" ? ""
: decodeURIComponent(results[1].replace(/\+/g, " ")); : decodeURIComponent(results[1].replace(/\+/g, " "));

View File

@ -5,8 +5,8 @@ let originalTemplates;
let resolver; let resolver;
function lookupTemplate(assert, name, expectedTemplate, message) { function lookupTemplate(assert, name, expectedTemplate, message) {
var parseName = resolver.parseName(name); let parseName = resolver.parseName(name);
var result = resolver.resolveTemplate(parseName); let result = resolver.resolveTemplate(parseName);
assert.equal(result, expectedTemplate, message); assert.equal(result, expectedTemplate, message);
} }

View File

@ -154,7 +154,7 @@ module("Unit | Utility | click-track", function (hooks) {
assert.notOk(track(generateClickEventOn("a"))); assert.notOk(track(generateClickEventOn("a")));
var $link = fixture("a").first(); let $link = fixture("a").first();
assert.ok($link.hasClass("no-href")); assert.ok($link.hasClass("no-href"));
assert.equal($link.data("href"), "http://www.google.com/"); assert.equal($link.data("href"), "http://www.google.com/");
assert.blank($link.attr("href")); assert.blank($link.attr("href"));
@ -178,7 +178,7 @@ module("Unit | Utility | click-track", function (hooks) {
function badgeClickCount(assert, id, expected) { function badgeClickCount(assert, id, expected) {
track(generateClickEventOn("#" + id)); track(generateClickEventOn("#" + id));
var $badge = $("span.badge", fixture("#" + id).first()); let $badge = $("span.badge", fixture("#" + id).first());
assert.equal(parseInt($badge.html(), 10), expected); assert.equal(parseInt($badge.html(), 10), expected);
} }
@ -200,7 +200,7 @@ module("Unit | Utility | click-track", function (hooks) {
function testOpenInANewTab(description, clickEventModifier) { function testOpenInANewTab(description, clickEventModifier) {
test(description, async function (assert) { test(description, async function (assert) {
var clickEvent = generateClickEventOn("a"); let clickEvent = generateClickEventOn("a");
clickEventModifier(clickEvent); clickEventModifier(clickEvent);
assert.ok(track(clickEvent)); assert.ok(track(clickEvent));
assert.notOk(clickEvent.defaultPrevented); assert.notOk(clickEvent.defaultPrevented);

View File

@ -45,7 +45,7 @@ discourseModule("Unit | Utility | computed", function (hooks) {
}); });
test("propertyEqual", function (assert) { test("propertyEqual", function (assert) {
var t = EmberObject.extend({ let t = EmberObject.extend({
same: propertyEqual("cookies", "biscuits"), same: propertyEqual("cookies", "biscuits"),
}).create({ }).create({
cookies: 10, cookies: 10,
@ -58,7 +58,7 @@ discourseModule("Unit | Utility | computed", function (hooks) {
}); });
test("propertyNotEqual", function (assert) { test("propertyNotEqual", function (assert) {
var t = EmberObject.extend({ let t = EmberObject.extend({
diff: propertyNotEqual("cookies", "biscuits"), diff: propertyNotEqual("cookies", "biscuits"),
}).create({ }).create({
cookies: 10, cookies: 10,
@ -71,7 +71,7 @@ discourseModule("Unit | Utility | computed", function (hooks) {
}); });
test("fmt", function (assert) { test("fmt", function (assert) {
var t = EmberObject.extend({ let t = EmberObject.extend({
exclaimyUsername: fmt("username", "!!! %@ !!!"), exclaimyUsername: fmt("username", "!!! %@ !!!"),
multiple: fmt("username", "mood", "%@ is %@"), multiple: fmt("username", "mood", "%@ is %@"),
}).create({ }).create({
@ -105,7 +105,7 @@ discourseModule("Unit | Utility | computed", function (hooks) {
}); });
test("i18n", function (assert) { test("i18n", function (assert) {
var t = EmberObject.extend({ let t = EmberObject.extend({
exclaimyUsername: i18n("username", "!!! %@ !!!"), exclaimyUsername: i18n("username", "!!! %@ !!!"),
multiple: i18n("username", "mood", "%@ is %@"), multiple: i18n("username", "mood", "%@ is %@"),
}).create({ }).create({
@ -139,7 +139,7 @@ discourseModule("Unit | Utility | computed", function (hooks) {
}); });
test("url", function (assert) { test("url", function (assert) {
var t, testClass; let t, testClass;
testClass = EmberObject.extend({ testClass = EmberObject.extend({
userUrl: url("username", "/u/%@"), userUrl: url("username", "/u/%@"),

View File

@ -159,7 +159,7 @@ discourseModule("Unit | Utility | formatter", function (hooks) {
assert.equal(formatDays(-500), shortDateYear(-500)); assert.equal(formatDays(-500), shortDateYear(-500));
assert.equal(formatDays(-365 * 2 - 1), shortDateYear(-365 * 2 - 1)); // one leap year assert.equal(formatDays(-365 * 2 - 1), shortDateYear(-365 * 2 - 1)); // one leap year
var originalValue = this.siteSettings.relative_date_duration; let originalValue = this.siteSettings.relative_date_duration;
this.siteSettings.relative_date_duration = 7; this.siteSettings.relative_date_duration = 7;
assert.equal(formatDays(7), "7d"); assert.equal(formatDays(7), "7d");
assert.equal(formatDays(8), shortDate(8)); assert.equal(formatDays(8), shortDate(8));
@ -203,9 +203,9 @@ discourseModule("Unit | Utility | formatter", function (hooks) {
}); });
test("autoUpdatingRelativeAge", function (assert) { test("autoUpdatingRelativeAge", function (assert) {
var d = moment().subtract(1, "day").toDate(); let d = moment().subtract(1, "day").toDate();
var $elem = $(autoUpdatingRelativeAge(d)); let $elem = $(autoUpdatingRelativeAge(d));
assert.equal($elem.data("format"), "tiny"); assert.equal($elem.data("format"), "tiny");
assert.equal($elem.data("time"), d.getTime()); assert.equal($elem.data("time"), d.getTime());
assert.equal($elem.attr("title"), undefined); assert.equal($elem.attr("title"), undefined);
@ -233,8 +233,8 @@ discourseModule("Unit | Utility | formatter", function (hooks) {
}); });
test("updateRelativeAge", function (assert) { test("updateRelativeAge", function (assert) {
var d = new Date(); let d = new Date();
var $elem = $(autoUpdatingRelativeAge(d)); let $elem = $(autoUpdatingRelativeAge(d));
$elem.data("time", d.getTime() - 2 * 60 * 1000); $elem.data("time", d.getTime() - 2 * 60 * 1000);
updateRelativeAge($elem); updateRelativeAge($elem);

View File

@ -194,7 +194,7 @@ discourseModule("Unit | Utility | uploads", function () {
test("isImage", function (assert) { test("isImage", function (assert) {
["png", "webp", "jpg", "jpeg", "gif", "ico"].forEach((extension) => { ["png", "webp", "jpg", "jpeg", "gif", "ico"].forEach((extension) => {
var image = "image." + extension; let image = "image." + extension;
assert.ok(isImage(image), image + " is recognized as an image"); assert.ok(isImage(image), image + " is recognized as an image");
assert.ok( assert.ok(
isImage("http://foo.bar/path/to/" + image), isImage("http://foo.bar/path/to/" + image),

View File

@ -71,7 +71,7 @@ discourseModule("Unit | Utilities", function () {
}); });
test("avatarUrl", function (assert) { test("avatarUrl", function (assert) {
var rawSize = getRawSize; let rawSize = getRawSize;
assert.blank(avatarUrl("", "tiny"), "no template returns blank"); assert.blank(avatarUrl("", "tiny"), "no template returns blank");
assert.equal( assert.equal(
avatarUrl("/fake/template/{size}.png", "tiny"), avatarUrl("/fake/template/{size}.png", "tiny"),
@ -85,7 +85,7 @@ discourseModule("Unit | Utilities", function () {
); );
}); });
var setDevicePixelRatio = function (value) { let setDevicePixelRatio = function (value) {
if (Object.defineProperty && !window.hasOwnProperty("devicePixelRatio")) { if (Object.defineProperty && !window.hasOwnProperty("devicePixelRatio")) {
Object.defineProperty(window, "devicePixelRatio", { value: 2 }); Object.defineProperty(window, "devicePixelRatio", { value: 2 });
} else { } else {
@ -94,10 +94,10 @@ discourseModule("Unit | Utilities", function () {
}; };
test("avatarImg", function (assert) { test("avatarImg", function (assert) {
var oldRatio = window.devicePixelRatio; let oldRatio = window.devicePixelRatio;
setDevicePixelRatio(2); setDevicePixelRatio(2);
var avatarTemplate = "/path/to/avatar/{size}.png"; let avatarTemplate = "/path/to/avatar/{size}.png";
assert.equal( assert.equal(
avatarImg({ avatarTemplate: avatarTemplate, size: "tiny" }), avatarImg({ avatarTemplate: avatarTemplate, size: "tiny" }),
"<img alt='' width='20' height='20' src='/path/to/avatar/40.png' class='avatar'>", "<img alt='' width='20' height='20' src='/path/to/avatar/40.png' class='avatar'>",
@ -164,7 +164,7 @@ discourseModule("Unit | Utilities", function () {
}); });
test("caretRowCol", function (assert) { test("caretRowCol", function (assert) {
var textarea = document.createElement("textarea"); let textarea = document.createElement("textarea");
const content = document.createTextNode("01234\n56789\n012345"); const content = document.createTextNode("01234\n56789\n012345");
textarea.appendChild(content); textarea.appendChild(content);
document.body.appendChild(textarea); document.body.appendChild(textarea);

View File

@ -4,10 +4,10 @@ import Singleton from "discourse/mixins/singleton";
module("Unit | Mixin | singleton", function () { module("Unit | Mixin | singleton", function () {
test("current", function (assert) { test("current", function (assert) {
var DummyModel = EmberObject.extend({}); let DummyModel = EmberObject.extend({});
DummyModel.reopenClass(Singleton); DummyModel.reopenClass(Singleton);
var current = DummyModel.current(); let current = DummyModel.current();
assert.present(current, "current returns the current instance"); assert.present(current, "current returns the current instance");
assert.equal( assert.equal(
current, current,
@ -22,9 +22,9 @@ module("Unit | Mixin | singleton", function () {
}); });
test("currentProp reading", function (assert) { test("currentProp reading", function (assert) {
var DummyModel = EmberObject.extend({}); let DummyModel = EmberObject.extend({});
DummyModel.reopenClass(Singleton); DummyModel.reopenClass(Singleton);
var current = DummyModel.current(); let current = DummyModel.current();
assert.blank( assert.blank(
DummyModel.currentProp("evil"), DummyModel.currentProp("evil"),
@ -39,14 +39,14 @@ module("Unit | Mixin | singleton", function () {
}); });
test("currentProp writing", function (assert) { test("currentProp writing", function (assert) {
var DummyModel = EmberObject.extend({}); let DummyModel = EmberObject.extend({});
DummyModel.reopenClass(Singleton); DummyModel.reopenClass(Singleton);
assert.blank( assert.blank(
DummyModel.currentProp("adventure"), DummyModel.currentProp("adventure"),
"by default attributes are blank" "by default attributes are blank"
); );
var result = DummyModel.currentProp("adventure", "time"); let result = DummyModel.currentProp("adventure", "time");
assert.equal(result, "time", "it returns the new value"); assert.equal(result, "time", "it returns the new value");
assert.equal( assert.equal(
DummyModel.currentProp("adventure"), DummyModel.currentProp("adventure"),
@ -70,7 +70,7 @@ module("Unit | Mixin | singleton", function () {
}); });
test("createCurrent", function (assert) { test("createCurrent", function (assert) {
var Shoe = EmberObject.extend({}); let Shoe = EmberObject.extend({});
Shoe.reopenClass(Singleton, { Shoe.reopenClass(Singleton, {
createCurrent: function () { createCurrent: function () {
return Shoe.create({ toes: 5 }); return Shoe.create({ toes: 5 });
@ -85,7 +85,7 @@ module("Unit | Mixin | singleton", function () {
}); });
test("createCurrent that returns null", function (assert) { test("createCurrent that returns null", function (assert) {
var Missing = EmberObject.extend({}); let Missing = EmberObject.extend({});
Missing.reopenClass(Singleton, { Missing.reopenClass(Singleton, {
createCurrent: function () { createCurrent: function () {
return null; return null;

View File

@ -18,13 +18,13 @@ function buildPost(args) {
module("Unit | Model | post", function () { module("Unit | Model | post", function () {
test("defaults", function (assert) { test("defaults", function (assert) {
var post = Post.create({ id: 1 }); let post = Post.create({ id: 1 });
assert.blank(post.get("deleted_at"), "it has no deleted_at by default"); assert.blank(post.get("deleted_at"), "it has no deleted_at by default");
assert.blank(post.get("deleted_by"), "there is no deleted_by by default"); assert.blank(post.get("deleted_by"), "there is no deleted_by by default");
}); });
test("new_user", function (assert) { test("new_user", function (assert) {
var post = Post.create({ trust_level: 0 }); let post = Post.create({ trust_level: 0 });
assert.ok(post.get("new_user"), "post is from a new user"); assert.ok(post.get("new_user"), "post is from a new user");
post.set("trust_level", 1); post.set("trust_level", 1);
@ -32,7 +32,7 @@ module("Unit | Model | post", function () {
}); });
test("firstPost", function (assert) { test("firstPost", function (assert) {
var post = Post.create({ post_number: 1 }); let post = Post.create({ post_number: 1 });
assert.ok(post.get("firstPost"), "it's the first post"); assert.ok(post.get("firstPost"), "it's the first post");
post.set("post_number", 10); post.set("post_number", 10);
@ -40,7 +40,7 @@ module("Unit | Model | post", function () {
}); });
test("updateFromPost", function (assert) { test("updateFromPost", function (assert) {
var post = Post.create({ let post = Post.create({
post_number: 1, post_number: 1,
raw: "hello world", raw: "hello world",
}); });

View File

@ -15,7 +15,7 @@ module("Unit | Model | rest-model", function () {
}, },
}); });
var g = Grape.create({ store, percent: 0.4 }); let g = Grape.create({ store, percent: 0.4 });
assert.equal(g.get("inverse"), 0.6, "it runs `munge` on `create`"); assert.equal(g.get("inverse"), 0.6, "it runs `munge` on `create`");
}); });

View File

@ -9,13 +9,13 @@ function buildDetails(id) {
module("Unit | Model | topic-details", function () { module("Unit | Model | topic-details", function () {
test("defaults", function (assert) { test("defaults", function (assert) {
var details = buildDetails(1234); let details = buildDetails(1234);
assert.present(details, "the details are present by default"); assert.present(details, "the details are present by default");
assert.ok(!details.get("loaded"), "details are not loaded by default"); assert.ok(!details.get("loaded"), "details are not loaded by default");
}); });
test("updateFromJson", function (assert) { test("updateFromJson", function (assert) {
var details = buildDetails(1234); let details = buildDetails(1234);
details.updateFromJson({ details.updateFromJson({
allowed_users: [{ username: "eviltrout" }], allowed_users: [{ username: "eviltrout" }],

View File

@ -3,7 +3,7 @@ import UserAction from "discourse/models/user-action";
module("Unit | Model | user-action", function () { module("Unit | Model | user-action", function () {
test("collapsing likes", function (assert) { test("collapsing likes", function (assert) {
var actions = UserAction.collapseStream([ let actions = UserAction.collapseStream([
UserAction.create({ UserAction.create({
action_type: UserAction.TYPES.likes_given, action_type: UserAction.TYPES.likes_given,
topic_id: 1, topic_id: 1,

View File

@ -4,8 +4,8 @@ import UserAction from "discourse/models/user-action";
module("Unit | Model | user-stream", function () { module("Unit | Model | user-stream", function () {
test("basics", function (assert) { test("basics", function (assert) {
var user = User.create({ id: 1, username: "eviltrout" }); let user = User.create({ id: 1, username: "eviltrout" });
var stream = user.get("stream"); let stream = user.get("stream");
assert.present(stream, "a user has a stream by default"); assert.present(stream, "a user has a stream by default");
assert.equal( assert.equal(
stream.get("user"), stream.get("user"),
@ -25,8 +25,8 @@ module("Unit | Model | user-stream", function () {
}); });
test("filterParam", function (assert) { test("filterParam", function (assert) {
var user = User.create({ id: 1, username: "eviltrout" }); let user = User.create({ id: 1, username: "eviltrout" });
var stream = user.get("stream"); let stream = user.get("stream");
// defaults to posts/topics // defaults to posts/topics
assert.equal(stream.get("filterParam"), "4,5"); assert.equal(stream.get("filterParam"), "4,5");

View File

@ -7,7 +7,7 @@ import sinon from "sinon";
module("Unit | Model | user", function () { module("Unit | Model | user", function () {
test("staff", function (assert) { test("staff", function (assert) {
var user = User.create({ id: 1, username: "eviltrout" }); let user = User.create({ id: 1, username: "eviltrout" });
assert.ok(!user.get("staff"), "user is not staff"); assert.ok(!user.get("staff"), "user is not staff");
@ -19,7 +19,7 @@ module("Unit | Model | user", function () {
}); });
test("searchContext", function (assert) { test("searchContext", function (assert) {
var user = User.create({ id: 1, username: "EvilTrout" }); let user = User.create({ id: 1, username: "EvilTrout" });
assert.deepEqual( assert.deepEqual(
user.get("searchContext"), user.get("searchContext"),
@ -29,7 +29,7 @@ module("Unit | Model | user", function () {
}); });
test("isAllowedToUploadAFile", function (assert) { test("isAllowedToUploadAFile", function (assert) {
var user = User.create({ trust_level: 0, admin: true }); let user = User.create({ trust_level: 0, admin: true });
assert.ok( assert.ok(
user.isAllowedToUploadAFile("image"), user.isAllowedToUploadAFile("image"),
"admin can always upload a file" "admin can always upload a file"

Some files were not shown because too many files have changed in this diff Show More