From 0313c773e83ac55499058a69b43980d56b3be31d Mon Sep 17 00:00:00 2001 From: angusmcleod Date: Tue, 7 Sep 2021 20:13:01 +0800 Subject: [PATCH] Apply prettier --- .../components/custom-field-input.js.es6 | 10 +-- .../components/wizard-custom-action.js.es6 | 4 +- .../components/wizard-pro-selector.js.es6 | 8 +-- .../wizard-pro-selector-row.js.es6 | 2 +- .../components/wizard-pro-subscription.js.es6 | 61 ++++++++++-------- .../controllers/admin-wizards-pro.js.es6 | 64 ++++++++++--------- .../admin-wizards-wizard-show.js.es6 | 2 +- .../custom-wizard-admin-route-map.js.es6 | 2 +- .../discourse/lib/wizard-schema.js.es6 | 10 +-- .../discourse/models/custom-wizard-pro.js.es6 | 6 +- .../discourse/models/custom-wizard.js.es6 | 2 +- .../routes/admin-wizards-custom-fields.js.es6 | 2 +- .../discourse/routes/admin-wizards-pro.js.es6 | 6 +- .../routes/admin-wizards-wizard-show.js.es6 | 2 +- assets/stylesheets/common/wizard-admin.scss | 29 +++++---- 15 files changed, 111 insertions(+), 99 deletions(-) diff --git a/assets/javascripts/discourse/components/custom-field-input.js.es6 b/assets/javascripts/discourse/components/custom-field-input.js.es6 index c389fb62..877b83fb 100644 --- a/assets/javascripts/discourse/components/custom-field-input.js.es6 +++ b/assets/javascripts/discourse/components/custom-field-input.js.es6 @@ -8,8 +8,8 @@ const klasses = ["topic", "post", "group", "category"]; const types = ["string", "boolean", "integer", "json"]; const proTypes = { klass: ["group", "category"], - type: ["json"] -} + type: ["json"], +}; const generateContent = function (array, type, proSubscribed = false) { return array.reduce((result, key) => { @@ -19,7 +19,7 @@ const generateContent = function (array, type, proSubscribed = false) { result.push({ id: key, name: I18n.t(`admin.wizard.custom_field.${type}.${key}`), - pro + pro, }); } return result; @@ -32,10 +32,10 @@ export default Component.extend({ postSerializers: ["post"], groupSerializers: ["basic_group"], categorySerializers: ["basic_category"], - klassContent: computed("proSubscribed", function() { + klassContent: computed("proSubscribed", function () { return generateContent(klasses, "klass", this.proSubscribed); }), - typeContent: computed("proSubscribed", function() { + typeContent: computed("proSubscribed", function () { return generateContent(types, "type", this.proSubscribed); }), showInputs: or("field.new", "field.edit"), diff --git a/assets/javascripts/discourse/components/wizard-custom-action.js.es6 b/assets/javascripts/discourse/components/wizard-custom-action.js.es6 index b0831d5d..c50be2ba 100644 --- a/assets/javascripts/discourse/components/wizard-custom-action.js.es6 +++ b/assets/javascripts/discourse/components/wizard-custom-action.js.es6 @@ -102,10 +102,10 @@ export default Component.extend(UndoChanges, { result.push({ id: type, name: I18n.t(`admin.wizard.action.${type}.label`), - pro + pro, }); } return result; }, []); - } + }, }); diff --git a/assets/javascripts/discourse/components/wizard-pro-selector.js.es6 b/assets/javascripts/discourse/components/wizard-pro-selector.js.es6 index b06b5943..7c9567fe 100644 --- a/assets/javascripts/discourse/components/wizard-pro-selector.js.es6 +++ b/assets/javascripts/discourse/components/wizard-pro-selector.js.es6 @@ -2,7 +2,7 @@ import SingleSelectComponent from "select-kit/components/single-select"; import { computed } from "@ember/object"; export default SingleSelectComponent.extend({ - classNames: ["combo-box", 'wizard-pro-selector'], + classNames: ["combo-box", "wizard-pro-selector"], selectKitOptions: { autoFilterable: false, @@ -10,10 +10,10 @@ export default SingleSelectComponent.extend({ showFullTitle: true, headerComponent: "wizard-pro-selector/wizard-pro-selector-header", caretUpIcon: "caret-up", - caretDownIcon: "caret-down" + caretDownIcon: "caret-down", }, modifyComponentForRow() { return "wizard-pro-selector/wizard-pro-selector-row"; - } -}); \ No newline at end of file + }, +}); diff --git a/assets/javascripts/discourse/components/wizard-pro-selector/wizard-pro-selector-row.js.es6 b/assets/javascripts/discourse/components/wizard-pro-selector/wizard-pro-selector-row.js.es6 index 9640cd0c..23034ac1 100644 --- a/assets/javascripts/discourse/components/wizard-pro-selector/wizard-pro-selector-row.js.es6 +++ b/assets/javascripts/discourse/components/wizard-pro-selector/wizard-pro-selector-row.js.es6 @@ -1,3 +1,3 @@ import SelectKitRowComponent from "select-kit/components/select-kit/select-kit-row"; -export default SelectKitRowComponent.extend(); \ No newline at end of file +export default SelectKitRowComponent.extend(); diff --git a/assets/javascripts/discourse/components/wizard-pro-subscription.js.es6 b/assets/javascripts/discourse/components/wizard-pro-subscription.js.es6 index 8ea56699..1c015da5 100644 --- a/assets/javascripts/discourse/components/wizard-pro-subscription.js.es6 +++ b/assets/javascripts/discourse/components/wizard-pro-subscription.js.es6 @@ -4,44 +4,49 @@ import { notEmpty } from "@ember/object/computed"; import discourseComputed from "discourse-common/utils/decorators"; export default Component.extend({ - classNameBindings: [':custom-wizard-pro-subscription', 'subscription.active:active:inactive'], - subscribed: notEmpty('subscription'), + classNameBindings: [ + ":custom-wizard-pro-subscription", + "subscription.active:active:inactive", + ], + subscribed: notEmpty("subscription"), - @discourseComputed('subscription.type') + @discourseComputed("subscription.type") title(type) { - return type ? - I18n.t(`admin.wizard.pro.subscription.title.${type}`) : - I18n.t("admin.wizard.pro.not_subscribed"); + return type + ? I18n.t(`admin.wizard.pro.subscription.title.${type}`) + : I18n.t("admin.wizard.pro.not_subscribed"); }, - @discourseComputed('subscription.active') + @discourseComputed("subscription.active") stateClass(active) { - return active ? 'active' : 'inactive'; + return active ? "active" : "inactive"; }, - @discourseComputed('stateClass') + @discourseComputed("stateClass") stateLabel(stateClass) { return I18n.t(`admin.wizard.pro.subscription.status.${stateClass}`); }, actions: { update() { - this.set('updating', true); - CustomWizardPro.update_subscription().then(result => { - if (result.success) { - this.setProperties({ - updateIcon: 'check', - subscription: result.subscription - }); - } else { - this.set('updateIcon', 'times'); - } - }).finally(() => { - this.set('updating', false); - setTimeout(() => { - this.set('updateIcon', null); - }, 7000); - }) - } - } -}); \ No newline at end of file + this.set("updating", true); + CustomWizardPro.update_subscription() + .then((result) => { + if (result.success) { + this.setProperties({ + updateIcon: "check", + subscription: result.subscription, + }); + } else { + this.set("updateIcon", "times"); + } + }) + .finally(() => { + this.set("updating", false); + setTimeout(() => { + this.set("updateIcon", null); + }, 7000); + }); + }, + }, +}); diff --git a/assets/javascripts/discourse/controllers/admin-wizards-pro.js.es6 b/assets/javascripts/discourse/controllers/admin-wizards-pro.js.es6 index 7c873c66..61012d8f 100644 --- a/assets/javascripts/discourse/controllers/admin-wizards-pro.js.es6 +++ b/assets/javascripts/discourse/controllers/admin-wizards-pro.js.es6 @@ -5,52 +5,58 @@ import { alias } from "@ember/object/computed"; export default Controller.extend({ messageUrl: "https://thepavilion.io/t/3652", - messageType: 'info', + messageType: "info", messageKey: null, - showSubscription: alias('model.authentication.active'), + showSubscription: alias("model.authentication.active"), setup() { - const authentication = this.get('model.authentication'); - const subscription = this.get('model.subscription'); + const authentication = this.get("model.authentication"); + const subscription = this.get("model.subscription"); const subscribed = subscription && subscription.active; const authenticated = authentication && authentication.active; if (!subscribed) { - this.set('messageKey', authenticated ? 'not_subscribed' : 'authorize'); + this.set("messageKey", authenticated ? "not_subscribed" : "authorize"); } else { - this.set('messageKey', !authenticated ? - 'subscription_expiring' : - subscribed ? 'subscription_active' : 'subscription_inactive' + this.set( + "messageKey", + !authenticated + ? "subscription_expiring" + : subscribed + ? "subscription_active" + : "subscription_inactive" ); } }, - @discourseComputed('model.server') + @discourseComputed("model.server") messageOpts(server) { return { server }; }, actions: { unauthorize() { - this.set('unauthorizing', true); + this.set("unauthorizing", true); - CustomWizardPro.unauthorize().then(result => { - if (result.success) { - this.setProperties({ - messageKey: 'unauthorized', - messageType: 'warn', - "model.authentication": null, - "model.subscription": null - }); - } else { - this.setProperties({ - messageKey: 'unauthorize_failed', - messageType: 'error' - }); - } - }).finally(() => { - this.set('unauthorizing', false); - }) - } - } + CustomWizardPro.unauthorize() + .then((result) => { + if (result.success) { + this.setProperties({ + messageKey: "unauthorized", + messageType: "warn", + "model.authentication": null, + "model.subscription": null, + }); + } else { + this.setProperties({ + messageKey: "unauthorize_failed", + messageType: "error", + }); + } + }) + .finally(() => { + this.set("unauthorizing", false); + }); + }, + }, }); 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 a4be0667..6aa5dea4 100644 --- a/assets/javascripts/discourse/controllers/admin-wizards-wizard-show.js.es6 +++ b/assets/javascripts/discourse/controllers/admin-wizards-wizard-show.js.es6 @@ -80,7 +80,7 @@ export default Controller.extend({ if (result.wizard_id) { this.send("afterSave", result.wizard_id); } else if (result.errors) { - this.set('error', result.errors.join(', ')); + this.set("error", result.errors.join(", ")); } }) .catch((result) => { diff --git a/assets/javascripts/discourse/custom-wizard-admin-route-map.js.es6 b/assets/javascripts/discourse/custom-wizard-admin-route-map.js.es6 index ec2f1b98..5468e863 100644 --- a/assets/javascripts/discourse/custom-wizard-admin-route-map.js.es6 +++ b/assets/javascripts/discourse/custom-wizard-admin-route-map.js.es6 @@ -45,7 +45,7 @@ export default { this.route("adminWizardsLogs", { path: "/logs", - resetNamespace: true + resetNamespace: true, }); this.route("adminWizardsManager", { diff --git a/assets/javascripts/discourse/lib/wizard-schema.js.es6 b/assets/javascripts/discourse/lib/wizard-schema.js.es6 index 2e810634..a25ab6d0 100644 --- a/assets/javascripts/discourse/lib/wizard-schema.js.es6 +++ b/assets/javascripts/discourse/lib/wizard-schema.js.es6 @@ -196,11 +196,11 @@ const action = { ], required: ["id", "type"], proTypes: [ - 'send_message', - 'add_to_group', - 'create_category', - 'create_group', - 'send_to_api' + "send_message", + "add_to_group", + "create_category", + "create_group", + "send_to_api", ], dependent: {}, objectArrays: {}, diff --git a/assets/javascripts/discourse/models/custom-wizard-pro.js.es6 b/assets/javascripts/discourse/models/custom-wizard-pro.js.es6 index 66d80572..83afa161 100644 --- a/assets/javascripts/discourse/models/custom-wizard-pro.js.es6 +++ b/assets/javascripts/discourse/models/custom-wizard-pro.js.es6 @@ -23,12 +23,12 @@ CustomWizardPro.reopenClass({ type: "DELETE", }).catch(popupAjaxError); }, - + update_subscription() { return ajax(`${basePath}/subscription`, { type: "POST", }).catch(popupAjaxError); - } + }, }); -export default CustomWizardPro; \ No newline at end of file +export default CustomWizardPro; diff --git a/assets/javascripts/discourse/models/custom-wizard.js.es6 b/assets/javascripts/discourse/models/custom-wizard.js.es6 index 80c4d86a..e6a8408d 100644 --- a/assets/javascripts/discourse/models/custom-wizard.js.es6 +++ b/assets/javascripts/discourse/models/custom-wizard.js.es6 @@ -221,7 +221,7 @@ CustomWizard.reopenClass({ const wizard = this._super.apply(this); wizard.setProperties(buildProperties(wizardJson)); return wizard; - } + }, }); export default CustomWizard; diff --git a/assets/javascripts/discourse/routes/admin-wizards-custom-fields.js.es6 b/assets/javascripts/discourse/routes/admin-wizards-custom-fields.js.es6 index 198f9a14..45ca9ae7 100644 --- a/assets/javascripts/discourse/routes/admin-wizards-custom-fields.js.es6 +++ b/assets/javascripts/discourse/routes/admin-wizards-custom-fields.js.es6 @@ -13,7 +13,7 @@ export default DiscourseRoute.extend({ controller.setProperties({ customFields, - proSubscribed + proSubscribed, }); }, }); diff --git a/assets/javascripts/discourse/routes/admin-wizards-pro.js.es6 b/assets/javascripts/discourse/routes/admin-wizards-pro.js.es6 index 2fa091c7..d5c7fbd7 100644 --- a/assets/javascripts/discourse/routes/admin-wizards-pro.js.es6 +++ b/assets/javascripts/discourse/routes/admin-wizards-pro.js.es6 @@ -7,13 +7,13 @@ export default DiscourseRoute.extend({ }, setupController(controller, model) { - controller.set('model', model); + controller.set("model", model); controller.setup(); }, actions: { authorize() { CustomWizardPro.authorize(); - } - } + }, + }, }); diff --git a/assets/javascripts/discourse/routes/admin-wizards-wizard-show.js.es6 b/assets/javascripts/discourse/routes/admin-wizards-wizard-show.js.es6 index f298fa1c..7032b974 100644 --- a/assets/javascripts/discourse/routes/admin-wizards-wizard-show.js.es6 +++ b/assets/javascripts/discourse/routes/admin-wizards-wizard-show.js.es6 @@ -39,7 +39,7 @@ export default DiscourseRoute.extend({ currentStep: wizard.steps[0], currentAction: wizard.actions[0], creating: model.create, - proSubscribed: parentModel.pro_subscribed + proSubscribed: parentModel.pro_subscribed, }; controller.setProperties(props); diff --git a/assets/stylesheets/common/wizard-admin.scss b/assets/stylesheets/common/wizard-admin.scss index 3146da13..86cb818a 100644 --- a/assets/stylesheets/common/wizard-admin.scss +++ b/assets/stylesheets/common/wizard-admin.scss @@ -700,7 +700,7 @@ background-color: var(--primary-low); padding: 1em; margin: 0 0 1em 0; - + .setting-title { display: flex; align-items: center; @@ -711,7 +711,7 @@ input[type="checkbox"] { margin: 0 5px 0 0; - } + } } .setting-label { @@ -729,7 +729,7 @@ > span { margin-right: 1em; - } + } } } } @@ -741,7 +741,7 @@ .validation-section { min-width: 250px; - margin: .5em 0; + margin: 0.5em 0; } } @@ -761,18 +761,19 @@ .pro-label { color: var(--tertiary); - font-size: .75em; + font-size: 0.75em; } .admin-wizards-pro { .admin-wizard-controls { - h3, label { + h3, + label { margin: 0; } label { - padding: .4em .5em; - margin-left: .75em; + padding: 0.4em 0.5em; + margin-left: 0.75em; background-color: var(--success); color: var(--secondary); } @@ -792,14 +793,14 @@ display: flex; justify-content: space-between; align-items: center; - margin-bottom: .5em; + margin-bottom: 0.5em; h3 { margin: 0; } .buttons > span { - margin-right: .5em; + margin-right: 0.5em; } } @@ -810,8 +811,8 @@ background-color: var(--primary-very-low); .subscription-state { - padding: .25em .5em; - margin-right: .75em; + padding: 0.25em 0.5em; + margin-right: 0.75em; &.active { background-color: var(--success); @@ -829,7 +830,7 @@ } .pro-label { - margin-left: .75em; - padding-top: .25em; + margin-left: 0.75em; + padding-top: 0.25em; } }