From 22275fa0f5d4e82cdb5132bd68bfbcf5e19fa87c Mon Sep 17 00:00:00 2001 From: Scott Bishel Date: Mon, 5 Jun 2023 15:18:20 -0600 Subject: [PATCH] MM-52818 - create config setting to enable/disable playbooks product (#23508) * create config setting to enable/disable playbooks product * fix to config name * fix typo * revert changes to package-lock.json * update name of test --------- Co-authored-by: Mattermost Build --- .../playwright/support/server/default_config.ts | 1 + server/channels/app/product.go | 4 ++++ server/config/client.go | 2 ++ server/config/client_test.go | 14 ++++++++++++++ server/public/model/config.go | 4 ++++ webapp/channels/src/plugins/products.ts | 9 ++++++--- webapp/platform/types/src/config.ts | 2 ++ 7 files changed, 33 insertions(+), 3 deletions(-) diff --git a/e2e-tests/playwright/support/server/default_config.ts b/e2e-tests/playwright/support/server/default_config.ts index 71a0388763..30760840f6 100644 --- a/e2e-tests/playwright/support/server/default_config.ts +++ b/e2e-tests/playwright/support/server/default_config.ts @@ -607,6 +607,7 @@ const defaultServerConfig: AdminConfig = { }, ProductSettings: { EnablePublicSharedBoards: false, + EnablePlaybooks: true, }, PluginSettings: { Enable: true, diff --git a/server/channels/app/product.go b/server/channels/app/product.go index 7183e38d3a..4d594e4e90 100644 --- a/server/channels/app/product.go +++ b/server/channels/app/product.go @@ -88,6 +88,10 @@ func (s *Server) shouldStart(product string) bool { s.Log().Warn("Skipping Playbooks start: disabled via env var") return false } + if !*s.Config().ProductSettings.EnablePlaybooks { + s.Log().Warn("Skipping Playbooks start: disabled via configuration") + return false + } } return true diff --git a/server/config/client.go b/server/config/client.go index 8670c22e1f..b97e9a87bb 100644 --- a/server/config/client.go +++ b/server/config/client.go @@ -144,6 +144,8 @@ func GenerateClientConfig(c *model.Config, telemetryID string, license *model.Li props["AllowSyncedDrafts"] = strconv.FormatBool(*c.ServiceSettings.AllowSyncedDrafts) props["DelayChannelAutocomplete"] = strconv.FormatBool(*c.ExperimentalSettings.DelayChannelAutocomplete) + props["EnablePlaybooks"] = strconv.FormatBool(*c.ProductSettings.EnablePlaybooks) + if license != nil { props["ExperimentalEnableAuthenticationTransfer"] = strconv.FormatBool(*c.ServiceSettings.ExperimentalEnableAuthenticationTransfer) diff --git a/server/config/client_test.go b/server/config/client_test.go index 465396ecb4..8d0fb679b0 100644 --- a/server/config/client_test.go +++ b/server/config/client_test.go @@ -326,6 +326,20 @@ func TestGetClientConfig(t *testing.T) { "ExperimentalSharedChannels": "true", }, }, + { + "Default Playbooks Enabled", + &model.Config{ + ProductSettings: model.ProductSettings{}, + }, + "", + &model.License{ + Features: &model.Features{}, + SkuShortName: "other", + }, + map[string]string{ + "EnablePlaybooks": "true", + }, + }, } for _, testCase := range testCases { diff --git a/server/public/model/config.go b/server/public/model/config.go index 6609c593b6..25cfae32b3 100644 --- a/server/public/model/config.go +++ b/server/public/model/config.go @@ -2879,6 +2879,7 @@ func (s *CloudSettings) SetDefaults() { type ProductSettings struct { EnablePublicSharedBoards *bool + EnablePlaybooks *bool } func (s *ProductSettings) SetDefaults(plugins map[string]map[string]any) { @@ -2889,6 +2890,9 @@ func (s *ProductSettings) SetDefaults(plugins map[string]map[string]any) { s.EnablePublicSharedBoards = NewBool(false) } } + if s.EnablePlaybooks == nil { + s.EnablePlaybooks = NewBool(true) + } } type PluginState struct { diff --git a/webapp/channels/src/plugins/products.ts b/webapp/channels/src/plugins/products.ts index 824538f060..fda0d51155 100644 --- a/webapp/channels/src/plugins/products.ts +++ b/webapp/channels/src/plugins/products.ts @@ -37,8 +37,8 @@ function configureClient() { function loadRemoteModules() { /* eslint-disable no-console */ - return async (/*dispatch: DispatchFunc, getState: GetStateFunc*/) => { - // const config = getConfig(getState()); + return async (dispatch: DispatchFunc, getState: GetStateFunc) => { + const config = getConfig(getState()); /** * products contains a map of product IDs to a function that will load all of their parts. Calling that @@ -47,7 +47,7 @@ function loadRemoteModules() { * Note that these import paths must be statically defined or else they won't be found at runtime. They * can't be constructed based on the name of a product at runtime. */ - const products = [ + let products = [ { id: 'boards', load: () => ({ @@ -65,6 +65,9 @@ function loadRemoteModules() { }), }, ]; + if (config.EnablePlaybooks !== 'true') { + products = products.filter((p) => p.id !== 'playbooks'); + } await Promise.all(products.map(async (product) => { if (!REMOTE_CONTAINERS[product.id]) { diff --git a/webapp/platform/types/src/config.ts b/webapp/platform/types/src/config.ts index 1b99ffd9ae..6a2f3ac48a 100644 --- a/webapp/platform/types/src/config.ts +++ b/webapp/platform/types/src/config.ts @@ -82,6 +82,7 @@ export type ClientConfig = { EnableOAuthServiceProvider: string; EnableOpenServer: string; EnableOutgoingWebhooks: string; + EnablePlaybooks: string; EnablePostIconOverride: string; EnablePostUsernameOverride: string; EnablePreviewFeatures: string; @@ -818,6 +819,7 @@ export type JobSettings = { export type ProductSettings = { EnablePublicSharedBoards: boolean; + EnablePlaybooks: boolean; }; export type PluginSettings = {