diff --git a/assets/javascripts/discourse/components/custom-field-input.js.es6 b/assets/javascripts/discourse/components/custom-field-input.js.es6 index 12d93e12..8be7e24b 100644 --- a/assets/javascripts/discourse/components/custom-field-input.js.es6 +++ b/assets/javascripts/discourse/components/custom-field-input.js.es6 @@ -35,7 +35,7 @@ export default Component.extend({ }, @discourseComputed("field.klass") - serializerContent(klass, p2) { + serializerContent(klass) { const serializers = this.get(`${klass}Serializers`); if (serializers) { @@ -78,10 +78,10 @@ export default Component.extend({ if (!current) {return false;} - if (attr == "serializers") { + if (attr === "serializers") { return this.compareArrays(current, original); } else { - return current == original; + return current === original; } }); }, diff --git a/assets/javascripts/discourse/components/wizard-custom-action.js.es6 b/assets/javascripts/discourse/components/wizard-custom-action.js.es6 index 9ea64caa..6d21eaaf 100644 --- a/assets/javascripts/discourse/components/wizard-custom-action.js.es6 +++ b/assets/javascripts/discourse/components/wizard-custom-action.js.es6 @@ -1,11 +1,10 @@ import { default as discourseComputed } from "discourse-common/utils/decorators"; import { and, empty, equal, or } from "@ember/object/computed"; -import { generateName, selectKitContent } from "../lib/wizard"; +import { notificationLevels, selectKitContent } from "../lib/wizard"; import { computed } from "@ember/object"; import wizardSchema from "../lib/wizard-schema"; import UndoChanges from "../mixins/undo-changes"; import Component from "@ember/component"; -import { notificationLevels } from "../lib/wizard"; import I18n from "I18n"; export default Component.extend(UndoChanges, { @@ -43,7 +42,7 @@ export default Component.extend(UndoChanges, { name: I18n.t(`admin.wizard.action.${type}.label`), }; }), - availableNotificationLevels: notificationLevels.map((type, index) => { + availableNotificationLevels: notificationLevels.map((type) => { return { id: type, name: I18n.t( diff --git a/assets/javascripts/discourse/components/wizard-custom-step.js.es6 b/assets/javascripts/discourse/components/wizard-custom-step.js.es6 index 102af717..5715bbda 100644 --- a/assets/javascripts/discourse/components/wizard-custom-step.js.es6 +++ b/assets/javascripts/discourse/components/wizard-custom-step.js.es6 @@ -1,5 +1,4 @@ import Component from "@ember/component"; -import { default as discourseComputed } from "discourse-common/utils/decorators"; export default Component.extend({ classNames: "wizard-custom-step", diff --git a/assets/javascripts/discourse/components/wizard-links.js.es6 b/assets/javascripts/discourse/components/wizard-links.js.es6 index 9f9d6a01..dde84e95 100644 --- a/assets/javascripts/discourse/components/wizard-links.js.es6 +++ b/assets/javascripts/discourse/components/wizard-links.js.es6 @@ -9,7 +9,7 @@ import { default as wizardSchema, } from "../lib/wizard-schema"; import { notEmpty } from "@ember/object/computed"; -import { bind, scheduleOnce } from "@ember/runloop"; +import { scheduleOnce } from "@ember/runloop"; import EmberObject from "@ember/object"; import Component from "@ember/component"; import { A } from "@ember/array"; diff --git a/assets/javascripts/discourse/components/wizard-mapper-connector.js.es6 b/assets/javascripts/discourse/components/wizard-mapper-connector.js.es6 index 36c0ec20..3ec2d502 100644 --- a/assets/javascripts/discourse/components/wizard-mapper-connector.js.es6 +++ b/assets/javascripts/discourse/components/wizard-mapper-connector.js.es6 @@ -3,7 +3,6 @@ import { gt } from "@ember/object/computed"; import { computed } from "@ember/object"; import { defaultConnector } from "../lib/wizard-mapper"; import { later } from "@ember/runloop"; -import { observes } from "discourse-common/utils/decorators"; import I18n from "I18n"; export default Component.extend({ diff --git a/assets/javascripts/discourse/components/wizard-mapper-pair.js.es6 b/assets/javascripts/discourse/components/wizard-mapper-pair.js.es6 index 19d7071f..cb237056 100644 --- a/assets/javascripts/discourse/components/wizard-mapper-pair.js.es6 +++ b/assets/javascripts/discourse/components/wizard-mapper-pair.js.es6 @@ -1,6 +1,6 @@ import { connectorContent } from "../lib/wizard-mapper"; -import { alias, gt, or } from "@ember/object/computed"; -import { computed, observes } from "@ember/object"; +import { alias, gt } from "@ember/object/computed"; +import { computed } from "@ember/object"; import Component from "@ember/component"; export default Component.extend({ diff --git a/assets/javascripts/discourse/components/wizard-mapper-selector.js.es6 b/assets/javascripts/discourse/components/wizard-mapper-selector.js.es6 index 349e7d7d..7e7e9b67 100644 --- a/assets/javascripts/discourse/components/wizard-mapper-selector.js.es6 +++ b/assets/javascripts/discourse/components/wizard-mapper-selector.js.es6 @@ -2,8 +2,7 @@ import { alias, gt, or } from "@ember/object/computed"; import { computed } from "@ember/object"; import { default as discourseComputed, - observes, - on, + observes } from "discourse-common/utils/decorators"; import { getOwner } from "discourse-common/lib/get-owner"; import { defaultSelectionType, selectionTypes } from "../lib/wizard-mapper"; @@ -135,7 +134,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) { @@ -249,7 +248,7 @@ export default Component.extend({ }, @discourseComputed("activeType", "inputType") - placeholderKey(activeType, inputType) { + placeholderKey(activeType) { if ( activeType === "text" && this.options[`${this.selectorType}Placeholder`] @@ -281,8 +280,8 @@ export default Component.extend({ if (option === true) {return true;} if (typeof option !== "string") {return false;} - return option.split(",").filter((option) => { - return [this.selectorType, this.inputType].indexOf(option) !== -1; + return option.split(",").filter((o) => { + return [this.selectorType, this.inputType].indexOf(o) !== -1; }).length; }, diff --git a/assets/javascripts/discourse/components/wizard-mapper.js.es6 b/assets/javascripts/discourse/components/wizard-mapper.js.es6 index 7581adbd..95aabb1c 100644 --- a/assets/javascripts/discourse/components/wizard-mapper.js.es6 +++ b/assets/javascripts/discourse/components/wizard-mapper.js.es6 @@ -1,10 +1,5 @@ -import { getOwner } from "discourse-common/lib/get-owner"; import { newInput, selectionTypes } from "../lib/wizard-mapper"; -import { - default as discourseComputed, - observes, - on, -} from "discourse-common/utils/decorators"; +import discourseComputed from "discourse-common/utils/decorators"; import { later } from "@ember/runloop"; import Component from "@ember/component"; import { A } from "@ember/array"; diff --git a/assets/javascripts/discourse/components/wizard-text-editor.js.es6 b/assets/javascripts/discourse/components/wizard-text-editor.js.es6 index 2866537d..88d7200c 100644 --- a/assets/javascripts/discourse/components/wizard-text-editor.js.es6 +++ b/assets/javascripts/discourse/components/wizard-text-editor.js.es6 @@ -1,7 +1,4 @@ -import { - default as discourseComputed, - on, -} from "discourse-common/utils/decorators"; +import discourseComputed from "discourse-common/utils/decorators"; import { notEmpty } from "@ember/object/computed"; import { userProperties } from "../lib/wizard"; import { scheduleOnce } from "@ember/runloop"; 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 f13652e5..16493715 100644 --- a/assets/javascripts/discourse/controllers/admin-wizards-api-show.js.es6 +++ b/assets/javascripts/discourse/controllers/admin-wizards-api-show.js.es6 @@ -146,7 +146,7 @@ export default Controller.extend({ const api = this.get("api"); const name = api.name; const authType = api.authType; - let refreshList = false; + let refreshList = false; // eslint-disable-line let error; if (!name || !authType) {return;} diff --git a/assets/javascripts/discourse/controllers/admin-wizards-custom-fields.js.es6 b/assets/javascripts/discourse/controllers/admin-wizards-custom-fields.js.es6 index c1254d3b..2081cfe3 100644 --- a/assets/javascripts/discourse/controllers/admin-wizards-custom-fields.js.es6 +++ b/assets/javascripts/discourse/controllers/admin-wizards-custom-fields.js.es6 @@ -1,9 +1,5 @@ import Controller from "@ember/controller"; -import EmberObject from "@ember/object"; -import { ajax } from "discourse/lib/ajax"; -import { popupAjaxError } from "discourse/lib/ajax-error"; import CustomWizardCustomField from "../models/custom-wizard-custom-field"; -import { default as discourseComputed } from "discourse-common/utils/decorators"; export default Controller.extend({ messageKey: "create", @@ -49,7 +45,7 @@ export default Controller.extend({ }, removeField(field) { - return CustomWizardCustomField.destroyField(field).then((result) => { + return CustomWizardCustomField.destroyField(field).then(() => { this.get("customFields").removeObject(field); }); }, diff --git a/assets/javascripts/discourse/controllers/admin-wizards-logs.js.es6 b/assets/javascripts/discourse/controllers/admin-wizards-logs.js.es6 index bc720ffd..3002b95a 100644 --- a/assets/javascripts/discourse/controllers/admin-wizards-logs.js.es6 +++ b/assets/javascripts/discourse/controllers/admin-wizards-logs.js.es6 @@ -1,6 +1,4 @@ -import { default as computed } from "discourse-common/utils/decorators"; -import { popupAjaxError } from "discourse/lib/ajax-error"; -import { ajax } from "discourse/lib/ajax"; +import discourseComputed from "discourse-common/utils/decorators"; import { notEmpty } from "@ember/object/computed"; import CustomWizardLogs from "../models/custom-wizard-logs"; import Controller from "@ember/controller"; @@ -27,7 +25,7 @@ export default Controller.extend({ .finally(() => this.set("refreshing", false)); }, - @computed("hasLogs", "refreshing") + @discourseComputed("hasLogs", "refreshing") noResults(hasLogs, refreshing) { return !hasLogs && !refreshing; }, diff --git a/assets/javascripts/discourse/controllers/admin-wizards-manager.js.es6 b/assets/javascripts/discourse/controllers/admin-wizards-manager.js.es6 index 840d68b1..7228d164 100644 --- a/assets/javascripts/discourse/controllers/admin-wizards-manager.js.es6 +++ b/assets/javascripts/discourse/controllers/admin-wizards-manager.js.es6 @@ -1,8 +1,5 @@ import Controller from "@ember/controller"; -import { - default as discourseComputed, - observes, -} from "discourse-common/utils/decorators"; +import { observes } from "discourse-common/utils/decorators"; import { empty } from "@ember/object/computed"; import CustomWizardManager from "../models/custom-wizard-manager"; import { A } from "@ember/array"; @@ -196,7 +193,7 @@ export default Controller.extend({ }, destroy() { - const destroyWizards = this.get("destroyWizards"); + let destroyWizards = this.get("destroyWizards"); if (!destroyWizards.length) { this.setMessage("error", "none_selected"); @@ -227,7 +224,7 @@ export default Controller.extend({ if (result.destroyed.length) { const destroyedIds = result.destroyed.map((d) => d.id); - const destroyWizards = this.get("destroyWizards"); + destroyWizards = this.get("destroyWizards"); const wizards = this.get("wizards"); wizards.removeObjects( 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 f975c2f0..773fed24 100644 --- a/assets/javascripts/discourse/controllers/admin-wizards-wizard-show.js.es6 +++ b/assets/javascripts/discourse/controllers/admin-wizards-wizard-show.js.es6 @@ -1,18 +1,14 @@ import { default as discourseComputed, - observes, - on, + observes } from "discourse-common/utils/decorators"; -import { alias, notEmpty } from "@ember/object/computed"; +import { 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 { later, scheduleOnce } from "@ember/runloop"; import Controller from "@ember/controller"; import copyText from "discourse/lib/copy-text"; -import CustomWizard from "../models/custom-wizard"; import I18n from "I18n"; export default Controller.extend({ diff --git a/assets/javascripts/discourse/initializers/custom-wizard-edits.js.es6 b/assets/javascripts/discourse/initializers/custom-wizard-edits.js.es6 index 0b725d41..610b80bc 100644 --- a/assets/javascripts/discourse/initializers/custom-wizard-edits.js.es6 +++ b/assets/javascripts/discourse/initializers/custom-wizard-edits.js.es6 @@ -1,4 +1,3 @@ -import { withPluginApi } from "discourse/lib/plugin-api"; import DiscourseURL from "discourse/lib/url"; export default { diff --git a/assets/javascripts/discourse/lib/wizard-json.js.es6 b/assets/javascripts/discourse/lib/wizard-json.js.es6 index ff2c5a5b..4b0aaa3d 100644 --- a/assets/javascripts/discourse/lib/wizard-json.js.es6 +++ b/assets/javascripts/discourse/lib/wizard-json.js.es6 @@ -1,4 +1,4 @@ -import { camelCase, listProperties, snakeCase } from "../lib/wizard"; +import { camelCase, listProperties } 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 a8cc8e34..5fe35996 100644 --- a/assets/javascripts/discourse/lib/wizard-mapper.js.es6 +++ b/assets/javascripts/discourse/lib/wizard-mapper.js.es6 @@ -4,6 +4,13 @@ import I18n from "I18n"; // Inputs +const selectableInputTypes = [ + 'conditional', + 'assignment', + 'association', + 'validation' +]; + function defaultInputType(options = {}) { return options.inputTypes.split(",")[0]; } diff --git a/assets/javascripts/discourse/lib/wizard-schema.js.es6 b/assets/javascripts/discourse/lib/wizard-schema.js.es6 index 54d3b255..effd8a5c 100644 --- a/assets/javascripts/discourse/lib/wizard-schema.js.es6 +++ b/assets/javascripts/discourse/lib/wizard-schema.js.es6 @@ -225,7 +225,7 @@ if (Discourse.SiteSettings.wizard_apis_enabled) { }; } -export function setWizardDefaults(obj, itemType, opts = {}) { +export function setWizardDefaults(obj, itemType) { const objSchema = wizardSchema[itemType]; const basicDefaults = objSchema.basic; diff --git a/assets/javascripts/discourse/lib/wizard.js.es6 b/assets/javascripts/discourse/lib/wizard.js.es6 index 4746fda1..1896b1fe 100644 --- a/assets/javascripts/discourse/lib/wizard.js.es6 +++ b/assets/javascripts/discourse/lib/wizard.js.es6 @@ -9,7 +9,7 @@ function generateName(id) { return id ? sentenceCase(id) : ""; } -function generateId(name, opts = {}) { +function generateId(name) { return name ? snakeCase(name) : ""; } @@ -60,10 +60,10 @@ const notificationLevels = [ "muted", ]; -function listProperties(type, opts = {}) { - let properties = Object.keys(wizardSchema[type].basic); +function listProperties(itemType, opts = {}) { + let properties = Object.keys(wizardSchema[itemType].basic); - const types = wizardSchema[type].types; + const types = wizardSchema[itemType].types; if (types) { let typeProperties = []; diff --git a/assets/javascripts/discourse/mixins/undo-changes.js.es6 b/assets/javascripts/discourse/mixins/undo-changes.js.es6 index c8d42c52..b2ab322d 100644 --- a/assets/javascripts/discourse/mixins/undo-changes.js.es6 +++ b/assets/javascripts/discourse/mixins/undo-changes.js.es6 @@ -2,7 +2,6 @@ import { listProperties } from "../lib/wizard"; import { default as wizardSchema } from "../lib/wizard-schema"; 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"; export default Mixin.create({ @@ -97,7 +96,6 @@ export default Mixin.create({ actions: { undoChanges() { const componentType = this.componentType; - const original = this.get("originalObject"); const obj = this.get(componentType); this.removeObservers(obj.type); @@ -118,6 +116,7 @@ export default Mixin.create({ this.setupObservers(type); }, + // eslint-disable-next-line mappedFieldUpdated(property, mappedComponent, type) { const obj = this.get(this.componentType); obj.notifyPropertyChange(property); diff --git a/assets/javascripts/discourse/models/custom-wizard.js.es6 b/assets/javascripts/discourse/models/custom-wizard.js.es6 index d47df6db..07bdb7b0 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, mapped, present } from "../lib/wizard-json"; -import { camelCase, listProperties, snakeCase } from "../lib/wizard"; +import { listProperties, snakeCase } from "../lib/wizard"; import wizardSchema from "../lib/wizard-schema"; import { Promise } from "rsvp"; import { popupAjaxError } from "discourse/lib/ajax-error"; diff --git a/assets/javascripts/discourse/routes/admin-wizards-api.js.es6 b/assets/javascripts/discourse/routes/admin-wizards-api.js.es6 index 927af8c8..541ab028 100644 --- a/assets/javascripts/discourse/routes/admin-wizards-api.js.es6 +++ b/assets/javascripts/discourse/routes/admin-wizards-api.js.es6 @@ -8,7 +8,7 @@ export default DiscourseRoute.extend({ setupController(controller, model) { const showParams = this.paramsFor("adminWizardsApiShow"); - const apiName = showParams.name == "create" ? null : showParams.name; + const apiName = showParams.name === "create" ? null : showParams.name; const apiList = (model || []).map((api) => { return { id: api.name,