2021-10-16 14:11:32 -07:00
|
|
|
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
|
|
// See LICENSE.txt for license information.
|
|
|
|
|
|
|
|
package model
|
|
|
|
|
|
|
|
import (
|
|
|
|
"reflect"
|
|
|
|
"strconv"
|
|
|
|
)
|
|
|
|
|
|
|
|
type FeatureFlags struct {
|
|
|
|
// Exists only for unit and manual testing.
|
|
|
|
// When set to a value, will be returned by the ping endpoint.
|
|
|
|
TestFeature string
|
|
|
|
// Exists only for testing bool functionality. Boolean feature flags interpret "on" or "true" as true and
|
|
|
|
// all other values as false.
|
|
|
|
TestBoolFeature bool
|
|
|
|
|
|
|
|
// Toggle on and off support for Collapsed Threads
|
|
|
|
CollapsedThreads bool
|
|
|
|
|
|
|
|
// Enable the remote cluster service for shared channels.
|
|
|
|
EnableRemoteClusterService bool
|
|
|
|
|
2022-01-18 11:24:14 -08:00
|
|
|
// AppsEnabled toggles the Apps framework functionalities both in server and client side
|
2021-10-16 14:11:32 -07:00
|
|
|
AppsEnabled bool
|
|
|
|
|
2022-01-18 11:24:14 -08:00
|
|
|
// AppBarEnabled toggles the App Bar component on client side
|
|
|
|
AppBarEnabled bool
|
|
|
|
|
2021-10-16 14:11:32 -07:00
|
|
|
// Feature flags to control plugin versions
|
|
|
|
PluginPlaybooks string `plugin_id:"playbooks"`
|
|
|
|
PluginApps string `plugin_id:"com.mattermost.apps"`
|
|
|
|
PluginFocalboard string `plugin_id:"focalboard"`
|
|
|
|
|
|
|
|
PermalinkPreviews bool
|
|
|
|
|
2021-12-11 15:05:15 -08:00
|
|
|
// Enable Calls plugin support in the mobile app
|
|
|
|
CallsMobile bool
|
|
|
|
|
2022-01-18 11:24:14 -08:00
|
|
|
// A dash separated list for feature flags to turn on for Boards
|
|
|
|
BoardsFeatureFlags string
|
|
|
|
|
|
|
|
// Enable Create First Channel
|
|
|
|
GuidedChannelCreation bool
|
|
|
|
|
|
|
|
// A/B test for whether radio buttons or toggle button is more effective in in-screen invite to team modal ("none", "toggle")
|
|
|
|
InviteToTeam string
|
2022-03-12 10:41:07 -08:00
|
|
|
|
2022-03-31 15:23:19 -07:00
|
|
|
CustomGroups bool
|
|
|
|
|
2022-03-12 10:41:07 -08:00
|
|
|
// Enable DataRetention for Boards
|
|
|
|
BoardsDataRetention bool
|
|
|
|
|
|
|
|
NormalizeLdapDNs bool
|
2022-03-31 15:23:19 -07:00
|
|
|
|
|
|
|
EnableInactivityCheckJob bool
|
|
|
|
|
|
|
|
// Enable special onboarding flow for first admin
|
|
|
|
UseCaseOnboarding bool
|
|
|
|
|
|
|
|
// Enable GraphQL feature
|
|
|
|
GraphQL bool
|
2022-06-11 14:07:42 -07:00
|
|
|
|
|
|
|
InsightsEnabled bool
|
|
|
|
|
|
|
|
CommandPalette bool
|
2021-10-16 14:11:32 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
func (f *FeatureFlags) SetDefaults() {
|
|
|
|
f.TestFeature = "off"
|
|
|
|
f.TestBoolFeature = false
|
|
|
|
f.CollapsedThreads = true
|
|
|
|
f.EnableRemoteClusterService = false
|
2022-05-01 15:10:54 -07:00
|
|
|
f.AppsEnabled = true
|
2022-01-18 11:24:14 -08:00
|
|
|
f.AppBarEnabled = false
|
2021-10-16 14:11:32 -07:00
|
|
|
f.PluginApps = ""
|
|
|
|
f.PluginFocalboard = ""
|
|
|
|
f.PermalinkPreviews = true
|
2021-12-11 15:05:15 -08:00
|
|
|
f.CallsMobile = false
|
2022-01-18 11:24:14 -08:00
|
|
|
f.BoardsFeatureFlags = ""
|
|
|
|
f.GuidedChannelCreation = false
|
|
|
|
f.InviteToTeam = "none"
|
2022-03-31 15:23:19 -07:00
|
|
|
f.CustomGroups = true
|
2022-03-12 10:41:07 -08:00
|
|
|
f.BoardsDataRetention = false
|
|
|
|
f.NormalizeLdapDNs = false
|
2022-03-31 15:23:19 -07:00
|
|
|
f.EnableInactivityCheckJob = true
|
|
|
|
f.UseCaseOnboarding = true
|
|
|
|
f.GraphQL = false
|
2022-06-11 14:07:42 -07:00
|
|
|
f.InsightsEnabled = false
|
|
|
|
f.CommandPalette = false
|
2021-10-16 14:11:32 -07:00
|
|
|
}
|
|
|
|
func (f *FeatureFlags) Plugins() map[string]string {
|
|
|
|
rFFVal := reflect.ValueOf(f).Elem()
|
|
|
|
rFFType := reflect.TypeOf(f).Elem()
|
|
|
|
|
|
|
|
pluginVersions := make(map[string]string)
|
|
|
|
for i := 0; i < rFFVal.NumField(); i++ {
|
|
|
|
rFieldVal := rFFVal.Field(i)
|
|
|
|
rFieldType := rFFType.Field(i)
|
|
|
|
|
|
|
|
pluginId, hasPluginId := rFieldType.Tag.Lookup("plugin_id")
|
|
|
|
if !hasPluginId {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
|
|
|
pluginVersions[pluginId] = rFieldVal.String()
|
|
|
|
}
|
|
|
|
|
|
|
|
return pluginVersions
|
|
|
|
}
|
|
|
|
|
|
|
|
// ToMap returns the feature flags as a map[string]string
|
|
|
|
// Supports boolean and string feature flags.
|
|
|
|
func (f *FeatureFlags) ToMap() map[string]string {
|
|
|
|
refStructVal := reflect.ValueOf(*f)
|
|
|
|
refStructType := reflect.TypeOf(*f)
|
|
|
|
ret := make(map[string]string)
|
|
|
|
for i := 0; i < refStructVal.NumField(); i++ {
|
|
|
|
refFieldVal := refStructVal.Field(i)
|
|
|
|
if !refFieldVal.IsValid() {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
refFieldType := refStructType.Field(i)
|
|
|
|
switch refFieldType.Type.Kind() {
|
|
|
|
case reflect.Bool:
|
|
|
|
ret[refFieldType.Name] = strconv.FormatBool(refFieldVal.Bool())
|
|
|
|
default:
|
|
|
|
ret[refFieldType.Name] = refFieldVal.String()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret
|
|
|
|
}
|