Skip to content

Commit

Permalink
[Discover] Fix dark theme issues by removing deprecated components (e…
Browse files Browse the repository at this point in the history
…lastic#163387)

- Closes elastic#163332

## Summary

This PR fixes dark mode issues which surfaced after
elastic#161914 and
elastic#163103

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
  • Loading branch information
jughosta and kibanamachine authored Aug 11, 2023
1 parent 987a850 commit 74911b6
Show file tree
Hide file tree
Showing 25 changed files with 192 additions and 203 deletions.
2 changes: 1 addition & 1 deletion packages/kbn-optimizer/limits.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pageLoadAssetSize:
dashboard: 82025
dashboardEnhanced: 65646
data: 454087
dataViewEditor: 12000
dataViewEditor: 13000
dataViewFieldEditor: 27000
dataViewManagement: 5000
dataViews: 47000
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import React from 'react';
import { render, unmountComponentAtNode } from 'react-dom';
import { KibanaRenderContextProvider } from '@kbn/react-kibana-context-render';
import { createKibanaReactContext } from '@kbn/kibana-react-plugin/public';
import { AppDependencies } from '..';
import { SearchSessionsMgmtMain } from '../components/main';
Expand All @@ -20,18 +21,17 @@ export const renderApp = (
return () => undefined;
}

const { Context: I18nContext } = i18n;
// uiSettings is required by the listing table to format dates in the timezone from Settings
const { Provider: KibanaReactContextProvider } = createKibanaReactContext({
uiSettings,
});

render(
<I18nContext>
<KibanaRenderContextProvider theme={homeDeps.core.theme} i18n={i18n}>
<KibanaReactContextProvider>
<SearchSessionsMgmtMain {...homeDeps} timezone={uiSettings.get('dateFormat:tz')} />
</KibanaReactContextProvider>
</I18nContext>,
</KibanaRenderContextProvider>,
elem
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@
* Side Public License, v 1.
*/

import React from 'react';
import { EuiButtonEmpty, EuiPageHeader, EuiSpacer } from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n-react';
import type { CoreStart, HttpStart } from '@kbn/core/public';
import React from 'react';
import { KibanaThemeProvider } from '@kbn/kibana-react-plugin/public';
import type { SearchSessionsMgmtAPI } from '../lib/api';
import type { AsyncSearchIntroDocumentation } from '../lib/documentation';
import { SearchSessionsMgmtTable } from './table';
Expand All @@ -30,7 +29,7 @@ interface Props {

export function SearchSessionsMgmtMain({ documentation, ...tableProps }: Props) {
return (
<KibanaThemeProvider theme$={tableProps.core.theme.theme$}>
<>
<EuiPageHeader
pageTitle={
<FormattedMessage
Expand Down Expand Up @@ -61,6 +60,6 @@ export function SearchSessionsMgmtMain({ documentation, ...tableProps }: Props)

<EuiSpacer size="l" />
<SearchSessionsMgmtTable data-test-subj="search-sessions-mgmt-table" {...tableProps} />
</KibanaThemeProvider>
</>
);
}
3 changes: 2 additions & 1 deletion src/plugins/data/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@
"@kbn/core-application-browser",
"@kbn/core-saved-objects-server",
"@kbn/core-saved-objects-utils-server",
"@kbn/data-service"
"@kbn/data-service",
"@kbn/react-kibana-context-render"
],
"exclude": [
"target/**/*",
Expand Down
32 changes: 15 additions & 17 deletions src/plugins/data_view_editor/public/open_editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@

import React from 'react';
import { CoreStart, OverlayRef } from '@kbn/core/public';
import { I18nProvider } from '@kbn/i18n-react';
import type { DataViewsServicePublic } from '@kbn/data-views-plugin/public';
import type { DataView } from '@kbn/data-views-plugin/public';

import { createKibanaReactContext, toMountPoint, DataPublicPluginStart } from './shared_imports';
import { toMountPoint } from '@kbn/react-kibana-mount';
import { createKibanaReactContext, DataPublicPluginStart } from './shared_imports';

import { CloseEditor, DataViewEditorContext, DataViewEditorProps } from './types';
import { DataViewEditorLazy } from './components/data_view_editor_lazy';
Expand Down Expand Up @@ -67,22 +67,20 @@ export const getEditorOpener =
overlayRef = overlays.openFlyout(
toMountPoint(
<KibanaReactContextProvider>
<I18nProvider>
<DataViewEditorLazy
onSave={onSaveIndexPattern}
onCancel={() => {
closeEditor();
onCancel();
}}
editData={editData}
defaultTypeIsRollup={defaultTypeIsRollup}
requireTimestampField={requireTimestampField}
allowAdHocDataView={allowAdHocDataView}
showManagementLink={Boolean(editData && editData.isPersisted())}
/>
</I18nProvider>
<DataViewEditorLazy
onSave={onSaveIndexPattern}
onCancel={() => {
closeEditor();
onCancel();
}}
editData={editData}
defaultTypeIsRollup={defaultTypeIsRollup}
requireTimestampField={requireTimestampField}
allowAdHocDataView={allowAdHocDataView}
showManagementLink={Boolean(editData && editData.isPersisted())}
/>
</KibanaReactContextProvider>,
{ theme$: core.theme.theme$ }
{ theme: core.theme, i18n: core.i18n }
),
{
hideCloseButton: true,
Expand Down
9 changes: 4 additions & 5 deletions src/plugins/data_view_editor/public/plugin.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,15 @@ describe('DataViewEditorPlugin', () => {

expect(openFlyout).toHaveBeenCalled();

const [[arg]] = openFlyout.mock.calls;
const i18nProvider = arg.props.children;
expect(i18nProvider.props.children.type).toBe(DataViewEditorLazy);
const [[{ __reactMount__ }]] = openFlyout.mock.calls;
expect(__reactMount__.props.children.type).toBe(DataViewEditorLazy);

// We force call the "onSave" prop from the <RuntimeFieldEditorFlyoutContent /> component
// and make sure that the the spy is being called.
// Note: we are testing implementation details, if we change or rename the "onSave" prop on
// the component, we will need to update this test accordingly.
expect(i18nProvider.props.children.props.onSave).toBeDefined();
i18nProvider.props.children.props.onSave();
expect(__reactMount__.props.children.props.onSave).toBeDefined();
__reactMount__.props.children.props.onSave();
expect(onSaveSpy).toHaveBeenCalled();
});

Expand Down
1 change: 1 addition & 0 deletions src/plugins/data_view_editor/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"@kbn/test-jest-helpers",
"@kbn/ui-theme",
"@kbn/kibana-utils-plugin",
"@kbn/react-kibana-mount",
],
"exclude": [
"target/**/*",
Expand Down
7 changes: 4 additions & 3 deletions src/plugins/data_view_field_editor/public/open_editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
* Side Public License, v 1.
*/

import React from 'react';
import { CoreStart, OverlayRef } from '@kbn/core/public';
import { i18n } from '@kbn/i18n';
import React from 'react';
import { toMountPoint } from '@kbn/react-kibana-mount';
import { FieldEditorLoader } from './components/field_editor_loader';
import { euiFlyoutClassname } from './constants';
import type { ApiService } from './lib/api';
Expand All @@ -21,7 +22,7 @@ import type {
FieldFormatsStart,
DataViewField,
} from './shared_imports';
import { createKibanaReactContext, toMountPoint } from './shared_imports';
import { createKibanaReactContext } from './shared_imports';
import type { CloseEditor, Field, InternalFieldType, PluginStart } from './types';

/**
Expand Down Expand Up @@ -196,7 +197,7 @@ export const getFieldEditorOpener =
uiSettings={uiSettings}
/>
</KibanaReactContextProvider>,
{ theme$: core.theme.theme$ }
{ theme: core.theme, i18n: core.i18n }
),
{
className: euiFlyoutClassname,
Expand Down
8 changes: 4 additions & 4 deletions src/plugins/data_view_field_editor/public/plugin.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,15 @@ describe('DataViewFieldEditorPlugin', () => {

expect(openFlyout).toHaveBeenCalled();

const [[arg]] = openFlyout.mock.calls;
expect(arg.props.children.type).toBe(FieldEditorLoader);
const [[{ __reactMount__ }]] = openFlyout.mock.calls;
expect(__reactMount__.props.children.type).toBe(FieldEditorLoader);

// We force call the "onSave" prop from the <RuntimeFieldEditorFlyoutContent /> component
// and make sure that the the spy is being called.
// Note: we are testing implementation details, if we change or rename the "onSave" prop on
// the component, we will need to update this test accordingly.
expect(arg.props.children.props.onSave).toBeDefined();
arg.props.children.props.onSave();
expect(__reactMount__.props.children.props.onSave).toBeDefined();
__reactMount__.props.children.props.onSave();
expect(onSaveSpy).toHaveBeenCalled();
});

Expand Down
1 change: 1 addition & 0 deletions src/plugins/data_view_field_editor/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"@kbn/field-types",
"@kbn/utility-types",
"@kbn/config-schema",
"@kbn/react-kibana-mount",
],
"exclude": [
"target/**/*",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@ import { Redirect } from 'react-router-dom';
import { Router, Routes, Route } from '@kbn/shared-ux-router';

import { i18n } from '@kbn/i18n';
import { I18nProvider } from '@kbn/i18n-react';
import { StartServicesAccessor } from '@kbn/core/public';

import { KibanaContextProvider, KibanaThemeProvider } from '@kbn/kibana-react-plugin/public';
import { KibanaRenderContextProvider } from '@kbn/react-kibana-context-render';
import { KibanaContextProvider } from '@kbn/kibana-react-plugin/public';
import { ManagementAppMountParams } from '@kbn/management-plugin/public';
import {
IndexPatternTableWithRouter,
Expand All @@ -40,7 +39,18 @@ export async function mountManagementSection(
params: ManagementAppMountParams
) {
const [
{ application, chrome, uiSettings, settings, notifications, overlays, http, docLinks, theme },
{
application,
chrome,
uiSettings,
settings,
notifications,
overlays,
http,
docLinks,
theme,
i18n: coreI18n,
},
{
data,
dataViewFieldEditor,
Expand Down Expand Up @@ -83,29 +93,27 @@ export async function mountManagementSection(
};

ReactDOM.render(
<KibanaContextProvider services={deps}>
<KibanaThemeProvider theme$={theme.theme$}>
<I18nProvider>
<Router history={params.history}>
<Routes>
<Route path={['/create']}>
<IndexPatternTableWithRouter canSave={canSave} showCreateDialog={true} />
</Route>
<Route path={['/dataView/:id/field/:fieldName', '/dataView/:id/create-field/']}>
<CreateEditFieldContainer />
</Route>
<Route path={['/dataView/:id']}>
<EditIndexPatternContainer />
</Route>
<Redirect path={'/patterns*'} to={'dataView*'} />
<Route path={['/']}>
<IndexPatternTableWithRouter canSave={canSave} />
</Route>
</Routes>
</Router>
</I18nProvider>
</KibanaThemeProvider>
</KibanaContextProvider>,
<KibanaRenderContextProvider theme={theme} i18n={coreI18n}>
<KibanaContextProvider services={deps}>
<Router history={params.history}>
<Routes>
<Route path={['/create']}>
<IndexPatternTableWithRouter canSave={canSave} showCreateDialog={true} />
</Route>
<Route path={['/dataView/:id/field/:fieldName', '/dataView/:id/create-field/']}>
<CreateEditFieldContainer />
</Route>
<Route path={['/dataView/:id']}>
<EditIndexPatternContainer />
</Route>
<Redirect path={'/patterns*'} to={'dataView*'} />
<Route path={['/']}>
<IndexPatternTableWithRouter canSave={canSave} />
</Route>
</Routes>
</Router>
</KibanaContextProvider>
</KibanaRenderContextProvider>,
params.element
);

Expand Down
1 change: 1 addition & 0 deletions src/plugins/data_view_management/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"@kbn/config-schema",
"@kbn/shared-ux-router",
"@kbn/core-ui-settings-browser",
"@kbn/react-kibana-context-render",
],
"exclude": [
"target/**/*",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
*/
import React, { useCallback, useMemo, useState } from 'react';
import { i18n } from '@kbn/i18n';
import { MarkdownSimple, toMountPoint, wrapWithTheme } from '@kbn/kibana-react-plugin/public';
import { toMountPoint } from '@kbn/react-kibana-mount';
import { MarkdownSimple } from '@kbn/kibana-react-plugin/public';
import type { DataView } from '@kbn/data-views-plugin/public';
import { SortDirection } from '@kbn/data-plugin/public';
import type { DataTableRecord } from '@kbn/discover-utils/types';
Expand Down Expand Up @@ -42,8 +43,7 @@ export function useContextAppFetch({
useNewFieldsApi,
}: ContextAppFetchProps) {
const services = useDiscoverServices();
const { uiSettings: config, data, toastNotifications, filterManager, core } = services;
const { theme$ } = core.theme;
const { uiSettings: config, data, toastNotifications, filterManager } = services;

const searchSource = useMemo(() => {
return data.search.searchSource.createEmpty();
Expand All @@ -70,16 +70,9 @@ export function useContextAppFetch({
setState(createError('anchorStatus', FailureReason.INVALID_TIEBREAKER));
toastNotifications.addDanger({
title: errorTitle,
text: toMountPoint(
wrapWithTheme(
<MarkdownSimple>
{i18n.translate('discover.context.invalidTieBreakerFiledSetting', {
defaultMessage: 'Invalid tie breaker field setting',
})}
</MarkdownSimple>,
theme$
)
),
text: i18n.translate('discover.context.invalidTieBreakerFiledSetting', {
defaultMessage: 'Invalid tie breaker field setting',
}),
});
return;
}
Expand Down Expand Up @@ -108,7 +101,10 @@ export function useContextAppFetch({
setState(createError('anchorStatus', FailureReason.UNKNOWN, error));
toastNotifications.addDanger({
title: errorTitle,
text: toMountPoint(wrapWithTheme(<MarkdownSimple>{error.message}</MarkdownSimple>, theme$)),
text: toMountPoint(<MarkdownSimple>{error.message}</MarkdownSimple>, {
theme: services.core.theme,
i18n: services.core.i18n,
}),
});
}
}, [
Expand All @@ -120,7 +116,6 @@ export function useContextAppFetch({
anchorId,
searchSource,
useNewFieldsApi,
theme$,
]);

const fetchSurroundingRows = useCallback(
Expand Down Expand Up @@ -161,9 +156,10 @@ export function useContextAppFetch({
setState(createError(statusKey, FailureReason.UNKNOWN, error));
toastNotifications.addDanger({
title: errorTitle,
text: toMountPoint(
wrapWithTheme(<MarkdownSimple>{error.message}</MarkdownSimple>, theme$)
),
text: toMountPoint(<MarkdownSimple>{error.message}</MarkdownSimple>, {
theme: services.core.theme,
i18n: services.core.i18n,
}),
});
}
},
Expand All @@ -177,7 +173,6 @@ export function useContextAppFetch({
dataView,
toastNotifications,
useNewFieldsApi,
theme$,
data,
]
);
Expand Down
Loading

0 comments on commit 74911b6

Please sign in to comment.