From 9c17957b4324ccf92a24f49dc0d98ad0f6ef4e0c Mon Sep 17 00:00:00 2001 From: angusmcleod Date: Mon, 12 Apr 2021 15:10:02 +1000 Subject: [PATCH] Apply to javascripts/discourse --- .../discourse/components/custom-field-input.js.es6 | 9 +++++---- .../components/wizard-advanced-toggle.js.es6 | 2 +- .../components/wizard-custom-action.js.es6 | 4 ++-- .../components/wizard-custom-field.js.es6 | 2 +- .../discourse/components/wizard-links.js.es6 | 8 ++++---- .../components/wizard-mapper-input.js.es6 | 8 ++++---- .../discourse/components/wizard-mapper-pair.js.es6 | 2 +- .../components/wizard-mapper-selector.js.es6 | 12 ++++++------ .../components/wizard-realtime-validations.js.es6 | 2 +- .../controllers/admin-wizards-api-show.js.es6 | 14 +++++++------- .../controllers/admin-wizards-logs.js.es6 | 2 +- .../controllers/admin-wizards-wizard-show.js.es6 | 4 ++-- .../initializers/custom-wizard-edits.js.es6 | 2 +- .../initializers/custom-wizard-redirect.js.es6 | 2 +- .../javascripts/discourse/lib/wizard-json.js.es6 | 2 +- .../javascripts/discourse/lib/wizard-mapper.js.es6 | 10 +++++----- .../javascripts/discourse/lib/wizard-schema.js.es6 | 2 +- .../discourse/mixins/undo-changes.js.es6 | 2 +- .../discourse/models/custom-wizard.js.es6 | 6 +++--- 19 files changed, 48 insertions(+), 47 deletions(-) diff --git a/assets/javascripts/discourse/components/custom-field-input.js.es6 b/assets/javascripts/discourse/components/custom-field-input.js.es6 index 1ad0b152..12d93e12 100644 --- a/assets/javascripts/discourse/components/custom-field-input.js.es6 +++ b/assets/javascripts/discourse/components/custom-field-input.js.es6 @@ -1,6 +1,7 @@ import Component from "@ember/component"; import discourseComputed, { observes } from "discourse-common/utils/decorators"; -import { or, alias } from "@ember/object/computed"; +import { alias, or } from "@ember/object/computed"; +import I18n from "I18n"; const generateContent = function (array, type) { return array.map((key) => ({ @@ -66,16 +67,16 @@ export default Component.extend({ "field.serializers" ) saveDisabled(saving) { - if (saving) return true; + if (saving) {return true;} const originalField = this.originalField; - if (!originalField) return false; + if (!originalField) {return false;} return ["name", "klass", "type", "serializers"].every((attr) => { let current = this.get(attr); let original = originalField[attr]; - if (!current) return false; + if (!current) {return false;} if (attr == "serializers") { return this.compareArrays(current, original); diff --git a/assets/javascripts/discourse/components/wizard-advanced-toggle.js.es6 b/assets/javascripts/discourse/components/wizard-advanced-toggle.js.es6 index b03a7ce5..2c5b3434 100644 --- a/assets/javascripts/discourse/components/wizard-advanced-toggle.js.es6 +++ b/assets/javascripts/discourse/components/wizard-advanced-toggle.js.es6 @@ -7,7 +7,7 @@ export default Component.extend({ @discourseComputed("showAdvanced") toggleClass(showAdvanced) { let classes = "btn"; - if (showAdvanced) classes += " btn-primary"; + if (showAdvanced) {classes += " btn-primary";} return classes; }, diff --git a/assets/javascripts/discourse/components/wizard-custom-action.js.es6 b/assets/javascripts/discourse/components/wizard-custom-action.js.es6 index 3dcc85d1..9ea64caa 100644 --- a/assets/javascripts/discourse/components/wizard-custom-action.js.es6 +++ b/assets/javascripts/discourse/components/wizard-custom-action.js.es6 @@ -1,5 +1,5 @@ import { default as discourseComputed } from "discourse-common/utils/decorators"; -import { equal, empty, or, and } from "@ember/object/computed"; +import { and, empty, equal, or } from "@ember/object/computed"; import { generateName, selectKitContent } from "../lib/wizard"; import { computed } from "@ember/object"; import wizardSchema from "../lib/wizard-schema"; @@ -92,7 +92,7 @@ export default Component.extend(UndoChanges, { @discourseComputed("apis", "action.api") availableEndpoints(apis, api) { - if (!api) return []; + if (!api) {return [];} return apis.find((a) => a.name === api).endpoints; }, }); diff --git a/assets/javascripts/discourse/components/wizard-custom-field.js.es6 b/assets/javascripts/discourse/components/wizard-custom-field.js.es6 index 85c26677..09896a6c 100644 --- a/assets/javascripts/discourse/components/wizard-custom-field.js.es6 +++ b/assets/javascripts/discourse/components/wizard-custom-field.js.es6 @@ -1,5 +1,5 @@ import { default as discourseComputed } from "discourse-common/utils/decorators"; -import { equal, or, alias } from "@ember/object/computed"; +import { alias, equal, or } from "@ember/object/computed"; import { computed } from "@ember/object"; import { selectKitContent } from "../lib/wizard"; import UndoChanges from "../mixins/undo-changes"; diff --git a/assets/javascripts/discourse/components/wizard-links.js.es6 b/assets/javascripts/discourse/components/wizard-links.js.es6 index 6f2ca117..9f9d6a01 100644 --- a/assets/javascripts/discourse/components/wizard-links.js.es6 +++ b/assets/javascripts/discourse/components/wizard-links.js.es6 @@ -1,15 +1,15 @@ import { default as discourseComputed, - on, observes, + on, } from "discourse-common/utils/decorators"; import { generateName } from "../lib/wizard"; import { - default as wizardSchema, setWizardDefaults, + default as wizardSchema, } from "../lib/wizard-schema"; import { notEmpty } from "@ember/object/computed"; -import { scheduleOnce, bind } from "@ember/runloop"; +import { bind, scheduleOnce } from "@ember/runloop"; import EmberObject from "@ember/object"; import Component from "@ember/component"; import { A } from "@ember/array"; @@ -53,7 +53,7 @@ export default Component.extend({ "items.@each.title" ) links(current, items) { - if (!items) return; + if (!items) {return;} return items.map((item) => { if (item) { diff --git a/assets/javascripts/discourse/components/wizard-mapper-input.js.es6 b/assets/javascripts/discourse/components/wizard-mapper-input.js.es6 index c7327fbc..021f2084 100644 --- a/assets/javascripts/discourse/components/wizard-mapper-input.js.es6 +++ b/assets/javascripts/discourse/components/wizard-mapper-input.js.es6 @@ -1,11 +1,11 @@ import { computed, set } from "@ember/object"; -import { alias, equal, or, not } from "@ember/object/computed"; +import { alias, equal, not, or } from "@ember/object/computed"; import { - newPair, connectorContent, - inputTypesContent, - defaultSelectionType, defaultConnector, + defaultSelectionType, + inputTypesContent, + newPair, } from "../lib/wizard-mapper"; import Component from "@ember/component"; import { observes } from "discourse-common/utils/decorators"; diff --git a/assets/javascripts/discourse/components/wizard-mapper-pair.js.es6 b/assets/javascripts/discourse/components/wizard-mapper-pair.js.es6 index bc7e9be9..19d7071f 100644 --- a/assets/javascripts/discourse/components/wizard-mapper-pair.js.es6 +++ b/assets/javascripts/discourse/components/wizard-mapper-pair.js.es6 @@ -1,5 +1,5 @@ import { connectorContent } from "../lib/wizard-mapper"; -import { gt, or, alias } from "@ember/object/computed"; +import { alias, gt, or } from "@ember/object/computed"; import { computed, observes } from "@ember/object"; import Component from "@ember/component"; diff --git a/assets/javascripts/discourse/components/wizard-mapper-selector.js.es6 b/assets/javascripts/discourse/components/wizard-mapper-selector.js.es6 index e70708c9..349e7d7d 100644 --- a/assets/javascripts/discourse/components/wizard-mapper-selector.js.es6 +++ b/assets/javascripts/discourse/components/wizard-mapper-selector.js.es6 @@ -1,4 +1,4 @@ -import { alias, or, gt } from "@ember/object/computed"; +import { alias, gt, or } from "@ember/object/computed"; import { computed } from "@ember/object"; import { default as discourseComputed, @@ -7,7 +7,7 @@ import { } from "discourse-common/utils/decorators"; import { getOwner } from "discourse-common/lib/get-owner"; import { defaultSelectionType, selectionTypes } from "../lib/wizard-mapper"; -import { snakeCase, generateName, userProperties } from "../lib/wizard"; +import { generateName, snakeCase, userProperties } from "../lib/wizard"; import Component from "@ember/component"; import { bind, later } from "@ember/runloop"; import I18n from "I18n"; @@ -135,7 +135,7 @@ export default Component.extend({ }, documentClick(e) { - if (this._state == "destroying") return; + if (this._state == "destroying") {return;} let $target = $(e.target); if (!$target.parents(".type-selector").length && this.showTypes) { @@ -275,11 +275,11 @@ export default Component.extend({ optionEnabled(type) { const options = this.options; - if (!options) return false; + if (!options) {return false;} const option = options[type]; - if (option === true) return true; - if (typeof option !== "string") return false; + if (option === true) {return true;} + if (typeof option !== "string") {return false;} return option.split(",").filter((option) => { return [this.selectorType, this.inputType].indexOf(option) !== -1; diff --git a/assets/javascripts/discourse/components/wizard-realtime-validations.js.es6 b/assets/javascripts/discourse/components/wizard-realtime-validations.js.es6 index b9b36e6f..55f98cdb 100644 --- a/assets/javascripts/discourse/components/wizard-realtime-validations.js.es6 +++ b/assets/javascripts/discourse/components/wizard-realtime-validations.js.es6 @@ -19,7 +19,7 @@ export default Component.extend({ init() { this._super(...arguments); - if (!this.validations) return; + if (!this.validations) {return;} if (!this.field.validations) { const validations = {}; diff --git a/assets/javascripts/discourse/controllers/admin-wizards-api-show.js.es6 b/assets/javascripts/discourse/controllers/admin-wizards-api-show.js.es6 index f330c00c..f13652e5 100644 --- a/assets/javascripts/discourse/controllers/admin-wizards-api-show.js.es6 +++ b/assets/javascripts/discourse/controllers/admin-wizards-api-show.js.es6 @@ -2,7 +2,7 @@ import { ajax } from "discourse/lib/ajax"; import { popupAjaxError } from "discourse/lib/ajax-error"; import CustomWizardApi from "../models/custom-wizard-api"; import { default as discourseComputed } from "discourse-common/utils/decorators"; -import { not, and, equal } from "@ember/object/computed"; +import { and, equal, not } from "@ember/object/computed"; import { selectKitContent } from "../lib/wizard"; import Controller from "@ember/controller"; import I18n from "I18n"; @@ -64,8 +64,8 @@ export default Controller.extend({ threeLeggedOauth ) { if (saveDisabled || !authType || !tokenUrl || !clientId || !clientSecret) - return true; - if (threeLeggedOauth) return !authUrl; + {return true;} + if (threeLeggedOauth) {return !authUrl;} return false; }, @@ -149,13 +149,13 @@ export default Controller.extend({ let refreshList = false; let error; - if (!name || !authType) return; + if (!name || !authType) {return;} let data = { auth_type: authType, }; - if (api.title) data["title"] = api.title; + if (api.title) {data["title"] = api.title;} const originalTitle = this.get("api.originalTitle"); if (api.get("isNew") || (originalTitle && api.title !== originalTitle)) { @@ -232,7 +232,7 @@ export default Controller.extend({ remove() { const name = this.get("api.name"); - if (!name) return; + if (!name) {return;} this.set("updating", true); @@ -250,7 +250,7 @@ export default Controller.extend({ clearLogs() { const name = this.get("api.name"); - if (!name) return; + if (!name) {return;} ajax(`/admin/wizards/api/${name.underscore()}/logs`, { type: "DELETE", diff --git a/assets/javascripts/discourse/controllers/admin-wizards-logs.js.es6 b/assets/javascripts/discourse/controllers/admin-wizards-logs.js.es6 index 5a03f064..bc720ffd 100644 --- a/assets/javascripts/discourse/controllers/admin-wizards-logs.js.es6 +++ b/assets/javascripts/discourse/controllers/admin-wizards-logs.js.es6 @@ -13,7 +13,7 @@ export default Controller.extend({ logs: [], loadLogs() { - if (!this.canLoadMore) return; + if (!this.canLoadMore) {return;} this.set("refreshing", true); diff --git a/assets/javascripts/discourse/controllers/admin-wizards-wizard-show.js.es6 b/assets/javascripts/discourse/controllers/admin-wizards-wizard-show.js.es6 index 68dee12e..f975c2f0 100644 --- a/assets/javascripts/discourse/controllers/admin-wizards-wizard-show.js.es6 +++ b/assets/javascripts/discourse/controllers/admin-wizards-wizard-show.js.es6 @@ -3,13 +3,13 @@ import { observes, on, } from "discourse-common/utils/decorators"; -import { notEmpty, alias } from "@ember/object/computed"; +import { alias, notEmpty } from "@ember/object/computed"; import showModal from "discourse/lib/show-modal"; import { generateId, wizardFieldList } from "../lib/wizard"; import { buildProperties } from "../lib/wizard-json"; import { dasherize } from "@ember/string"; import EmberObject from "@ember/object"; -import { scheduleOnce, later } from "@ember/runloop"; +import { later, scheduleOnce } from "@ember/runloop"; import Controller from "@ember/controller"; import copyText from "discourse/lib/copy-text"; import CustomWizard from "../models/custom-wizard"; diff --git a/assets/javascripts/discourse/initializers/custom-wizard-edits.js.es6 b/assets/javascripts/discourse/initializers/custom-wizard-edits.js.es6 index 73eae8b9..0b725d41 100644 --- a/assets/javascripts/discourse/initializers/custom-wizard-edits.js.es6 +++ b/assets/javascripts/discourse/initializers/custom-wizard-edits.js.es6 @@ -6,7 +6,7 @@ export default { initialize(container) { const siteSettings = container.lookup("site-settings:main"); - if (!siteSettings.custom_wizard_enabled) return; + if (!siteSettings.custom_wizard_enabled) {return;} const existing = DiscourseURL.routeTo; DiscourseURL.routeTo = function (path, opts) { diff --git a/assets/javascripts/discourse/initializers/custom-wizard-redirect.js.es6 b/assets/javascripts/discourse/initializers/custom-wizard-redirect.js.es6 index ae4db35b..22afd4de 100644 --- a/assets/javascripts/discourse/initializers/custom-wizard-redirect.js.es6 +++ b/assets/javascripts/discourse/initializers/custom-wizard-redirect.js.es6 @@ -8,7 +8,7 @@ export default { const messageBus = container.lookup("message-bus:main"); const siteSettings = container.lookup("site-settings:main"); - if (!siteSettings.custom_wizard_enabled || !messageBus) return; + if (!siteSettings.custom_wizard_enabled || !messageBus) {return;} messageBus.subscribe("/redirect_to_wizard", function (wizardId) { const wizardUrl = window.location.origin + "/w/" + wizardId; diff --git a/assets/javascripts/discourse/lib/wizard-json.js.es6 b/assets/javascripts/discourse/lib/wizard-json.js.es6 index ec85bb19..ff2c5a5b 100644 --- a/assets/javascripts/discourse/lib/wizard-json.js.es6 +++ b/assets/javascripts/discourse/lib/wizard-json.js.es6 @@ -1,4 +1,4 @@ -import { listProperties, camelCase, snakeCase } from "../lib/wizard"; +import { camelCase, listProperties, snakeCase } from "../lib/wizard"; import wizardSchema from "../lib/wizard-schema"; import EmberObject from "@ember/object"; import { A } from "@ember/array"; diff --git a/assets/javascripts/discourse/lib/wizard-mapper.js.es6 b/assets/javascripts/discourse/lib/wizard-mapper.js.es6 index 8af93297..a8cc8e34 100644 --- a/assets/javascripts/discourse/lib/wizard-mapper.js.es6 +++ b/assets/javascripts/discourse/lib/wizard-mapper.js.es6 @@ -43,13 +43,13 @@ function defaultConnector(connectorType, inputType, options = {}) { return defaultInputType(options); } if (connectorType === "pair") { - if (inputType === "conditional") return "equal"; - if (inputType === "association") return "association"; - if (inputType === "validation") return "equal"; + if (inputType === "conditional") {return "equal";} + if (inputType === "association") {return "association";} + if (inputType === "validation") {return "equal";} } if (connectorType === "output") { - if (inputType === "conditional") return "then"; - if (inputType === "assignment") return "set"; + if (inputType === "conditional") {return "then";} + if (inputType === "assignment") {return "set";} } return "equal"; } diff --git a/assets/javascripts/discourse/lib/wizard-schema.js.es6 b/assets/javascripts/discourse/lib/wizard-schema.js.es6 index 1a1455f8..54d3b255 100644 --- a/assets/javascripts/discourse/lib/wizard-schema.js.es6 +++ b/assets/javascripts/discourse/lib/wizard-schema.js.es6 @@ -1,4 +1,4 @@ -import { set, get } from "@ember/object"; +import { get, set } from "@ember/object"; const wizard = { basic: { diff --git a/assets/javascripts/discourse/mixins/undo-changes.js.es6 b/assets/javascripts/discourse/mixins/undo-changes.js.es6 index 61608cf2..c8d42c52 100644 --- a/assets/javascripts/discourse/mixins/undo-changes.js.es6 +++ b/assets/javascripts/discourse/mixins/undo-changes.js.es6 @@ -1,6 +1,6 @@ import { listProperties } from "../lib/wizard"; import { default as wizardSchema } from "../lib/wizard-schema"; -import { set, get } from "@ember/object"; +import { get, set } from "@ember/object"; import Mixin from "@ember/object/mixin"; import { observes } from "discourse-common/utils/decorators"; import { deepEqual } from "discourse-common/lib/object"; diff --git a/assets/javascripts/discourse/models/custom-wizard.js.es6 b/assets/javascripts/discourse/models/custom-wizard.js.es6 index aa9c1145..d47df6db 100644 --- a/assets/javascripts/discourse/models/custom-wizard.js.es6 +++ b/assets/javascripts/discourse/models/custom-wizard.js.es6 @@ -1,7 +1,7 @@ import { ajax } from "discourse/lib/ajax"; import EmberObject from "@ember/object"; -import { buildProperties, present, mapped } from "../lib/wizard-json"; -import { listProperties, camelCase, snakeCase } from "../lib/wizard"; +import { buildProperties, mapped, present } from "../lib/wizard-json"; +import { camelCase, listProperties, snakeCase } from "../lib/wizard"; import wizardSchema from "../lib/wizard-schema"; import { Promise } from "rsvp"; import { popupAjaxError } from "discourse/lib/ajax-error"; @@ -132,7 +132,7 @@ const CustomWizard = EmberObject.extend({ }, buildMappedJson(inputs) { - if (!inputs || !inputs.length) return false; + if (!inputs || !inputs.length) {return false;} let result = [];