From ad0fd9919b7431ebcee2361647cd9955f7705f91 Mon Sep 17 00:00:00 2001 From: David Taylor Date: Thu, 23 Feb 2023 23:03:27 +0000 Subject: [PATCH] FIX: Correct issues in admin-theme-editor (#20435) Followup to a433b30650d125e6685fb13f679f613003f246aa - `discourseComputed` -> `computed` on a getter (human error) - `this.model` -> `this.theme` (human error) - missing `setField` target param (human error) - `onlyOverriddenChanged` and `save` action method name clashes (native-class-codemod error) --- .../addon/components/admin-theme-editor.hbs | 4 ++-- .../addon/components/admin-theme-editor.js | 18 ++++-------------- 2 files changed, 6 insertions(+), 16 deletions(-) diff --git a/app/assets/javascripts/admin/addon/components/admin-theme-editor.hbs b/app/assets/javascripts/admin/addon/components/admin-theme-editor.hbs index b74b2239f84..e6c201cb784 100644 --- a/app/assets/javascripts/admin/addon/components/admin-theme-editor.hbs +++ b/app/assets/javascripts/admin/addon/components/admin-theme-editor.hbs @@ -44,7 +44,7 @@ @checked={{this.onlyOverridden}} {{on "click" - (action "onlyOverriddenChanged" value="target.checked") + (action this.onlyOverriddenChanged value="target.checked") }} /> {{i18n "admin.customize.theme.hide_unused_fields"}} @@ -125,6 +125,6 @@ @autofocus="true" @placeholder={{this.placeholder}} @htmlPlaceholder={{true}} - @save={{action "save"}} + @save={{this.save}} @setWarning={{action "setWarning"}} /> \ No newline at end of file diff --git a/app/assets/javascripts/admin/addon/components/admin-theme-editor.js b/app/assets/javascripts/admin/addon/components/admin-theme-editor.js index 7d3389902c1..31a0d02ec91 100644 --- a/app/assets/javascripts/admin/addon/components/admin-theme-editor.js +++ b/app/assets/javascripts/admin/addon/components/admin-theme-editor.js @@ -3,7 +3,7 @@ import I18n from "I18n"; import discourseComputed from "discourse-common/utils/decorators"; import { fmt } from "discourse/lib/computed"; import { isDocumentRTL } from "discourse/lib/text-direction"; -import { action } from "@ember/object"; +import { action, computed } from "@ember/object"; import { next } from "@ember/runloop"; export default class AdminThemeEditor extends Component { @@ -62,13 +62,13 @@ export default class AdminThemeEditor extends Component { return ""; } - @discourseComputed("fieldName", "currentTargetName", "theme") + @computed("fieldName", "currentTargetName", "theme") get activeSection() { - return this.model.getField(this.currentTargetName, this.fieldName); + return this.theme.getField(this.currentTargetName, this.fieldName); } set activeSection(value) { - this.theme.setField(this.fieldName, value); + this.theme.setField(this.currentTargetName, this.fieldName, value); return value; } @@ -126,16 +126,6 @@ export default class AdminThemeEditor extends Component { this.fieldAdded(this.currentTargetName, name); } - @action - onlyOverriddenChanged(value) { - this.onlyOverriddenChanged(value); - } - - @action - save() { - this.attrs.save(); - } - @action setWarning(message) { this.set("warning", message);