Skip to content

Commit

Permalink
[Discover] Fix theme for Alerts popover (elastic#145390)
Browse files Browse the repository at this point in the history
Closes elastic#143070

## Summary

This PR adds theme provider to the Alerts popover.

Dark theme:
<img width="534" alt="Screenshot 2022-11-16 at 16 37 49"
src="https://user-images.githubusercontent.com/1415710/202226249-a46f6608-4f35-40ce-bfbf-847e9a7ba81a.png">

Light theme:
<img width="531" alt="Screenshot 2022-11-16 at 16 38 17"
src="https://user-images.githubusercontent.com/1415710/202226260-9e67a8dd-f6a4-40ff-ae28-2691b9a082bf.png">

Co-authored-by: Matthias Wilhelm <[email protected]>
  • Loading branch information
jughosta and kertal authored Nov 17, 2022
1 parent 2f68c14 commit e33392b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -177,6 +178,7 @@ function closeAlertsPopover() {

export function openAlertsPopover({
I18nContext,
theme$,
anchorElement,
searchSource,
services,
Expand All @@ -185,6 +187,7 @@ export function openAlertsPopover({
updateDataViewList,
}: {
I18nContext: I18nStart['Context'];
theme$: Observable<CoreTheme>;
anchorElement: HTMLElement;
searchSource: ISearchSource;
services: DiscoverServices;
Expand All @@ -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>
);
Expand Down

0 comments on commit e33392b

Please sign in to comment.