From e925b3cc84a72797cc9b87f9e63c84ae64cfff90 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Thu, 29 Dec 2022 21:42:39 +0000 Subject: [PATCH] Adds config override to fix obsolete theme:version config value of v8 (beta) rendering issue (#3045) Signed-off-by: Manasvini B Suryanarayana (cherry picked from commit 7789295328d4c2b4353f00ccf39cae204cee9f4e) Signed-off-by: github-actions[bot] # Conflicts: # CHANGELOG.md --- .../ui_settings/ui_settings_client.test.ts | 23 +++++++++++++++++++ .../server/ui_settings/ui_settings_config.ts | 7 +++++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/src/core/server/ui_settings/ui_settings_client.test.ts b/src/core/server/ui_settings/ui_settings_client.test.ts index 72461653d652..a7aa95ebab91 100644 --- a/src/core/server/ui_settings/ui_settings_client.test.ts +++ b/src/core/server/ui_settings/ui_settings_client.test.ts @@ -624,6 +624,29 @@ describe('ui settings', () => { expect(await uiSettings.get('dateFormat')).toBe('foo'); }); + it('returns the overridden value for key theme:version', async () => { + const opensearchDocSource = { 'theme:version': 'v8 (beta)' }; + const overrides = { 'theme:version': 'v7' }; + const { uiSettings } = setup({ opensearchDocSource, overrides }); + + expect(await uiSettings.get('theme:version')).toBe('v7'); + }); + + it('returns the overridden value for key theme:version when doc source is empty', async () => { + const opensearchDocSource = {}; + const overrides = { 'theme:version': 'v7' }; + const { uiSettings } = setup({ opensearchDocSource, overrides }); + + expect(await uiSettings.get('theme:version')).toBe('v7'); + }); + + it('rewrites the key theme:version value without override', async () => { + const opensearchDocSource = { 'theme:version': 'v8 (beta)' }; + const { uiSettings } = setup({ opensearchDocSource }); + + expect(await uiSettings.get('theme:version')).toBe('v8 (beta)'); + }); + it('returns the default value for an override with value null', async () => { const opensearchDocSource = { dateFormat: 'YYYY-MM-DD' }; const overrides = { dateFormat: null }; diff --git a/src/core/server/ui_settings/ui_settings_config.ts b/src/core/server/ui_settings/ui_settings_config.ts index 4c3dd0e4dcf5..634fb5c62d55 100644 --- a/src/core/server/ui_settings/ui_settings_config.ts +++ b/src/core/server/ui_settings/ui_settings_config.ts @@ -38,7 +38,12 @@ const deprecations: ConfigDeprecationProvider = ({ unused, renameFromRoot }) => ]; const configSchema = schema.object({ - overrides: schema.object({}, { unknowns: 'allow' }), + overrides: schema.object( + { + 'theme:version': schema.string({ defaultValue: 'v7' }), + }, + { unknowns: 'allow' } + ), }); export type UiSettingsConfigType = TypeOf;