From 291ab9667f7a0fbf0d4e62ed1825fdd1112f8eb5 Mon Sep 17 00:00:00 2001 From: Christiane Heiligers Date: Thu, 17 Mar 2022 07:11:20 -0700 Subject: [PATCH 1/4] Hides unregistered uiSettings in the AS page --- .../public/management_app/advanced_settings.tsx | 1 + .../public/management_app/lib/to_editable_config.ts | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/advanced_settings/public/management_app/advanced_settings.tsx b/src/plugins/advanced_settings/public/management_app/advanced_settings.tsx index e0966d70aeb98..d7a028755fbf3 100644 --- a/src/plugins/advanced_settings/public/management_app/advanced_settings.tsx +++ b/src/plugins/advanced_settings/public/management_app/advanced_settings.tsx @@ -198,6 +198,7 @@ export class AdvancedSettings extends Component !c.readOnly) + .filter((c) => !c.isCustom) // hide any settings that aren't explicitly registered by enabled plugins. .sort(fieldSorter); } diff --git a/src/plugins/advanced_settings/public/management_app/lib/to_editable_config.ts b/src/plugins/advanced_settings/public/management_app/lib/to_editable_config.ts index d2ed64aa918a7..be980f5052daa 100644 --- a/src/plugins/advanced_settings/public/management_app/lib/to_editable_config.ts +++ b/src/plugins/advanced_settings/public/management_app/lib/to_editable_config.ts @@ -54,6 +54,5 @@ export function toEditableConfig({ requiresPageReload: !!def.requiresPageReload, metric: def.metric, }; - return conf; } From e4be4aa83c42402b2c33e8e2571c20d0ccdd9ec6 Mon Sep 17 00:00:00 2001 From: Christiane Heiligers Date: Fri, 18 Mar 2022 19:44:45 -0700 Subject: [PATCH 2/4] Adds unit test for filtering out custom settings --- .../management_app/advanced_settings.test.tsx | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/plugins/advanced_settings/public/management_app/advanced_settings.test.tsx b/src/plugins/advanced_settings/public/management_app/advanced_settings.test.tsx index 7b294c609f31e..7d55d64761cf1 100644 --- a/src/plugins/advanced_settings/public/management_app/advanced_settings.test.tsx +++ b/src/plugins/advanced_settings/public/management_app/advanced_settings.test.tsx @@ -268,6 +268,33 @@ describe('AdvancedSettings', () => { ).toHaveLength(1); }); + it('should should not render a custom setting', async () => { + // For various complicated reasons the mock returns false for isConfig, override that + const uiSettings = mockConfig().core.uiSettings; + uiSettings.isCustom = (key) => true; + + const customSettingQuery = 'test:customstring:setting'; + mockQuery(customSettingQuery); + const component = mountWithI18nProvider( + + ); + + const expected = component + .find('Field') + .filterWhere( + (n: ReactWrapper) => (n.prop('setting') as Record).name === customSettingQuery + ); + expect(component).toEqual({}); + }); + it('should render read-only when saving is disabled', async () => { mockQuery(); const component = mountWithI18nProvider( From 55a8fb9d123c8a725ebdff5b3c4085732d6afeff Mon Sep 17 00:00:00 2001 From: Christiane Heiligers Date: Fri, 18 Mar 2022 19:46:16 -0700 Subject: [PATCH 3/4] adds newline back to file --- .../public/management_app/lib/to_editable_config.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/plugins/advanced_settings/public/management_app/lib/to_editable_config.ts b/src/plugins/advanced_settings/public/management_app/lib/to_editable_config.ts index be980f5052daa..d2ed64aa918a7 100644 --- a/src/plugins/advanced_settings/public/management_app/lib/to_editable_config.ts +++ b/src/plugins/advanced_settings/public/management_app/lib/to_editable_config.ts @@ -54,5 +54,6 @@ export function toEditableConfig({ requiresPageReload: !!def.requiresPageReload, metric: def.metric, }; + return conf; } From a21220776dce9d80ec2cc4d44687121b99e5c0d5 Mon Sep 17 00:00:00 2001 From: Christiane Heiligers Date: Sat, 19 Mar 2022 07:38:12 -0700 Subject: [PATCH 4/4] Typescript fix --- .../management_app/advanced_settings.test.tsx | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/plugins/advanced_settings/public/management_app/advanced_settings.test.tsx b/src/plugins/advanced_settings/public/management_app/advanced_settings.test.tsx index 7d55d64761cf1..5ee1bbf49f56c 100644 --- a/src/plugins/advanced_settings/public/management_app/advanced_settings.test.tsx +++ b/src/plugins/advanced_settings/public/management_app/advanced_settings.test.tsx @@ -269,7 +269,7 @@ describe('AdvancedSettings', () => { }); it('should should not render a custom setting', async () => { - // For various complicated reasons the mock returns false for isConfig, override that + // The manual mock for the uiSettings client returns false for isConfig, override that const uiSettings = mockConfig().core.uiSettings; uiSettings.isCustom = (key) => true; @@ -287,12 +287,14 @@ describe('AdvancedSettings', () => { /> ); - const expected = component - .find('Field') - .filterWhere( - (n: ReactWrapper) => (n.prop('setting') as Record).name === customSettingQuery - ); - expect(component).toEqual({}); + expect( + component + .find('Field') + .filterWhere( + (n: ReactWrapper) => + (n.prop('setting') as Record).name === customSettingQuery + ) + ).toEqual({}); }); it('should render read-only when saving is disabled', async () => {