[Log Explorer] Hide Discover announcement callouts (#166835)

## 📓 Summary

Closes #166056 

This PR adds a new override to the `uiSetting` service, allowing it to
override specific UI preferences.
In this case, we'll overwrite the `hideAnnouncements` preference to be
true, so that discover-specific announcements won't be displayed for the
Log Explorer app.


50dade20-1902-4f4a-8615-3e1f7a964522

---------

Co-authored-by: Marco Antonio Ghiani <marcoantonio.ghiani@elastic.co>
Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
Marco Antonio Ghiani 2023-09-21 12:38:31 +02:00 committed by GitHub
parent 39aebd66be
commit b04b07ec52
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 27 additions and 2 deletions

View file

@ -8,9 +8,10 @@
import React, { useMemo } from 'react';
import { ScopedHistory } from '@kbn/core-application-browser';
import { DataPublicPluginStart } from '@kbn/data-plugin/public';
import { DiscoverStart } from '@kbn/discover-plugin/public';
import { DiscoverAppState, DiscoverStart } from '@kbn/discover-plugin/public';
import type { BehaviorSubject } from 'rxjs';
import { DiscoverAppState } from '@kbn/discover-plugin/public/application/main/services/discover_app_state_container';
import { IUiSettingsClient } from '@kbn/core-ui-settings-browser';
import { HIDE_ANNOUNCEMENTS } from '@kbn/discover-utils';
import {
createLogExplorerProfileCustomizations,
CreateLogExplorerProfileCustomizationsDeps,
@ -39,6 +40,7 @@ export const createLogExplorer = ({
}: CreateLogExplorerArgs) => {
const overrideServices = {
data: createDataServiceProxy(data),
uiSettings: createUiSettingsServiceProxy(core.uiSettings),
};
return ({ scopedHistory, state$ }: LogExplorerProps) => {
@ -76,3 +78,24 @@ const createDataServiceProxy = (data: DataPublicPluginStart) => {
search: () => searchServiceProxy,
});
};
/**
* Create proxy for the uiSettings service, in which settings preferences are overwritten
* with custom values
*/
const createUiSettingsServiceProxy = (uiSettings: IUiSettingsClient) => {
const overrides: Record<string, any> = {
[HIDE_ANNOUNCEMENTS]: true,
};
return createPropertyGetProxy(uiSettings, {
get:
() =>
(key, ...args) => {
if (key in overrides) {
return overrides[key];
}
return uiSettings.get(key, ...args);
},
});
};

View file

@ -22,6 +22,8 @@
"@kbn/core-application-browser",
"@kbn/share-plugin",
"@kbn/unified-data-table",
"@kbn/core-ui-settings-browser",
"@kbn/discover-utils",
"@kbn/deeplinks-observability"
],
"exclude": ["target/**/*"]