mirror of
https://github.com/discourse/discourse.git
synced 2024-12-11 16:23:44 +08:00
5fc93b95cc
This commit contains a few improvements: * Use LinkTo instead of a button with a weird action referencing the controller to navigate to the filtered settings for a plugin * Add an AdminPlugin model with tracked properties and use that when toggling the setting on/off and in the templates * Make it so the Settings button for a plugin navigates to the correct site setting category instead of always just going to the generic "plugins" one if possible
25 lines
697 B
JavaScript
25 lines
697 B
JavaScript
import Controller from "@ember/controller";
|
|
import { action } 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 oldValue = plugin.enabled;
|
|
const newValue = !oldValue;
|
|
|
|
try {
|
|
plugin.enabled = newValue;
|
|
await SiteSetting.update(plugin.enabledSetting, newValue);
|
|
this.session.requiresRefresh = true;
|
|
} catch (e) {
|
|
plugin.enabled = oldValue;
|
|
popupAjaxError(e);
|
|
}
|
|
}
|
|
}
|