2023-08-03 22:19:33 +08:00
|
|
|
import Controller from "@ember/controller";
|
2023-08-28 08:48:59 +08:00
|
|
|
import { action } from "@ember/object";
|
2024-03-07 01:05:11 +08:00
|
|
|
import { service } from "@ember/service";
|
2023-08-03 22:19:33 +08:00
|
|
|
import { popupAjaxError } from "discourse/lib/ajax-error";
|
2023-10-11 02:38:59 +08:00
|
|
|
import SiteSetting from "admin/models/site-setting";
|
2023-08-03 22:19:33 +08:00
|
|
|
|
|
|
|
export default class AdminPluginsIndexController extends Controller {
|
|
|
|
@service session;
|
|
|
|
|
|
|
|
@action
|
|
|
|
async togglePluginEnabled(plugin) {
|
|
|
|
const oldValue = plugin.enabled;
|
|
|
|
const newValue = !oldValue;
|
2023-08-28 08:48:59 +08:00
|
|
|
|
2023-08-03 22:19:33 +08:00
|
|
|
try {
|
2023-08-28 08:48:59 +08:00
|
|
|
plugin.enabled = newValue;
|
|
|
|
await SiteSetting.update(plugin.enabledSetting, newValue);
|
2023-08-03 22:19:33 +08:00
|
|
|
this.session.requiresRefresh = true;
|
|
|
|
} catch (e) {
|
2023-08-28 08:48:59 +08:00
|
|
|
plugin.enabled = oldValue;
|
2023-08-03 22:19:33 +08:00
|
|
|
popupAjaxError(e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|