discourse/app/assets/javascripts/admin/addon/routes/admin-customize-themes-show-schema.js
Alan Guo Xiang Tan ef99b97ea7
DEV: Load theme objects typed setting metadata when routing to editor (#26354)
Why this change?

Previously, we were preloading the necessary metadata for
`adminCustomizeThemes.show.schema` route in the
`adminCustomizeThemes.show` route. This is wasteful because we're
loading data upfront when the objects setting editor may not be used.

This change also lays the ground work for a future commit where we need
to be shipping down additional metadata which may further add to the
payload.
2024-03-26 14:02:05 +08:00

35 lines
846 B
JavaScript

import Route from "@ember/routing/route";
export default class AdminCustomizeThemesShowSchemaRoute extends Route {
model(params) {
const theme = this.modelFor("adminCustomizeThemesShow");
const setting = theme.settings.findBy("setting", params.setting_name);
return setting.loadMetadata(theme.id).then(() => {
return {
theme,
setting,
};
});
}
setupController() {
super.setupController(...arguments);
this.controllerFor("adminCustomizeThemes").set("editingTheme", true);
this.controllerFor("adminCustomizeThemes.show").set(
"editingThemeSetting",
true
);
}
deactivate() {
this.controllerFor("adminCustomizeThemes").set("editingTheme", false);
this.controllerFor("adminCustomizeThemes.show").set(
"editingThemeSetting",
false
);
}
}