[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>
Этот коммит содержится в:
Claudio Costa
2022-05-10 19:29:48 +02:00
коммит произвёл GitHub
родитель a4ad6eda5d
Коммит aee68c7ae4
9 изменённых файлов: 155 добавлений и 6 удалений

Просмотреть файл

@@ -2810,6 +2810,11 @@ func (s *PluginSettings) SetDefaults(ls LogSettings) {
s.PluginStates["com.mattermost.apps"] = &PluginState{Enable: true}
}
if s.PluginStates["com.mattermost.calls"] == nil && IsCloud() {
// Enable the calls plugin by default on Cloud only
s.PluginStates["com.mattermost.calls"] = &PluginState{Enable: true}
}
if s.EnableMarketplace == nil {
s.EnableMarketplace = NewBool(PluginSettingsDefaultEnableMarketplace)
}

Просмотреть файл

@@ -6,6 +6,7 @@ package model
import (
"encoding/json"
"fmt"
"os"
"reflect"
"testing"
@@ -1491,3 +1492,38 @@ func TestConfigServiceSettingsIsValid(t *testing.T) {
require.NotNil(t, err)
require.Equal(t, "model.config.is_valid.collapsed_threads.autofollow.app_error", err.Id)
}
func TestConfigDefaultCallsPluginState(t *testing.T) {
t.Run("should not enable Calls plugin by default when not in Cloud", func(t *testing.T) {
c1 := Config{}
c1.SetDefaults()
assert.Nil(t, c1.PluginSettings.PluginStates["com.mattermost.calls"])
})
t.Run("should enable Calls plugin by default on Cloud", func(t *testing.T) {
os.Setenv("MM_CLOUD_INSTALLATION_ID", "test")
defer os.Unsetenv("MM_CLOUD_INSTALLATION_ID")
c1 := Config{}
c1.SetDefaults()
assert.True(t, c1.PluginSettings.PluginStates["com.mattermost.calls"].Enable)
})
t.Run("should not re-enable Calls plugin after it has been disabled", func(t *testing.T) {
os.Setenv("MM_CLOUD_INSTALLATION_ID", "test")
defer os.Unsetenv("MM_CLOUD_INSTALLATION_ID")
c1 := Config{
PluginSettings: PluginSettings{
PluginStates: map[string]*PluginState{
"com.mattermost.calls": {
Enable: false,
},
},
},
}
c1.SetDefaults()
assert.False(t, c1.PluginSettings.PluginStates["com.mattermost.calls"].Enable)
})
}

Просмотреть файл

@@ -32,12 +32,16 @@ type FeatureFlags struct {
PluginPlaybooks string `plugin_id:"playbooks"`
PluginApps string `plugin_id:"com.mattermost.apps"`
PluginFocalboard string `plugin_id:"focalboard"`
PluginCalls string `plugin_id:"com.mattermost.calls"`
PermalinkPreviews bool
// Enable Calls plugin support in the mobile app
CallsMobile bool
// CallsEnabled controls whether or not the Calls plugin should be enabled
CallsEnabled bool
// A dash separated list for feature flags to turn on for Boards
BoardsFeatureFlags string
@@ -93,6 +97,7 @@ func (f *FeatureFlags) SetDefaults() {
f.CloudFree = false
f.CommandPalette = false
}
func (f *FeatureFlags) Plugins() map[string]string {
rFFVal := reflect.ValueOf(f).Elem()
rFFType := reflect.TypeOf(f).Elem()

Просмотреть файл

@@ -16,6 +16,7 @@ import (
"net/http"
"net/mail"
"net/url"
"os"
"regexp"
"sort"
"strings"
@@ -691,3 +692,7 @@ func filterBlocklist(r rune) rune {
return r
}
func IsCloud() bool {
return os.Getenv("MM_CLOUD_INSTALLATION_ID") != ""
}