Commit 7bfb5aec authored by Joram Wilander's avatar Joram Wilander Committed by Christopher Speller

Add back enable/disable WS events (#9052)

parent 83a3ac08
......@@ -170,6 +170,12 @@ func (a *App) EnablePlugin(id string) *model.AppError {
cfg.PluginSettings.PluginStates[id] = &model.PluginState{Enable: true}
})
if manifest.HasClient() {
message := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_PLUGIN_ENABLED, "", "", "", nil)
message.Add("manifest", manifest.ClientManifest())
a.Publish(message)
}
// This call will cause SyncPluginsActiveState to be called and the plugin to be activated
if err := a.SaveConfig(a.Config(), true); err != nil {
if err.Id == "ent.cluster.save_config.error" {
......@@ -208,6 +214,12 @@ func (a *App) DisablePlugin(id string) *model.AppError {
cfg.PluginSettings.PluginStates[id] = &model.PluginState{Enable: false}
})
if manifest.HasClient() {
message := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_PLUGIN_DISABLED, "", "", "", nil)
message.Add("manifest", manifest.ClientManifest())
a.Publish(message)
}
if err := a.SaveConfig(a.Config(), true); err != nil {
return model.NewAppError("DisablePlugin", "app.plugin.config.app_error", nil, err.Error(), http.StatusInternalServerError)
}
......
......@@ -108,6 +108,12 @@ func (a *App) removePlugin(id string) *model.AppError {
return model.NewAppError("removePlugin", "app.plugin.not_installed.app_error", nil, "", http.StatusBadRequest)
}
if a.Plugins.IsActive(id) && manifest.HasClient() {
message := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_PLUGIN_DISABLED, "", "", "", nil)
message.Add("manifest", manifest.ClientManifest())
a.Publish(message)
}
a.Plugins.Deactivate(id)
err = os.RemoveAll(pluginPath)
......
......@@ -44,7 +44,9 @@ const (
WEBSOCKET_EVENT_RESPONSE = "response"
WEBSOCKET_EVENT_EMOJI_ADDED = "emoji_added"
WEBSOCKET_EVENT_CHANNEL_VIEWED = "channel_viewed"
WEBSOCKET_EVENT_PLUGIN_STATUSES_CHANGED = "plugin_statuses_changed" // EXPERIMENTAL - SUBJECT TO CHANGE
WEBSOCKET_EVENT_PLUGIN_STATUSES_CHANGED = "plugin_statuses_changed"
WEBSOCKET_EVENT_PLUGIN_ENABLED = "plugin_enabled"
WEBSOCKET_EVENT_PLUGIN_DISABLED = "plugin_disabled"
WEBSOCKET_EVENT_ROLE_UPDATED = "role_updated"
WEBSOCKET_EVENT_LICENSE_CHANGED = "license_changed"
WEBSOCKET_EVENT_CONFIG_CHANGED = "config_changed"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment