Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hides unknown uiSettings from the advanced settings page #128030

Merged
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,35 @@ describe('AdvancedSettings', () => {
).toHaveLength(1);
});

it('should should not render a custom setting', async () => {
// The manual mock for the uiSettings client 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(
<AdvancedSettings
history={mockHistory}
enableSaving={true}
toasts={notificationServiceMock.createStartContract().toasts}
docLinks={docLinksServiceMock.createStartContract().links}
uiSettings={uiSettings}
componentRegistry={new ComponentRegistry().start}
theme={themeServiceMock.createStartContract().theme$}
/>
);

expect(
component
.find('Field')
.filterWhere(
(n: ReactWrapper) =>
(n.prop('setting') as Record<string, any>).name === customSettingQuery
)
).toEqual({});
});

it('should render read-only when saving is disabled', async () => {
mockQuery();
const component = mountWithI18nProvider(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ export class AdvancedSettings extends Component<AdvancedSettingsProps, AdvancedS
});
})
.filter((c) => !c.readOnly)
.filter((c) => !c.isCustom) // hide any settings that aren't explicitly registered by enabled plugins.
Copy link
Contributor Author

@TinaHeiligers TinaHeiligers Mar 18, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already have a flag that we can use to filter out any settings that aren't explicitly registered during Kibana setup and start lifecycles and don't need to necessarily add another one.

.sort(fieldSorter);
}

Expand Down