From 54c00f17841fa3eca7cf527308b56de047df2b5c Mon Sep 17 00:00:00 2001 From: angusmcleod Date: Mon, 12 Apr 2021 16:12:20 +1000 Subject: [PATCH] Apply prettier to recent changes --- .../components/custom-field-input.js.es6 | 12 ++++++-- .../components/wizard-advanced-toggle.js.es6 | 4 ++- .../components/wizard-custom-action.js.es6 | 4 ++- .../discourse/components/wizard-links.js.es6 | 4 ++- .../components/wizard-mapper-selector.js.es6 | 18 ++++++++---- .../wizard-realtime-validations.js.es6 | 4 ++- .../controllers/admin-wizards-api-show.js.es6 | 25 ++++++++++++----- .../controllers/admin-wizards-logs.js.es6 | 4 ++- .../admin-wizards-wizard-show.js.es6 | 2 +- .../initializers/custom-wizard-edits.js.es6 | 4 ++- .../custom-wizard-redirect.js.es6 | 4 ++- .../discourse/lib/wizard-mapper.js.es6 | 28 +++++++++++++------ .../discourse/models/custom-wizard.js.es6 | 4 ++- 13 files changed, 84 insertions(+), 33 deletions(-) diff --git a/assets/javascripts/discourse/components/custom-field-input.js.es6 b/assets/javascripts/discourse/components/custom-field-input.js.es6 index 8be7e24b..f2dca4c7 100644 --- a/assets/javascripts/discourse/components/custom-field-input.js.es6 +++ b/assets/javascripts/discourse/components/custom-field-input.js.es6 @@ -67,16 +67,22 @@ 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 2c5b3434..c6e1fd9c 100644 --- a/assets/javascripts/discourse/components/wizard-advanced-toggle.js.es6 +++ b/assets/javascripts/discourse/components/wizard-advanced-toggle.js.es6 @@ -7,7 +7,9 @@ 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 6d21eaaf..c8309f10 100644 --- a/assets/javascripts/discourse/components/wizard-custom-action.js.es6 +++ b/assets/javascripts/discourse/components/wizard-custom-action.js.es6 @@ -91,7 +91,9 @@ 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-links.js.es6 b/assets/javascripts/discourse/components/wizard-links.js.es6 index dde84e95..5d82a57d 100644 --- a/assets/javascripts/discourse/components/wizard-links.js.es6 +++ b/assets/javascripts/discourse/components/wizard-links.js.es6 @@ -53,7 +53,9 @@ 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-selector.js.es6 b/assets/javascripts/discourse/components/wizard-mapper-selector.js.es6 index 7e7e9b67..6d65d782 100644 --- a/assets/javascripts/discourse/components/wizard-mapper-selector.js.es6 +++ b/assets/javascripts/discourse/components/wizard-mapper-selector.js.es6 @@ -2,7 +2,7 @@ import { alias, gt, or } from "@ember/object/computed"; import { computed } from "@ember/object"; import { default as discourseComputed, - observes + observes, } from "discourse-common/utils/decorators"; import { getOwner } from "discourse-common/lib/get-owner"; import { defaultSelectionType, selectionTypes } from "../lib/wizard-mapper"; @@ -134,7 +134,9 @@ 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) { @@ -274,11 +276,17 @@ 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((o) => { return [this.selectorType, this.inputType].indexOf(o) !== -1; diff --git a/assets/javascripts/discourse/components/wizard-realtime-validations.js.es6 b/assets/javascripts/discourse/components/wizard-realtime-validations.js.es6 index 55f98cdb..8332b86e 100644 --- a/assets/javascripts/discourse/components/wizard-realtime-validations.js.es6 +++ b/assets/javascripts/discourse/components/wizard-realtime-validations.js.es6 @@ -19,7 +19,9 @@ 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 16493715..5dba2d7f 100644 --- a/assets/javascripts/discourse/controllers/admin-wizards-api-show.js.es6 +++ b/assets/javascripts/discourse/controllers/admin-wizards-api-show.js.es6 @@ -63,9 +63,12 @@ export default Controller.extend({ clientSecret, threeLeggedOauth ) { - if (saveDisabled || !authType || !tokenUrl || !clientId || !clientSecret) - {return true;} - if (threeLeggedOauth) {return !authUrl;} + if (saveDisabled || !authType || !tokenUrl || !clientId || !clientSecret) { + return true; + } + if (threeLeggedOauth) { + return !authUrl; + } return false; }, @@ -149,13 +152,17 @@ export default Controller.extend({ let refreshList = false; // eslint-disable-line 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 +239,9 @@ export default Controller.extend({ remove() { const name = this.get("api.name"); - if (!name) {return;} + if (!name) { + return; + } this.set("updating", true); @@ -250,7 +259,9 @@ 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 3002b95a..9559b01b 100644 --- a/assets/javascripts/discourse/controllers/admin-wizards-logs.js.es6 +++ b/assets/javascripts/discourse/controllers/admin-wizards-logs.js.es6 @@ -11,7 +11,9 @@ 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 773fed24..332efedd 100644 --- a/assets/javascripts/discourse/controllers/admin-wizards-wizard-show.js.es6 +++ b/assets/javascripts/discourse/controllers/admin-wizards-wizard-show.js.es6 @@ -1,6 +1,6 @@ import { default as discourseComputed, - observes + observes, } from "discourse-common/utils/decorators"; import { notEmpty } from "@ember/object/computed"; import showModal from "discourse/lib/show-modal"; diff --git a/assets/javascripts/discourse/initializers/custom-wizard-edits.js.es6 b/assets/javascripts/discourse/initializers/custom-wizard-edits.js.es6 index 610b80bc..63ddd5e8 100644 --- a/assets/javascripts/discourse/initializers/custom-wizard-edits.js.es6 +++ b/assets/javascripts/discourse/initializers/custom-wizard-edits.js.es6 @@ -5,7 +5,9 @@ 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 22afd4de..21dd0e81 100644 --- a/assets/javascripts/discourse/initializers/custom-wizard-redirect.js.es6 +++ b/assets/javascripts/discourse/initializers/custom-wizard-redirect.js.es6 @@ -8,7 +8,9 @@ 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-mapper.js.es6 b/assets/javascripts/discourse/lib/wizard-mapper.js.es6 index 5fe35996..29315b9c 100644 --- a/assets/javascripts/discourse/lib/wizard-mapper.js.es6 +++ b/assets/javascripts/discourse/lib/wizard-mapper.js.es6 @@ -5,10 +5,10 @@ import I18n from "I18n"; // Inputs const selectableInputTypes = [ - 'conditional', - 'assignment', - 'association', - 'validation' + "conditional", + "assignment", + "association", + "validation", ]; function defaultInputType(options = {}) { @@ -50,13 +50,23 @@ 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/models/custom-wizard.js.es6 b/assets/javascripts/discourse/models/custom-wizard.js.es6 index 07bdb7b0..7d97183f 100644 --- a/assets/javascripts/discourse/models/custom-wizard.js.es6 +++ b/assets/javascripts/discourse/models/custom-wizard.js.es6 @@ -132,7 +132,9 @@ const CustomWizard = EmberObject.extend({ }, buildMappedJson(inputs) { - if (!inputs || !inputs.length) {return false;} + if (!inputs || !inputs.length) { + return false; + } let result = [];