From 2df920895d882f8ada5660c88182369379b382ae Mon Sep 17 00:00:00 2001 From: merefield Date: Mon, 10 Jul 2023 07:03:45 +0100 Subject: [PATCH] FE linting --- .../custom-wizard-composer-editor.js.es6 | 8 +- .../controllers/admin-wizards-api-show.js.es6 | 25 +----- .../initializers/custom-wizard-edits.js.es6 | 80 +++++++++---------- 3 files changed, 46 insertions(+), 67 deletions(-) diff --git a/assets/javascripts/discourse/components/custom-wizard-composer-editor.js.es6 b/assets/javascripts/discourse/components/custom-wizard-composer-editor.js.es6 index 5335da81..5560a126 100644 --- a/assets/javascripts/discourse/components/custom-wizard-composer-editor.js.es6 +++ b/assets/javascripts/discourse/components/custom-wizard-composer-editor.js.es6 @@ -14,7 +14,8 @@ import { uploadIcon } from "discourse/lib/uploads"; import { dasherize } from "@ember/string"; import showModal from "discourse/lib/show-modal"; -const IMAGE_MARKDOWN_REGEX = /!\[(.*?)\|(\d{1,4}x\d{1,4})(,\s*\d{1,3}%)?(.*?)\]\((upload:\/\/.*?)\)(?!(.*`))/g; +const IMAGE_MARKDOWN_REGEX = + /!\[(.*?)\|(\d{1,4}x\d{1,4})(,\s*\d{1,3}%)?(.*?)\]\((upload:\/\/.*?)\)(?!(.*`))/g; export default ComposerEditor.extend({ classNameBindings: ["fieldClass"], @@ -116,9 +117,8 @@ export default ComposerEditor.extend({ event.target.closest(".button-wrapper").dataset.imageIndex, 10 ); - const matchingPlaceholder = this.get("composer.reply").match( - IMAGE_MARKDOWN_REGEX - ); + const matchingPlaceholder = + this.get("composer.reply").match(IMAGE_MARKDOWN_REGEX); this.session.set("wizardEventFieldId", this.field.id); this.appEvents.trigger( 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 11bf94d7..c08e820c 100644 --- a/assets/javascripts/discourse/controllers/admin-wizards-api-show.js.es6 +++ b/assets/javascripts/discourse/controllers/admin-wizards-api-show.js.es6 @@ -21,29 +21,8 @@ export default Controller.extend({ "application/x-www-form-urlencoded", ]), successCodes: selectKitContent([ - 100, - 101, - 102, - 200, - 201, - 202, - 203, - 204, - 205, - 206, - 207, - 208, - 226, - 300, - 301, - 302, - 303, - 303, - 304, - 305, - 306, - 307, - 308, + 100, 101, 102, 200, 201, 202, 203, 204, 205, 206, 207, 208, 226, 300, 301, + 302, 303, 303, 304, 305, 306, 307, 308, ]), @discourseComputed( diff --git a/assets/javascripts/discourse/initializers/custom-wizard-edits.js.es6 b/assets/javascripts/discourse/initializers/custom-wizard-edits.js.es6 index 5da38fe8..eb285d15 100644 --- a/assets/javascripts/discourse/initializers/custom-wizard-edits.js.es6 +++ b/assets/javascripts/discourse/initializers/custom-wizard-edits.js.es6 @@ -21,7 +21,7 @@ export default { }; withPluginApi("0.8.36", (api) => { - api.onAppEvent('page:changed', (data) => { + api.onAppEvent("page:changed", (data) => { const currentUser = container.lookup("service:current-user"); const settings = container.lookup("service:site-settings"); const redirectToWizard = currentUser.redirect_to_wizard; @@ -30,10 +30,10 @@ export default { .concat(["loading"]); if ( redirectToWizard && - (data.currentRouteName !== "customWizardStep") && - !(excludedPaths.find((p) => { + data.currentRouteName !== "customWizardStep" && + !excludedPaths.find((p) => { return data.currentRouteName.indexOf(p) > -1; - })) + }) ) { window.location = "/w/" + redirectToWizard.dasherize(); } @@ -60,47 +60,47 @@ export default { // Needed to ensure appEvents get registered when navigating between steps @observes("id") initOnStepChange() { - if(/ wizard - field | wizard - step /.test(this.id)) { - this._initialize(); - } - }, + if (/ wizard - field | wizard - step /.test(this.id)) { + this._initialize(); + } + }, }); - api.modifyClass("component:d-editor", { - pluginId: "custom-wizard", + api.modifyClass("component:d-editor", { + pluginId: "custom-wizard", - didInsertElement() { - this._super(...arguments); + didInsertElement() { + this._super(...arguments); - if (this.wizardComposer) { - this.appEvents.on( - `wizard-editor:insert-text`, - this, - "_wizardInsertText" - ); - this.appEvents.on( - "wizard-editor:replace-text", - this, - "_wizardReplaceText" - ); - } - }, + if (this.wizardComposer) { + this.appEvents.on( + `wizard-editor:insert-text`, + this, + "_wizardInsertText" + ); + this.appEvents.on( + "wizard-editor:replace-text", + this, + "_wizardReplaceText" + ); + } + }, - _wizardInsertText(text, options) { - if ( - this.session.wizardEventFieldId === this.fieldId && - this.element - ) { - this.insertText(text, options); - } - }, + _wizardInsertText(text, options) { + if ( + this.session.wizardEventFieldId === this.fieldId && + this.element + ) { + this.insertText(text, options); + } + }, - _wizardReplaceText(oldVal, newVal, opts = {}) { - if (this.session.wizardEventFieldId === this.fieldId) { - this.replaceText(oldVal, newVal, opts); - } - }, - }); -}); + _wizardReplaceText(oldVal, newVal, opts = {}) { + if (this.session.wizardEventFieldId === this.fieldId) { + this.replaceText(oldVal, newVal, opts); + } + }, + }); + }); }, };