mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-05-25 20:15:50 +08:00
This builds onto #32013 in two major ways: - Unsaved changes are now persisted when you browse categories inside "All site settings". - If you're about to navigate away (and lose edits) you will be prompted if you want to save or discard changes. (This applies to individual category site setting pages as well.
30 lines
885 B
JavaScript
Vendored
30 lines
885 B
JavaScript
Vendored
import { action } from "@ember/object";
|
|
import { service } from "@ember/service";
|
|
import DiscourseRoute from "discourse/routes/discourse";
|
|
|
|
export default class AdminConfigWithSettingsRoute extends DiscourseRoute {
|
|
@service siteSettingChangeTracker;
|
|
|
|
resetController(controller, isExiting) {
|
|
// Have to do this because this is the parent route. We don't want to have
|
|
// to make a controller for every single settings route when we can reset
|
|
// the filter here.
|
|
const settingsController = this.controllerFor(
|
|
`${this.fullRouteName}.settings`
|
|
);
|
|
if (isExiting) {
|
|
settingsController.set("filter", "");
|
|
}
|
|
}
|
|
|
|
@action
|
|
async willTransition(transition) {
|
|
if (this.siteSettingChangeTracker.hasUnsavedChanges) {
|
|
transition.abort();
|
|
|
|
await this.siteSettingChangeTracker.confirmTransition();
|
|
|
|
transition.retry();
|
|
}
|
|
}
|
|
}
|