mirror of
https://github.com/discourse/discourse.git
synced 2024-11-30 10:33:43 +08:00
45ae9d9bab
This commit makes some visual tweaks to the admin panel plugin list, and introduces functional 'toggle switches' for admins to enable/disable plugins more easily. Co-authored-by: Jordan Vidrine <jordan@jordanvidrine.com>
26 lines
768 B
JavaScript
26 lines
768 B
JavaScript
import Controller from "@ember/controller";
|
|
import { action, set } from "@ember/object";
|
|
import { inject as service } from "@ember/service";
|
|
import SiteSetting from "admin/models/site-setting";
|
|
import { popupAjaxError } from "discourse/lib/ajax-error";
|
|
|
|
export default class AdminPluginsIndexController extends Controller {
|
|
@service session;
|
|
|
|
@action
|
|
async togglePluginEnabled(plugin) {
|
|
const enabledSettingName = plugin.enabled_setting;
|
|
|
|
const oldValue = plugin.enabled;
|
|
const newValue = !oldValue;
|
|
try {
|
|
set(plugin, "enabled", newValue);
|
|
await SiteSetting.update(enabledSettingName, newValue);
|
|
this.session.requiresRefresh = true;
|
|
} catch (e) {
|
|
set(plugin, "enabled", oldValue);
|
|
popupAjaxError(e);
|
|
}
|
|
}
|
|
}
|