Adds ConnectedWorkspacesSettings configuration block (#27820)

* Adds ServerFederationSettings configuration block

The Server Federation related configuration properties were located in
the `ExperimentalSettings` config block. Now that the feature is going
to get out of beta, and foreseeing more configuration properties being
added to it, we're moving them to a block of its own.

If the properties were set in the old location, their values should be
carried over to the new ones. The old properties are left in place and
marked as deprecated not to cause issues with the model.

* Update System Console to include Server Federation section

* Remove system console section

* Move the configuration properties to ConnectedWorkspaces

* Add ConnectedWorkspacesSettings to the telemetry

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
Этот коммит содержится в:
Miguel de la Cruz
2024-09-10 22:33:00 +02:00
коммит произвёл GitHub
родитель 0c585bdac6
Коммит d5e9aa9fb3
15 изменённых файлов: 171 добавлений и 123 удалений

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

@@ -212,7 +212,7 @@ func setupTestHelper(dbStore store.Store, searchEngine *searchengine.Broker, ent
} }
func getLicense(enterprise bool, cfg *model.Config) *model.License { func getLicense(enterprise bool, cfg *model.Config) *model.License {
if *cfg.ExperimentalSettings.EnableRemoteClusterService || *cfg.ExperimentalSettings.EnableSharedChannels { if *cfg.ConnectedWorkspacesSettings.EnableRemoteClusterService || *cfg.ConnectedWorkspacesSettings.EnableSharedChannels {
return model.NewTestLicenseSKU(model.LicenseShortSkuProfessional) return model.NewTestLicenseSKU(model.LicenseShortSkuProfessional)
} }
if enterprise { if enterprise {

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

@@ -24,8 +24,8 @@ var (
func setupForSharedChannels(tb testing.TB) *TestHelper { func setupForSharedChannels(tb testing.TB) *TestHelper {
th := SetupConfig(tb, func(cfg *model.Config) { th := SetupConfig(tb, func(cfg *model.Config) {
*cfg.ExperimentalSettings.EnableRemoteClusterService = true *cfg.ConnectedWorkspacesSettings.EnableRemoteClusterService = true
*cfg.ExperimentalSettings.EnableSharedChannels = true *cfg.ConnectedWorkspacesSettings.EnableSharedChannels = true
}) })
th.App.UpdateConfig(func(cfg *model.Config) { th.App.UpdateConfig(func(cfg *model.Config) {

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

@@ -145,7 +145,7 @@ func setupTestHelper(dbStore store.Store, enterprise bool, includeCacheLayer boo
} }
func getLicense(enterprise bool, cfg *model.Config) *model.License { func getLicense(enterprise bool, cfg *model.Config) *model.License {
if *cfg.ExperimentalSettings.EnableRemoteClusterService || *cfg.ExperimentalSettings.EnableSharedChannels { if *cfg.ConnectedWorkspacesSettings.EnableRemoteClusterService || *cfg.ConnectedWorkspacesSettings.EnableSharedChannels {
return model.NewTestLicenseSKU(model.LicenseShortSkuProfessional) return model.NewTestLicenseSKU(model.LicenseShortSkuProfessional)
} }
if enterprise { if enterprise {

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

@@ -15,7 +15,7 @@ import (
func setupRemoteCluster(tb testing.TB) *TestHelper { func setupRemoteCluster(tb testing.TB) *TestHelper {
return SetupConfig(tb, func(cfg *model.Config) { return SetupConfig(tb, func(cfg *model.Config) {
*cfg.ExperimentalSettings.EnableRemoteClusterService = true *cfg.ConnectedWorkspacesSettings.EnableRemoteClusterService = true
}) })
} }

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

@@ -589,7 +589,7 @@ func (s *Server) startInterClusterServices(license *model.License) error {
} }
// Config check // Config check
if !*s.platform.Config().ExperimentalSettings.EnableRemoteClusterService && !*s.platform.Config().ExperimentalSettings.EnableSharedChannels { if !*s.platform.Config().ConnectedWorkspacesSettings.EnableRemoteClusterService && !*s.platform.Config().ConnectedWorkspacesSettings.EnableSharedChannels {
mlog.Debug("Remote Cluster Service disabled via config") mlog.Debug("Remote Cluster Service disabled via config")
return nil return nil
} }
@@ -618,7 +618,7 @@ func (s *Server) startInterClusterServices(license *model.License) error {
} }
// Config check // Config check
if !*s.platform.Config().ExperimentalSettings.EnableSharedChannels { if !*s.platform.Config().ConnectedWorkspacesSettings.EnableSharedChannels {
mlog.Debug("Shared Channels Service disabled via config") mlog.Debug("Shared Channels Service disabled via config")
return nil return nil
} }

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

@@ -14,8 +14,8 @@ import (
func setupSharedChannels(tb testing.TB) *TestHelper { func setupSharedChannels(tb testing.TB) *TestHelper {
return SetupConfig(tb, func(cfg *model.Config) { return SetupConfig(tb, func(cfg *model.Config) {
*cfg.ExperimentalSettings.EnableRemoteClusterService = true *cfg.ConnectedWorkspacesSettings.EnableRemoteClusterService = true
*cfg.ExperimentalSettings.EnableSharedChannels = true *cfg.ConnectedWorkspacesSettings.EnableSharedChannels = true
}) })
} }

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

@@ -20,8 +20,8 @@ import (
func setupForSharedChannels(tb testing.TB) *TestHelper { func setupForSharedChannels(tb testing.TB) *TestHelper {
return setupConfig(tb, func(cfg *model.Config) { return setupConfig(tb, func(cfg *model.Config) {
*cfg.ExperimentalSettings.EnableRemoteClusterService = true *cfg.ConnectedWorkspacesSettings.EnableRemoteClusterService = true
*cfg.ExperimentalSettings.EnableSharedChannels = true *cfg.ConnectedWorkspacesSettings.EnableSharedChannels = true
}) })
} }

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

@@ -138,7 +138,7 @@ func setupTestHelper(dbStore store.Store, enterprise bool, includeCacheLayer boo
} }
func getLicense(enterprise bool, cfg *model.Config) *model.License { func getLicense(enterprise bool, cfg *model.Config) *model.License {
if *cfg.ExperimentalSettings.EnableRemoteClusterService || *cfg.ExperimentalSettings.EnableSharedChannels { if *cfg.ConnectedWorkspacesSettings.EnableRemoteClusterService || *cfg.ConnectedWorkspacesSettings.EnableSharedChannels {
return model.NewTestLicenseSKU(model.LicenseShortSkuProfessional) return model.NewTestLicenseSKU(model.LicenseShortSkuProfessional)
} }
if enterprise { if enterprise {

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

@@ -215,8 +215,8 @@ func GenerateClientConfig(c *model.Config, telemetryID string, license *model.Li
} }
if license.HasSharedChannels() { if license.HasSharedChannels() {
props["ExperimentalSharedChannels"] = strconv.FormatBool(*c.ExperimentalSettings.EnableSharedChannels) props["ExperimentalSharedChannels"] = strconv.FormatBool(*c.ConnectedWorkspacesSettings.EnableSharedChannels)
props["ExperimentalRemoteClusterService"] = strconv.FormatBool(c.FeatureFlags.EnableRemoteClusterService && *c.ExperimentalSettings.EnableRemoteClusterService) props["ExperimentalRemoteClusterService"] = strconv.FormatBool(c.FeatureFlags.EnableRemoteClusterService && *c.ConnectedWorkspacesSettings.EnableRemoteClusterService)
} }
if license.SkuShortName == model.LicenseShortSkuProfessional || license.SkuShortName == model.LicenseShortSkuEnterprise { if license.SkuShortName == model.LicenseShortSkuProfessional || license.SkuShortName == model.LicenseShortSkuEnterprise {

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

@@ -189,7 +189,7 @@ func TestGetClientConfig(t *testing.T) {
{ {
"Shared channels other license", "Shared channels other license",
&model.Config{ &model.Config{
ExperimentalSettings: model.ExperimentalSettings{ ConnectedWorkspacesSettings: model.ConnectedWorkspacesSettings{
EnableSharedChannels: model.NewPointer(true), EnableSharedChannels: model.NewPointer(true),
}, },
}, },
@@ -207,7 +207,7 @@ func TestGetClientConfig(t *testing.T) {
{ {
"licensed for shared channels", "licensed for shared channels",
&model.Config{ &model.Config{
ExperimentalSettings: model.ExperimentalSettings{ ConnectedWorkspacesSettings: model.ConnectedWorkspacesSettings{
EnableSharedChannels: model.NewPointer(true), EnableSharedChannels: model.NewPointer(true),
}, },
}, },
@@ -225,7 +225,7 @@ func TestGetClientConfig(t *testing.T) {
{ {
"Shared channels professional license", "Shared channels professional license",
&model.Config{ &model.Config{
ExperimentalSettings: model.ExperimentalSettings{ ConnectedWorkspacesSettings: model.ConnectedWorkspacesSettings{
EnableSharedChannels: model.NewPointer(true), EnableSharedChannels: model.NewPointer(true),
}, },
}, },
@@ -256,7 +256,7 @@ func TestGetClientConfig(t *testing.T) {
{ {
"Shared channels enterprise license", "Shared channels enterprise license",
&model.Config{ &model.Config{
ExperimentalSettings: model.ExperimentalSettings{ ConnectedWorkspacesSettings: model.ConnectedWorkspacesSettings{
EnableSharedChannels: model.NewPointer(true), EnableSharedChannels: model.NewPointer(true),
}, },
}, },

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

@@ -77,6 +77,7 @@ const (
TrackConfigBleve = "config_bleve" TrackConfigBleve = "config_bleve"
TrackConfigExport = "config_export" TrackConfigExport = "config_export"
TrackConfigWrangler = "config_wrangler" TrackConfigWrangler = "config_wrangler"
TrackConfigConnectedWorkspaces = "config_connected_workspaces"
TrackFeatureFlags = "config_feature_flags" TrackFeatureFlags = "config_feature_flags"
TrackPermissionsGeneral = "permissions_general" TrackPermissionsGeneral = "permissions_general"
TrackPermissionsSystemScheme = "permissions_system_scheme" TrackPermissionsSystemScheme = "permissions_system_scheme"
@@ -773,8 +774,6 @@ func (ts *TelemetryService) trackConfig() {
"isdefault_client_side_cert_check": isDefault(*cfg.ExperimentalSettings.ClientSideCertCheck, model.ClientSideCertCheckPrimaryAuth), "isdefault_client_side_cert_check": isDefault(*cfg.ExperimentalSettings.ClientSideCertCheck, model.ClientSideCertCheckPrimaryAuth),
"link_metadata_timeout_milliseconds": *cfg.ExperimentalSettings.LinkMetadataTimeoutMilliseconds, "link_metadata_timeout_milliseconds": *cfg.ExperimentalSettings.LinkMetadataTimeoutMilliseconds,
"restrict_system_admin": *cfg.ExperimentalSettings.RestrictSystemAdmin, "restrict_system_admin": *cfg.ExperimentalSettings.RestrictSystemAdmin,
"enable_shared_channels": *cfg.ExperimentalSettings.EnableSharedChannels,
"enable_remote_cluster_service": *cfg.ExperimentalSettings.EnableRemoteClusterService && cfg.FeatureFlags.EnableRemoteClusterService,
"enable_app_bar": !*cfg.ExperimentalSettings.DisableAppBar, "enable_app_bar": !*cfg.ExperimentalSettings.DisableAppBar,
"disable_refetching_on_browser_focus": *cfg.ExperimentalSettings.DisableRefetchingOnBrowserFocus, "disable_refetching_on_browser_focus": *cfg.ExperimentalSettings.DisableRefetchingOnBrowserFocus,
"delay_channel_autocomplete": *cfg.ExperimentalSettings.DelayChannelAutocomplete, "delay_channel_autocomplete": *cfg.ExperimentalSettings.DelayChannelAutocomplete,
@@ -891,6 +890,11 @@ func (ts *TelemetryService) trackConfig() {
"move_thread_from_group_message_channel_enable": cfg.WranglerSettings.MoveThreadFromGroupMessageChannelEnable, "move_thread_from_group_message_channel_enable": cfg.WranglerSettings.MoveThreadFromGroupMessageChannelEnable,
}) })
ts.SendTelemetry(TrackConfigConnectedWorkspaces, map[string]any{
"enable_shared_channels": *cfg.ConnectedWorkspacesSettings.EnableSharedChannels,
"enable_remote_cluster_service": *cfg.ConnectedWorkspacesSettings.EnableRemoteClusterService && cfg.FeatureFlags.EnableRemoteClusterService,
})
// Convert feature flags to map[string]any for sending // Convert feature flags to map[string]any for sending
flags := cfg.FeatureFlags.ToMap() flags := cfg.FeatureFlags.ToMap()
interfaceFlags := make(map[string]any) interfaceFlags := make(map[string]any)

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

@@ -1068,8 +1068,8 @@ type ExperimentalSettings struct {
ClientSideCertCheck *string `access:"experimental_features,cloud_restrictable"` ClientSideCertCheck *string `access:"experimental_features,cloud_restrictable"`
LinkMetadataTimeoutMilliseconds *int64 `access:"experimental_features,write_restrictable,cloud_restrictable"` LinkMetadataTimeoutMilliseconds *int64 `access:"experimental_features,write_restrictable,cloud_restrictable"`
RestrictSystemAdmin *bool `access:"experimental_features,write_restrictable"` RestrictSystemAdmin *bool `access:"experimental_features,write_restrictable"`
EnableSharedChannels *bool `access:"experimental_features"` EnableSharedChannels *bool `access:"experimental_features"` // Deprecated: use `ConnectedWorkspacesSettings.EnableSharedChannels`
EnableRemoteClusterService *bool `access:"experimental_features"` EnableRemoteClusterService *bool `access:"experimental_features"` // Deprecated: use `ConnectedWorkspacesSettings.EnableRemoteClusterService`
DisableAppBar *bool `access:"experimental_features"` DisableAppBar *bool `access:"experimental_features"`
DisableRefetchingOnBrowserFocus *bool `access:"experimental_features"` DisableRefetchingOnBrowserFocus *bool `access:"experimental_features"`
DelayChannelAutocomplete *bool `access:"experimental_features"` DelayChannelAutocomplete *bool `access:"experimental_features"`
@@ -3242,6 +3242,29 @@ func (w *WranglerSettings) IsValid() *AppError {
return nil return nil
} }
type ConnectedWorkspacesSettings struct {
EnableSharedChannels *bool
EnableRemoteClusterService *bool
}
func (c *ConnectedWorkspacesSettings) SetDefaults(isUpdate bool, e ExperimentalSettings) {
if c.EnableSharedChannels == nil {
if isUpdate && e.EnableSharedChannels != nil {
c.EnableSharedChannels = e.EnableSharedChannels
} else {
c.EnableSharedChannels = NewPointer(false)
}
}
if c.EnableRemoteClusterService == nil {
if isUpdate && e.EnableRemoteClusterService != nil {
c.EnableRemoteClusterService = e.EnableRemoteClusterService
} else {
c.EnableRemoteClusterService = NewPointer(false)
}
}
}
type GlobalRelayMessageExportSettings struct { type GlobalRelayMessageExportSettings struct {
CustomerType *string `access:"compliance_compliance_export"` // must be either A9, A10 or CUSTOM, dictates SMTP server url CustomerType *string `access:"compliance_compliance_export"` // must be either A9, A10 or CUSTOM, dictates SMTP server url
SMTPUsername *string `access:"compliance_compliance_export"` SMTPUsername *string `access:"compliance_compliance_export"`
@@ -3540,6 +3563,7 @@ type Config struct {
ImportSettings ImportSettings // telemetry: none ImportSettings ImportSettings // telemetry: none
ExportSettings ExportSettings ExportSettings ExportSettings
WranglerSettings WranglerSettings WranglerSettings WranglerSettings
ConnectedWorkspacesSettings ConnectedWorkspacesSettings
} }
func (o *Config) Auditable() map[string]interface{} { func (o *Config) Auditable() map[string]interface{} {
@@ -3656,6 +3680,7 @@ func (o *Config) SetDefaults() {
o.ImportSettings.SetDefaults() o.ImportSettings.SetDefaults()
o.ExportSettings.SetDefaults() o.ExportSettings.SetDefaults()
o.WranglerSettings.SetDefaults() o.WranglerSettings.SetDefaults()
o.ConnectedWorkspacesSettings.SetDefaults(isUpdate, o.ExperimentalSettings)
} }
func (o *Config) IsValid() *AppError { func (o *Config) IsValid() *AppError {

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

@@ -1761,3 +1761,37 @@ func TestConfigGetFileRetentionHours(t *testing.T) {
}) })
} }
} }
func TestConfigDefaultConnectedWorkspacesSettings(t *testing.T) {
t.Run("if the config is new, default values should be established", func(t *testing.T) {
c := Config{}
c.SetDefaults()
require.False(t, *c.ConnectedWorkspacesSettings.EnableSharedChannels)
require.False(t, *c.ConnectedWorkspacesSettings.EnableRemoteClusterService)
})
t.Run("if the config is being updated and server federation settings had no values, experimental settings values should be migrated", func(t *testing.T) {
c := Config{}
c.SetDefaults()
c.ConnectedWorkspacesSettings = ConnectedWorkspacesSettings{}
c.ExperimentalSettings.EnableSharedChannels = NewPointer(true)
c.ExperimentalSettings.EnableRemoteClusterService = NewPointer(false)
c.SetDefaults()
require.True(t, *c.ConnectedWorkspacesSettings.EnableSharedChannels)
require.False(t, *c.ConnectedWorkspacesSettings.EnableRemoteClusterService)
})
t.Run("if the config is being updated and server federation settings already have values, they should not change", func(t *testing.T) {
c := Config{}
c.SetDefaults()
c.ConnectedWorkspacesSettings.EnableSharedChannels = NewPointer(false)
c.ConnectedWorkspacesSettings.EnableRemoteClusterService = NewPointer(true)
c.ExperimentalSettings.EnableSharedChannels = NewPointer(true)
c.ExperimentalSettings.EnableRemoteClusterService = NewPointer(false)
c.SetDefaults()
require.False(t, *c.ConnectedWorkspacesSettings.EnableSharedChannels)
require.True(t, *c.ConnectedWorkspacesSettings.EnableRemoteClusterService)
})
}

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

@@ -6213,19 +6213,6 @@ const AdminDefinition: AdminDefinitionType = {
placeholder: defineMessage({id: 'admin.experimental.userStatusAwayTimeout.example', defaultMessage: 'E.g.: "300"'}), placeholder: defineMessage({id: 'admin.experimental.userStatusAwayTimeout.example', defaultMessage: 'E.g.: "300"'}),
isDisabled: it.not(it.userHasWritePermissionOnResource(RESOURCE_KEYS.EXPERIMENTAL.FEATURES)), isDisabled: it.not(it.userHasWritePermissionOnResource(RESOURCE_KEYS.EXPERIMENTAL.FEATURES)),
}, },
{
type: 'bool',
key: 'ExperimentalSettings.EnableSharedChannels',
label: defineMessage({id: 'admin.experimental.enableSharedChannels.title', defaultMessage: 'Enable Shared Channels:'}),
help_text: defineMessage({id: 'admin.experimental.enableSharedChannels.desc', defaultMessage: 'Toggles Shared Channels'}),
help_text_markdown: false,
isHidden: it.not(it.any(
it.licensedForFeature('SharedChannels'),
it.licensedForSku(LicenseSkus.Enterprise),
it.licensedForSku(LicenseSkus.Professional),
)),
isDisabled: it.not(it.userHasWritePermissionOnResource(RESOURCE_KEYS.EXPERIMENTAL.FEATURES)),
},
{ {
type: 'bool', type: 'bool',
key: 'ExperimentalSettings.DisableAppBar', key: 'ExperimentalSettings.DisableAppBar',

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

@@ -931,8 +931,6 @@
"admin.experimental.enableChannelViewedMessages.title": "Enable Channel Viewed WebSocket Messages:", "admin.experimental.enableChannelViewedMessages.title": "Enable Channel Viewed WebSocket Messages:",
"admin.experimental.enableOnboardingFlow.desc": "When true, new users are shown steps to complete as part of an onboarding process", "admin.experimental.enableOnboardingFlow.desc": "When true, new users are shown steps to complete as part of an onboarding process",
"admin.experimental.enableOnboardingFlow.title": "Enable Onboarding:", "admin.experimental.enableOnboardingFlow.title": "Enable Onboarding:",
"admin.experimental.enableSharedChannels.desc": "When true, users who have permission to manage shared channels can configure another Mattermost server to synchronize and share a channel. Disabling shared channels stops synchronizing the channel with the other Mattermost server, however the channel continues to function for local users per normal channel behavior.",
"admin.experimental.enableSharedChannels.title": "Enable Shared Channels:",
"admin.experimental.enableThemeSelection.desc": "Enables the **Display > Theme** tab in Settings so users can select their theme.", "admin.experimental.enableThemeSelection.desc": "Enables the **Display > Theme** tab in Settings so users can select their theme.",
"admin.experimental.enableThemeSelection.title": "Enable Theme Selection:", "admin.experimental.enableThemeSelection.title": "Enable Theme Selection:",
"admin.experimental.enableTutorial.desc": "When true, users are prompted with a tutorial when they open Mattermost for the first time after account creation. When false, the tutorial is disabled, and users are placed in Town Square when they open Mattermost for the first time after account creation.", "admin.experimental.enableTutorial.desc": "When true, users are prompted with a tutorial when they open Mattermost for the first time after account creation. When false, the tutorial is disabled, and users are placed in Town Square when they open Mattermost for the first time after account creation.",