DEV: Allow typed objects theme settings to be saved via settings editor (#26100)

Why this change?

On the `/admin/customize/themes/<:id>` route, we allow admins to edit
all settings via a settings editor. Prior to this change, trying to edit
and save a typed objects theme settings will result in an error on the
server.
This commit is contained in:
Alan Guo Xiang Tan
2024-03-11 08:42:12 +08:00
committed by GitHub
parent 17a60be189
commit 8d4f405da4
11 changed files with 171 additions and 34 deletions

View File

@ -6,6 +6,7 @@ import {
mapBy,
match,
notEmpty,
readOnly,
} from "@ember/object/computed";
import { service } from "@ember/service";
import { popupAjaxError } from "discourse/lib/ajax-error";
@ -43,6 +44,7 @@ export default class AdminCustomizeThemesShowController extends Controller {
@notEmpty("settings") hasSettings;
@notEmpty("translations") hasTranslations;
@match("model.remote_theme.remote_url", /^http(s)?:\/\//) sourceIsHttp;
@readOnly("model.settings") settings;
@discourseComputed("model.component", "model.remote_theme")
showCheckboxes() {
@ -146,11 +148,6 @@ export default class AdminCustomizeThemesShowController extends Controller {
return `admin.customize.theme.convert_${type}_tooltip`;
}
@discourseComputed("model.settings")
settings(settings) {
return settings.map((setting) => ThemeSettings.create(setting));
}
@discourseComputed("model.translations")
translations(translations) {
return translations.map((setting) =>