From 9d997dbbdea342a2ab92b2c61451f0040bbb628c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Espino=20Garc=C3=ADa?= Date: Mon, 29 Mar 2021 15:53:31 +0200 Subject: [PATCH] Add feature flag for apps (#16851) * Add feature flag for apps * Update default to false * Add plugin version Feature Flag * Fix typo * Only force shutdown, and leave the enable status dependant on the user (defaulting to enable) * Remove unneeded tracking of status * Handle plugin init on startup for locally installed plugin --- app/plugin.go | 7 +++++++ app/plugin_install.go | 3 +++ model/feature_flags.go | 8 ++++++++ 3 files changed, 18 insertions(+) diff --git a/app/plugin.go b/app/plugin.go index e168cddfe9..dbc29f603a 100644 --- a/app/plugin.go +++ b/app/plugin.go @@ -97,6 +97,13 @@ func (a *App) SyncPluginsActiveState() { pluginEnabled = state.Enable } + // Tie Apps proxy disabled status to the feature flag. + if pluginID == "com.mattermost.apps" { + if !a.Config().FeatureFlags.AppsEnabled { + pluginEnabled = false + } + } + if pluginEnabled { enabledPlugins = append(enabledPlugins, plugin) } else { diff --git a/app/plugin_install.go b/app/plugin_install.go index a30065bed8..f0e4b7a3d0 100644 --- a/app/plugin_install.go +++ b/app/plugin_install.go @@ -373,6 +373,9 @@ func (a *App) installExtractedPlugin(manifest *model.Manifest, fromPluginDir str // Activate the plugin if enabled. pluginState := a.Config().PluginSettings.PluginStates[manifest.Id] if pluginState != nil && pluginState.Enable { + if manifest.Id == "com.mattermost.apps" && !a.Config().FeatureFlags.AppsEnabled { + return manifest, nil + } updatedManifest, _, err := pluginsEnvironment.Activate(manifest.Id) if err != nil { return nil, model.NewAppError("installExtractedPlugin", "app.plugin.restart.app_error", nil, err.Error(), http.StatusInternalServerError) diff --git a/model/feature_flags.go b/model/feature_flags.go index 252fa212d8..cdcf87dab7 100644 --- a/model/feature_flags.go +++ b/model/feature_flags.go @@ -19,8 +19,13 @@ type FeatureFlags struct { // Toggle on and off support for Collapsed Threads CollapsedThreads bool + // AppsEnabled toggle the Apps framework functionalities both in server and client side + AppsEnabled bool + // Feature flags to control plugin versions PluginIncidentManagement string `plugin_id:"com.mattermost.plugin-incident-management"` + PluginApps string `plugin_id:"com.mattermost.apps"` + // Toggle on and off support for Files search FilesSearch bool // Feature flag to control setting the TCP_NO_DELAY setting for websockets. @@ -33,7 +38,10 @@ func (f *FeatureFlags) SetDefaults() { f.CloudDelinquentEmailJobsEnabled = false f.CollapsedThreads = false f.FilesSearch = false + f.AppsEnabled = false + f.PluginIncidentManagement = "1.7.0" + f.PluginApps = "" f.WebSocketDelay = false }