[MM-44056] Make Calls plugin's state on Cloud controllable by feature flag (#20161)
* Make Calls plugin's state on Cloud controllable by feature flag * Prepackage Calls v0.4.9 (#20148) * Update app/plugin.go Co-authored-by: Jesse Hallam <jesse.hallam@gmail.com> * Update app/plugin_install.go Co-authored-by: Jesse Hallam <jesse.hallam@gmail.com> * Bump Calls version to latest Co-authored-by: Jesse Hallam <jesse.hallam@gmail.com> Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
a4ad6eda5d
Коммит
aee68c7ae4
@@ -98,11 +98,8 @@ func (ch *Channels) syncPluginsActiveState() {
|
||||
pluginEnabled = state.Enable
|
||||
}
|
||||
|
||||
// Tie Apps proxy disabled status to the feature flag.
|
||||
if pluginID == "com.mattermost.apps" {
|
||||
if !ch.cfgSvc.Config().FeatureFlags.AppsEnabled {
|
||||
pluginEnabled = false
|
||||
}
|
||||
if hasOverride, value := ch.getPluginStateOverride(pluginID); hasOverride {
|
||||
pluginEnabled = value
|
||||
}
|
||||
|
||||
if pluginEnabled {
|
||||
@@ -1064,3 +1061,19 @@ func getIcon(iconPath string) (string, error) {
|
||||
|
||||
return fmt.Sprintf("data:image/svg+xml;base64,%s", base64.StdEncoding.EncodeToString(icon)), nil
|
||||
}
|
||||
|
||||
func (ch *Channels) getPluginStateOverride(pluginID string) (bool, bool) {
|
||||
switch pluginID {
|
||||
case "com.mattermost.apps":
|
||||
// Tie Apps proxy disabled status to the feature flag.
|
||||
if !ch.cfgSvc.Config().FeatureFlags.AppsEnabled {
|
||||
return true, false
|
||||
}
|
||||
case "com.mattermost.calls":
|
||||
if model.IsCloud() {
|
||||
return true, ch.cfgSvc.Config().FeatureFlags.CallsEnabled
|
||||
}
|
||||
}
|
||||
|
||||
return false, false
|
||||
}
|
||||
|
||||
@@ -393,9 +393,10 @@ func (ch *Channels) installExtractedPlugin(manifest *model.Manifest, fromPluginD
|
||||
// Activate the plugin if enabled.
|
||||
pluginState := ch.cfgSvc.Config().PluginSettings.PluginStates[manifest.Id]
|
||||
if pluginState != nil && pluginState.Enable {
|
||||
if manifest.Id == "com.mattermost.apps" && !ch.cfgSvc.Config().FeatureFlags.AppsEnabled {
|
||||
if hasOverride, enabled := ch.getPluginStateOverride(manifest.Id); hasOverride && !enabled {
|
||||
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)
|
||||
|
||||
@@ -965,3 +965,78 @@ func TestProcessPrepackagedPlugins(t *testing.T) {
|
||||
require.Len(t, pluginStatus, 0)
|
||||
})
|
||||
}
|
||||
|
||||
func TestGetPluginStateOverride(t *testing.T) {
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
t.Run("no override", func(t *testing.T) {
|
||||
overrides, value := th.App.ch.getPluginStateOverride("focalboard")
|
||||
require.False(t, overrides)
|
||||
require.False(t, value)
|
||||
})
|
||||
|
||||
t.Run("calls override", func(t *testing.T) {
|
||||
t.Run("on-prem", func(t *testing.T) {
|
||||
overrides, value := th.App.ch.getPluginStateOverride("com.mattermost.calls")
|
||||
require.False(t, overrides)
|
||||
require.False(t, value)
|
||||
})
|
||||
|
||||
t.Run("Cloud, without enabled flag", func(t *testing.T) {
|
||||
os.Setenv("MM_CLOUD_INSTALLATION_ID", "test")
|
||||
defer os.Unsetenv("MM_CLOUD_INSTALLATION_ID")
|
||||
overrides, value := th.App.ch.getPluginStateOverride("com.mattermost.calls")
|
||||
require.True(t, overrides)
|
||||
require.False(t, value)
|
||||
})
|
||||
|
||||
t.Run("Cloud, with enabled flag set to true", func(t *testing.T) {
|
||||
os.Setenv("MM_CLOUD_INSTALLATION_ID", "test")
|
||||
defer os.Unsetenv("MM_CLOUD_INSTALLATION_ID")
|
||||
os.Setenv("MM_FEATUREFLAGS_CALLSENABLED", "true")
|
||||
defer os.Unsetenv("MM_FEATUREFLAGS_CALLSENABLED")
|
||||
|
||||
th2 := Setup(t)
|
||||
defer th2.TearDown()
|
||||
|
||||
overrides, value := th2.App.ch.getPluginStateOverride("com.mattermost.calls")
|
||||
require.True(t, overrides)
|
||||
require.True(t, value)
|
||||
})
|
||||
|
||||
t.Run("Cloud, with enabled flag set to false", func(t *testing.T) {
|
||||
os.Setenv("MM_CLOUD_INSTALLATION_ID", "test")
|
||||
defer os.Unsetenv("MM_CLOUD_INSTALLATION_ID")
|
||||
os.Setenv("MM_FEATUREFLAGS_CALLSENABLED", "false")
|
||||
defer os.Unsetenv("MM_FEATUREFLAGS_CALLSENABLED")
|
||||
|
||||
th2 := Setup(t)
|
||||
defer th2.TearDown()
|
||||
|
||||
overrides, value := th2.App.ch.getPluginStateOverride("com.mattermost.calls")
|
||||
require.True(t, overrides)
|
||||
require.False(t, value)
|
||||
})
|
||||
})
|
||||
|
||||
t.Run("apps override", func(t *testing.T) {
|
||||
t.Run("without enabled flag", func(t *testing.T) {
|
||||
overrides, value := th.App.ch.getPluginStateOverride("com.mattermost.apps")
|
||||
require.False(t, overrides)
|
||||
require.False(t, value)
|
||||
})
|
||||
|
||||
t.Run("with enabled flag set to false", func(t *testing.T) {
|
||||
os.Setenv("MM_FEATUREFLAGS_APPSENABLED", "false")
|
||||
defer os.Unsetenv("MM_FEATUREFLAGS_APPSENABLED")
|
||||
|
||||
th2 := Setup(t)
|
||||
defer th2.TearDown()
|
||||
|
||||
overrides, value := th2.App.ch.getPluginStateOverride("com.mattermost.apps")
|
||||
require.True(t, overrides)
|
||||
require.False(t, value)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user