Skip to content

Commit

Permalink
Merge with main, resolve conflicts, adds theme provider
Browse files Browse the repository at this point in the history
  • Loading branch information
stratoula committed Nov 24, 2021
2 parents 0bb4c7f + 7f2dbe5 commit 8653a82
Show file tree
Hide file tree
Showing 155 changed files with 2,973 additions and 1,357 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ import {
} from '../../../../core/public';
import { FieldSetting } from './types';
import { AdvancedSettings } from './advanced_settings';
import { notificationServiceMock, docLinksServiceMock } from '../../../../core/public/mocks';
import {
notificationServiceMock,
docLinksServiceMock,
themeServiceMock,
} from '../../../../core/public/mocks';
import { ComponentRegistry } from '../component_registry';
import { Search } from './components/search';

Expand Down Expand Up @@ -251,6 +255,7 @@ describe('AdvancedSettings', () => {
dockLinks={docLinksServiceMock.createStartContract().links}
uiSettings={mockConfig().core.uiSettings}
componentRegistry={new ComponentRegistry().start}
theme={themeServiceMock.createStartContract().theme$}
/>
);

Expand All @@ -273,6 +278,7 @@ describe('AdvancedSettings', () => {
dockLinks={docLinksServiceMock.createStartContract().links}
uiSettings={mockConfig().core.uiSettings}
componentRegistry={new ComponentRegistry().start}
theme={themeServiceMock.createStartContract().theme$}
/>
);

Expand All @@ -299,6 +305,7 @@ describe('AdvancedSettings', () => {
dockLinks={docLinksServiceMock.createStartContract().links}
uiSettings={mockConfig().core.uiSettings}
componentRegistry={new ComponentRegistry().start}
theme={themeServiceMock.createStartContract().theme$}
/>
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
DocLinksStart,
ToastsStart,
ScopedHistory,
ThemeServiceStart,
} from '../../../../core/public';
import { url } from '../../../kibana_utils/public';

Expand All @@ -41,6 +42,7 @@ interface AdvancedSettingsProps {
uiSettings: IUiSettingsClient;
dockLinks: DocLinksStart['links'];
toasts: ToastsStart;
theme: ThemeServiceStart['theme$'];
componentRegistry: ComponentRegistry['start'];
trackUiMetric?: (metricType: UiCounterMetricType, eventName: string | string[]) => void;
}
Expand Down Expand Up @@ -270,6 +272,7 @@ export class AdvancedSettings extends Component<AdvancedSettingsProps, AdvancedS
toasts={this.props.toasts}
trackUiMetric={this.props.trackUiMetric}
queryText={query.text}
theme={this.props.theme}
/>
<PageFooter
toasts={this.props.toasts}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import React from 'react';
import { shallowWithI18nProvider, mountWithI18nProvider } from '@kbn/test/jest';
import { UiSettingsType } from '../../../../../../core/public';
import { themeServiceMock } from '../../../../../../core/public/mocks';

import { findTestSubject } from '@elastic/eui/lib/test';

Expand Down Expand Up @@ -127,6 +128,7 @@ describe('Form', () => {
enableSaving={true}
toasts={{} as any}
dockLinks={{} as any}
theme={themeServiceMock.createStartContract().theme$}
/>
);

Expand All @@ -146,6 +148,7 @@ describe('Form', () => {
enableSaving={false}
toasts={{} as any}
dockLinks={{} as any}
theme={themeServiceMock.createStartContract().theme$}
/>
);

Expand All @@ -165,6 +168,7 @@ describe('Form', () => {
enableSaving={true}
toasts={{} as any}
dockLinks={{} as any}
theme={themeServiceMock.createStartContract().theme$}
/>
);

Expand All @@ -184,6 +188,7 @@ describe('Form', () => {
enableSaving={true}
toasts={{} as any}
dockLinks={{} as any}
theme={themeServiceMock.createStartContract().theme$}
/>
);

Expand All @@ -203,6 +208,7 @@ describe('Form', () => {
enableSaving={false}
toasts={{} as any}
dockLinks={{} as any}
theme={themeServiceMock.createStartContract().theme$}
/>
);
(wrapper.instance() as Form).setState({
Expand Down Expand Up @@ -233,6 +239,7 @@ describe('Form', () => {
enableSaving={false}
toasts={toasts}
dockLinks={{} as any}
theme={themeServiceMock.createStartContract().theme$}
/>
);
(wrapper.instance() as Form).setState({
Expand Down Expand Up @@ -269,6 +276,7 @@ describe('Form', () => {
enableSaving={false}
toasts={{} as any}
dockLinks={{} as any}
theme={themeServiceMock.createStartContract().theme$}
/>
);

Expand Down Expand Up @@ -297,6 +305,7 @@ describe('Form', () => {
enableSaving={false}
toasts={{} as any}
dockLinks={{} as any}
theme={themeServiceMock.createStartContract().theme$}
/>
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ import { FormattedMessage } from '@kbn/i18n/react';
import { isEmpty } from 'lodash';
import { i18n } from '@kbn/i18n';
import { UiCounterMetricType } from '@kbn/analytics';
import { toMountPoint } from '../../../../../kibana_react/public';
import { DocLinksStart, ToastsStart } from '../../../../../../core/public';
import { KibanaThemeProvider, toMountPoint } from '../../../../../kibana_react/public';
import { DocLinksStart, ThemeServiceStart, ToastsStart } from '../../../../../../core/public';

import { getCategoryName } from '../../lib';
import { Field, getEditableValue } from '../field';
Expand All @@ -46,6 +46,7 @@ interface FormProps {
enableSaving: boolean;
dockLinks: DocLinksStart['links'];
toasts: ToastsStart;
theme: ThemeServiceStart['theme$'];
trackUiMetric?: (metricType: UiCounterMetricType, eventName: string | string[]) => void;
queryText?: string;
}
Expand Down Expand Up @@ -191,7 +192,7 @@ export class Form extends PureComponent<FormProps> {
defaultMessage: 'One or more settings require you to reload the page to take effect.',
}),
text: toMountPoint(
<>
<KibanaThemeProvider theme$={this.props.theme}>
<EuiFlexGroup justifyContent="flexEnd" gutterSize="s">
<EuiFlexItem grow={false}>
<EuiButton size="s" onClick={() => window.location.reload()}>
Expand All @@ -201,7 +202,7 @@ export class Form extends PureComponent<FormProps> {
</EuiButton>
</EuiFlexItem>
</EuiFlexGroup>
</>
</KibanaThemeProvider>
),
color: 'success',
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { i18n } from '@kbn/i18n';
import { I18nProvider } from '@kbn/i18n/react';

import { LocationDescriptor } from 'history';
import { KibanaThemeProvider } from '../../../kibana_react/public';
import { url } from '../../../kibana_utils/public';
import { ManagementAppMountParams } from '../../../management/public';
import { UsageCollectionSetup } from '../../../usage_collection/public';
Expand Down Expand Up @@ -70,25 +71,28 @@ export async function mountManagementSection(
chrome.docTitle.change(title);

ReactDOM.render(
<I18nProvider>
<Router history={params.history}>
<Switch>
{/* TODO: remove route param (`query`) in 7.13 */}
<Route path={`/:${QUERY}`}>{(props) => <Redirect to={redirectUrl(props)} />}</Route>
<Route path="/">
<AdvancedSettings
history={params.history}
enableSaving={canSave}
toasts={notifications.toasts}
dockLinks={docLinks.links}
uiSettings={uiSettings}
componentRegistry={componentRegistry}
trackUiMetric={trackUiMetric}
/>
</Route>
</Switch>
</Router>
</I18nProvider>,
<KibanaThemeProvider theme$={params.theme$}>
<I18nProvider>
<Router history={params.history}>
<Switch>
{/* TODO: remove route param (`query`) in 7.13 */}
<Route path={`/:${QUERY}`}>{(props) => <Redirect to={redirectUrl(props)} />}</Route>
<Route path="/">
<AdvancedSettings
history={params.history}
enableSaving={canSave}
toasts={notifications.toasts}
dockLinks={docLinks.links}
uiSettings={uiSettings}
theme={params.theme$}
componentRegistry={componentRegistry}
trackUiMetric={trackUiMetric}
/>
</Route>
</Switch>
</Router>
</I18nProvider>
</KibanaThemeProvider>,
params.element
);
return () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"server": true,
"ui": true,
"requiredPlugins": ["expressions", "fieldFormats", "charts", "visualizations", "presentationUtil", "data"],
"requiredBundles": ["kibanaUtils"],
"requiredBundles": ["kibanaUtils", "kibanaReact"],
"optionalPlugins": [],
"extraPublicDirs": ["common"]
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import { i18n } from '@kbn/i18n';
import React, { memo } from 'react';
import { render, unmountComponentAtNode } from 'react-dom';
import type { PersistedState } from '../../../../visualizations/public';
import { ThemeServiceStart } from '../../../../../core/public';
import { KibanaThemeProvider } from '../../../../kibana_react/public';
import { ExpressionRenderDefinition } from '../../../../expressions/common/expression_renderers';
import {
EXPRESSION_HEATMAP_NAME,
Expand All @@ -23,7 +25,13 @@ import HeatmapComponent from '../components/heatmap_component';
import './index.scss';
const MemoizedChart = memo(HeatmapComponent);

export const heatmapRenderer = (): ExpressionRenderDefinition<HeatmapExpressionProps> => ({
interface ExpressioHeatmapRendererDependencies {
theme: ThemeServiceStart;
}

export const heatmapRenderer: (
deps: ExpressioHeatmapRendererDependencies
) => ExpressionRenderDefinition<HeatmapExpressionProps> = ({ theme }) => ({
name: EXPRESSION_HEATMAP_NAME,
displayName: i18n.translate('expressionHeatmap.visualizationName', {
defaultMessage: 'Heatmap',
Expand All @@ -42,18 +50,20 @@ export const heatmapRenderer = (): ExpressionRenderDefinition<HeatmapExpressionP

const timeZone = getTimeZone(getUISettings());
render(
<div className="heatmap-container" data-test-subj="heatmapChart">
<MemoizedChart
{...config}
onClickValue={onClickValue}
onSelectRange={onSelectRange}
timeZone={timeZone}
formatFactory={getFormatService().deserialize}
chartsThemeService={getThemeService()}
paletteService={getPaletteService()}
uiState={handlers.uiState as PersistedState}
/>
</div>,
<KibanaThemeProvider theme$={theme.theme$}>
<div className="heatmap-container" data-test-subj="heatmapChart">
<MemoizedChart
{...config}
onClickValue={onClickValue}
onSelectRange={onSelectRange}
timeZone={timeZone}
formatFactory={getFormatService().deserialize}
chartsThemeService={getThemeService()}
paletteService={getPaletteService()}
uiState={handlers.uiState as PersistedState}
/>
</div>
</KibanaThemeProvider>,
domNode,
() => {
handlers.done();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export class ExpressionHeatmapPlugin {
expressions.registerFunction(heatmapFunction);
expressions.registerFunction(heatmapLegendConfig);
expressions.registerFunction(heatmapGridConfig);
expressions.registerRenderer(heatmapRenderer());
expressions.registerRenderer(heatmapRenderer({ theme: core.theme }));
}

public start(core: CoreStart, { fieldFormats }: ExpressionHeatmapPluginStart) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
"server": true,
"ui": true,
"requiredPlugins": ["expressions", "fieldFormats", "charts", "visualizations", "presentationUtil"],
"requiredBundles": ["kibanaUtils"],
"requiredBundles": ["kibanaUtils", "kibanaReact"],
"optionalPlugins": []
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@

import React from 'react';
import { storiesOf } from '@storybook/react';
import { from } from 'rxjs';
import { ExpressionValueVisDimension } from '../../../../visualizations/common';
import { Datatable, DatatableColumn } from '../../../../expressions';
import { Render } from '../../../../presentation_util/public/__stories__';
import { ColorMode, CustomPaletteState } from '../../../../charts/common';
import { metricVisRenderer } from '../expression_renderers';
import { getMetricVisRenderer } from '../expression_renderers';
import { MetricStyle, MetricVisRenderConfig, visType } from '../../common/types';

const palette: CustomPaletteState = {
Expand Down Expand Up @@ -117,6 +118,8 @@ const containerSize = {
height: '700px',
};

const metricVisRenderer = getMetricVisRenderer({ theme$: from([{ darkMode: false }]) });

storiesOf('renderers/visMetric', module)
.add('Default', () => {
return <Render renderer={metricVisRenderer} config={config} {...containerSize} />;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
* Side Public License, v 1.
*/

export { metricVisRenderer } from './metric_vis_renderer';
export { getMetricVisRenderer } from './metric_vis_renderer';
Loading

0 comments on commit 8653a82

Please sign in to comment.