[8.6] [Discover] Fix theme for Alerts popover (#145390) (#145631)

# Backport

This will backport the following commits from `main` to `8.6`:
- [[Discover] Fix theme for Alerts popover
(#145390)](https://github.com/elastic/kibana/pull/145390)

<!--- Backport version: 8.9.7 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Julia
Rechkunova","email":"julia.rechkunova@elastic.co"},"sourceCommit":{"committedDate":"2022-11-17T21:32:39Z","message":"[Discover]
Fix theme for Alerts popover (#145390)\n\nCloses
https://github.com/elastic/kibana/issues/143070\r\n\r\n##
Summary\r\n\r\nThis PR adds theme provider to the Alerts
popover.\r\n\r\nDark theme:\r\n<img width=\"534\" alt=\"Screenshot
2022-11-16 at 16 37
49\"\r\nsrc=\"https://user-images.githubusercontent.com/1415710/202226249-a46f6608-4f35-40ce-bfbf-847e9a7ba81a.png\">\r\n\r\nLight
theme:\r\n<img width=\"531\" alt=\"Screenshot 2022-11-16 at 16 38
17\"\r\nsrc=\"https://user-images.githubusercontent.com/1415710/202226260-9e67a8dd-f6a4-40ff-ae28-2691b9a082bf.png\">\r\n\r\nCo-authored-by:
Matthias Wilhelm
<ankertal@gmail.com>","sha":"e33392bff0a022bb246f8d560a336ebdac0555f9","branchLabelMapping":{"^v8.7.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","Team:DataDiscovery","backport:prev-minor","v8.7.0"],"number":145390,"url":"https://github.com/elastic/kibana/pull/145390","mergeCommit":{"message":"[Discover]
Fix theme for Alerts popover (#145390)\n\nCloses
https://github.com/elastic/kibana/issues/143070\r\n\r\n##
Summary\r\n\r\nThis PR adds theme provider to the Alerts
popover.\r\n\r\nDark theme:\r\n<img width=\"534\" alt=\"Screenshot
2022-11-16 at 16 37
49\"\r\nsrc=\"https://user-images.githubusercontent.com/1415710/202226249-a46f6608-4f35-40ce-bfbf-847e9a7ba81a.png\">\r\n\r\nLight
theme:\r\n<img width=\"531\" alt=\"Screenshot 2022-11-16 at 16 38
17\"\r\nsrc=\"https://user-images.githubusercontent.com/1415710/202226260-9e67a8dd-f6a4-40ff-ae28-2691b9a082bf.png\">\r\n\r\nCo-authored-by:
Matthias Wilhelm
<ankertal@gmail.com>","sha":"e33392bff0a022bb246f8d560a336ebdac0555f9"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v8.7.0","labelRegex":"^v8.7.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/145390","number":145390,"mergeCommit":{"message":"[Discover]
Fix theme for Alerts popover (#145390)\n\nCloses
https://github.com/elastic/kibana/issues/143070\r\n\r\n##
Summary\r\n\r\nThis PR adds theme provider to the Alerts
popover.\r\n\r\nDark theme:\r\n<img width=\"534\" alt=\"Screenshot
2022-11-16 at 16 37
49\"\r\nsrc=\"https://user-images.githubusercontent.com/1415710/202226249-a46f6608-4f35-40ce-bfbf-847e9a7ba81a.png\">\r\n\r\nLight
theme:\r\n<img width=\"531\" alt=\"Screenshot 2022-11-16 at 16 38
17\"\r\nsrc=\"https://user-images.githubusercontent.com/1415710/202226260-9e67a8dd-f6a4-40ff-ae28-2691b9a082bf.png\">\r\n\r\nCo-authored-by:
Matthias Wilhelm
<ankertal@gmail.com>","sha":"e33392bff0a022bb246f8d560a336ebdac0555f9"}}]}]
BACKPORT-->

Co-authored-by: Julia Rechkunova <julia.rechkunova@elastic.co>
This commit is contained in:
Kibana Machine 2022-11-17 17:34:39 -05:00 committed by GitHub
parent 953ece5454
commit 520e876557
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 12 deletions

View file

@ -81,6 +81,7 @@ export const getTopNavLinks = ({
run: async (anchorElement: HTMLElement) => {
openAlertsPopover({
I18nContext: services.core.i18n.Context,
theme$: services.core.theme.theme$,
anchorElement,
searchSource: savedSearch.searchSource,
services,

View file

@ -8,11 +8,12 @@
import React, { useCallback, useState, useMemo } from 'react';
import ReactDOM from 'react-dom';
import { I18nStart } from '@kbn/core/public';
import type { Observable } from 'rxjs';
import type { CoreTheme, I18nStart } from '@kbn/core/public';
import { EuiWrappingPopover, EuiContextMenu } from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n-react';
import type { DataView, ISearchSource } from '@kbn/data-plugin/common';
import { KibanaContextProvider } from '@kbn/kibana-react-plugin/public';
import { KibanaContextProvider, KibanaThemeProvider } from '@kbn/kibana-react-plugin/public';
import { DiscoverServices } from '../../../../build_services';
import { updateSearchSource } from '../../utils/update_search_source';
@ -177,6 +178,7 @@ function closeAlertsPopover() {
export function openAlertsPopover({
I18nContext,
theme$,
anchorElement,
searchSource,
services,
@ -185,6 +187,7 @@ export function openAlertsPopover({
updateDataViewList,
}: {
I18nContext: I18nStart['Context'];
theme$: Observable<CoreTheme>;
anchorElement: HTMLElement;
searchSource: ISearchSource;
services: DiscoverServices;
@ -203,16 +206,18 @@ export function openAlertsPopover({
const element = (
<I18nContext>
<KibanaContextProvider services={services}>
<AlertsPopover
onClose={closeAlertsPopover}
anchorElement={anchorElement}
searchSource={searchSource}
savedQueryId={savedQueryId}
adHocDataViews={adHocDataViews}
I18nContext={I18nContext}
services={services}
updateDataViewList={updateDataViewList}
/>
<KibanaThemeProvider theme$={theme$}>
<AlertsPopover
onClose={closeAlertsPopover}
anchorElement={anchorElement}
searchSource={searchSource}
savedQueryId={savedQueryId}
adHocDataViews={adHocDataViews}
I18nContext={I18nContext}
services={services}
updateDataViewList={updateDataViewList}
/>
</KibanaThemeProvider>
</KibanaContextProvider>
</I18nContext>
);