FIX: Theme translations resetting on save (#22072)

Fixes an issue where saving a theme translation would reset unsaved
changes made to other theme translations.

Also cleans up unused `saveSettings` and `saveTranslations` actions.

Co-authored-by: Jarek Radosz <jradosz@gmail.com>
This commit is contained in:
Penar Musaraj 2023-06-19 10:37:43 -04:00 committed by GitHub
parent 19133af057
commit fc11e77eff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 14 deletions

View File

@ -1,16 +1,23 @@
import SiteSettingComponent from "./site-setting";
import { ajax } from "discourse/lib/ajax";
import { url } from "discourse/lib/computed";
import { alias } from "@ember/object/computed";
export default class ThemeTranslation extends SiteSettingComponent {
@alias("translation") setting;
@alias("translation.key") settingName;
@url("model.id", "/admin/themes/%@") updateUrl;
type = "string";
_save() {
return this.model.saveTranslation(
this.get("translation.key"),
this.get("buffered.value")
);
const translations = {
[this.get("translation.key")]: this.get("buffered.value"),
};
return ajax(this.updateUrl, {
type: "PUT",
data: { theme: translations },
});
}
}

View File

@ -309,16 +309,6 @@ class Theme extends RestModel {
.finally(() => this.set("changed", false))
.catch(popupAjaxError);
}
saveSettings(name, value) {
const settings = {};
settings[name] = value;
return this.save({ settings });
}
saveTranslation(name, value) {
return this.save({ translations: { [name]: value } });
}
}
export default Theme;