Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into issue-108387-es-cli…
Browse files Browse the repository at this point in the history
…ent-80
  • Loading branch information
mshustov committed Oct 25, 2021
2 parents f7aa7ce + 1527535 commit 22c8789
Show file tree
Hide file tree
Showing 42 changed files with 355 additions and 205 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,9 @@ describe('Dashboard container lifecycle', () => {
});
});

describe('Dashboard initial state', () => {
// FLAKY: https://github.com/elastic/kibana/issues/116050
// FLAKY: https://github.com/elastic/kibana/issues/105018
describe.skip('Dashboard initial state', () => {
it('Extracts state from Dashboard Saved Object', async () => {
const { renderHookResult, embeddableFactoryResult } = renderDashboardAppStateHook({});
const getResult = () => renderHookResult.result.current;
Expand Down Expand Up @@ -276,7 +278,8 @@ describe('Dashboard initial state', () => {
});
});

describe('Dashboard state sync', () => {
// FLAKY: https://github.com/elastic/kibana/issues/116043
describe.skip('Dashboard state sync', () => {
let defaultDashboardAppStateHookResult: RenderDashboardStateHookReturn;
const getResult = () => defaultDashboardAppStateHookResult.renderHookResult.result.current;

Expand Down
1 change: 1 addition & 0 deletions src/plugins/telemetry/server/fetcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ export class FetcherTask {
method: 'post',
body: stats,
headers: {
'Content-Type': 'application/json',
'X-Elastic-Stack-Version': this.currentKibanaVersion,
'X-Elastic-Cluster-ID': clusterUuid,
'X-Elastic-Content-Encoding': PAYLOAD_CONTENT_ENCODING,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

import './timeseries_visualization.scss';

import React, { useCallback, useEffect } from 'react';
import { EuiFlexGroup, EuiFlexItem } from '@elastic/eui';
import React, { Suspense, useCallback, useEffect } from 'react';
import { EuiFlexGroup, EuiFlexItem, EuiLoadingChart } from '@elastic/eui';
import { XYChartSeriesIdentifier, GeometryValue } from '@elastic/charts';
import { IUiSettingsClient } from 'src/core/public';
import { IInterpreterRenderHandlers } from 'src/plugins/expressions';
Expand All @@ -28,6 +28,7 @@ import { getInterval } from './lib/get_interval';
import { AUTO_INTERVAL } from '../../../common/constants';
import { TIME_RANGE_DATA_MODES, PANEL_TYPES } from '../../../common/enums';
import type { IndexPattern } from '../../../../../data/common';
import '../index.scss';

interface TimeseriesVisualizationProps {
className?: string;
Expand Down Expand Up @@ -161,18 +162,26 @@ function TimeseriesVisualization({
</EuiFlexItem>
)}
<EuiFlexItem>
<VisComponent
getConfig={getConfig}
model={model}
visData={visData}
uiState={uiState}
onBrush={onBrush}
onFilterClick={handleFilterClick}
onUiState={handleUiState}
syncColors={syncColors}
palettesService={palettesService}
fieldFormatMap={indexPattern?.fieldFormatMap}
/>
<Suspense
fallback={
<div className="visChart__spinner">
<EuiLoadingChart mono size="l" />
</div>
}
>
<VisComponent
getConfig={getConfig}
model={model}
visData={visData}
uiState={uiState}
onBrush={onBrush}
onFilterClick={handleFilterClick}
onUiState={handleUiState}
syncColors={syncColors}
palettesService={palettesService}
fieldFormatMap={indexPattern?.fieldFormatMap}
/>
</Suspense>
</EuiFlexItem>
</EuiFlexGroup>
);
Expand Down
69 changes: 41 additions & 28 deletions src/plugins/vis_types/timeseries/public/timeseries_vis_renderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { render, unmountComponentAtNode } from 'react-dom';
import { I18nProvider } from '@kbn/i18n/react';
import { IUiSettingsClient } from 'kibana/public';

import { EuiLoadingChart } from '@elastic/eui';
import { fetchIndexPattern } from '../common/index_patterns_utils';
import { VisualizationContainer, PersistedState } from '../../../visualizations/public';

Expand Down Expand Up @@ -43,10 +44,6 @@ export const getTimeseriesVisRenderer: (deps: {
name: 'timeseries_vis',
reuseDomNode: true,
render: async (domNode, config, handlers) => {
// Build optimization. Move app styles from main bundle
// @ts-expect-error TS error, cannot find type declaration for scss
await import('./application/index.scss');

handlers.onDestroy(() => {
unmountComponentAtNode(domNode);
});
Expand All @@ -55,33 +52,49 @@ export const getTimeseriesVisRenderer: (deps: {
const { indexPatterns } = getDataStart();

const showNoResult = !checkIfDataExists(visData, model);
const [palettesService, { indexPattern }] = await Promise.all([

let servicesLoaded;

Promise.all([
palettes.getPalettes(),
fetchIndexPattern(model.index_pattern, indexPatterns),
]);
]).then(([palettesService, { indexPattern }]) => {
servicesLoaded = true;

render(
<I18nProvider>
<VisualizationContainer
data-test-subj="timeseriesVis"
handlers={handlers}
showNoResult={showNoResult}
error={get(visData, [model.id, 'error'])}
>
<TimeseriesVisualization
// it is mandatory to bind uiSettings because of "this" usage inside "get" method
getConfig={uiSettings.get.bind(uiSettings)}
unmountComponentAtNode(domNode);

render(
<I18nProvider>
<VisualizationContainer
data-test-subj="timeseriesVis"
handlers={handlers}
indexPattern={indexPattern}
model={model}
visData={visData as TimeseriesVisData}
syncColors={syncColors}
uiState={handlers.uiState! as PersistedState}
palettesService={palettesService}
/>
</VisualizationContainer>
</I18nProvider>,
domNode
);
showNoResult={showNoResult}
error={get(visData, [model.id, 'error'])}
>
<TimeseriesVisualization
// it is mandatory to bind uiSettings because of "this" usage inside "get" method
getConfig={uiSettings.get.bind(uiSettings)}
handlers={handlers}
indexPattern={indexPattern}
model={model}
visData={visData as TimeseriesVisData}
syncColors={syncColors}
uiState={handlers.uiState! as PersistedState}
palettesService={palettesService}
/>
</VisualizationContainer>
</I18nProvider>,
domNode
);
});

if (!servicesLoaded) {
render(
<div className="visChart__spinner">
<EuiLoadingChart mono size="l" />
</div>,
domNode
);
}
},
});
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
import _, { get } from 'lodash';
import { Subscription } from 'rxjs';
import { i18n } from '@kbn/i18n';
import React from 'react';
import { render } from 'react-dom';
import { EuiLoadingChart } from '@elastic/eui';
import { VISUALIZE_EMBEDDABLE_TYPE } from './constants';
import {
IndexPattern,
Expand Down Expand Up @@ -299,6 +302,13 @@ export class VisualizeEmbeddable
this.domNode = div;
super.render(this.domNode);

render(
<div className="visChart__spinner">
<EuiLoadingChart mono size="l" />
</div>,
this.domNode
);

const expressions = getExpressions();
this.handler = await expressions.loader(this.domNode, undefined, {
onRenderError: (element: HTMLElement, error: ExpressionRenderError) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@ export const createVisualizeEmbeddableAsync = async (
...args: ConstructorParameters<typeof VisualizeEmbeddableType>
) => {
// Build optimization. Move app styles from main bundle
// @ts-expect-error TS error, cannot find type declaration for scss
await import('./embeddables.scss');

const { VisualizeEmbeddable } = await import('./visualize_embeddable');
const [{ VisualizeEmbeddable }] = await Promise.all([
import('./visualize_embeddable'),
// @ts-expect-error TS error, cannot find type declaration for scss
import('./embeddables.scss'),
]);

return new VisualizeEmbeddable(...args);
};
3 changes: 2 additions & 1 deletion test/functional/apps/visualize/_timelion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,8 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
expect(value).to.eql('.es()');
});

describe('dynamic suggestions for argument values', () => {
// FLAKY: https://github.com/elastic/kibana/issues/116033
describe.skip('dynamic suggestions for argument values', () => {
describe('.es()', () => {
it('should show index pattern suggestions for index argument', async () => {
await monacoEditor.setCodeEditorValue('');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,18 @@ describe('DomainsTable', () => {
expect(tableContent).toContain('elastic.co');
});

it('renders a clickable domain url', () => {
const basicTable = wrapper.find(EuiInMemoryTable).dive().find(EuiBasicTable).dive();
const link = basicTable.find('[data-test-subj="CrawlerDomainURL"]').at(0);

expect(link.dive().text()).toContain('elastic.co');
expect(link.props()).toEqual(
expect.objectContaining({
to: '/engines/some-engine/crawler/domains/1234',
})
);
});

it('renders a last crawled column', () => {
expect(tableContent).toContain('Last activity');
expect(tableContent).toContain('Jan 1, 2020');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { FormattedNumber } from '@kbn/i18n/react';

import { DELETE_BUTTON_LABEL, MANAGE_BUTTON_LABEL } from '../../../../shared/constants';
import { KibanaLogic } from '../../../../shared/kibana';
import { EuiLinkTo } from '../../../../shared/react_router_helpers';
import { AppLogic } from '../../../app_logic';
import { ENGINE_CRAWLER_DOMAIN_PATH } from '../../../routes';
import { generateEnginePath } from '../../engine';
Expand Down Expand Up @@ -46,6 +47,14 @@ export const DomainsTable: React.FC = () => {
defaultMessage: 'Domain URL',
}
),
render: (_, domain: CrawlerDomain) => (
<EuiLinkTo
data-test-subj="CrawlerDomainURL"
to={generateEnginePath(ENGINE_CRAWLER_DOMAIN_PATH, { domainId: domain.id })}
>
{domain.url}
</EuiLinkTo>
),
},
{
field: 'lastCrawl',
Expand Down
3 changes: 1 addition & 2 deletions x-pack/plugins/lens/common/expressions/xy_chart/xy_args.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ import type { LayerArgs } from './layer_config';
import type { LegendConfigResult } from './legend_config';
import type { TickLabelsConfigResult } from './tick_labels_config';
import type { LabelsOrientationConfigResult } from './labels_orientation_config';

export type ValueLabelConfig = 'hide' | 'inside' | 'outside';
import type { ValueLabelConfig } from '../../types';

export type XYCurveType = 'LINEAR' | 'CURVE_MONOTONE_X';

Expand Down
3 changes: 3 additions & 0 deletions x-pack/plugins/lens/common/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,6 @@ export interface CustomPaletteParams {
export type RequiredPaletteParamTypes = Required<CustomPaletteParams>;

export type LayerType = 'data' | 'referenceLine';

// Shared by XY Chart and Heatmap as for now
export type ValueLabelConfig = 'hide' | 'inside' | 'outside';
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,9 @@ export const HeatmapComponent: FC<HeatmapRenderProps> = ({
maxHeight: 'fill',
label: {
visible: args.gridConfig.isCellLabelVisible ?? false,
minFontSize: 8,
maxFontSize: 18,
useGlobalMinFontSize: true, // override the min if there's a different directive upstream
},
border: {
strokeWidth: 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { EuiFlexGroup, EuiFlexItem } from '@elastic/eui';
import { Position } from '@elastic/charts';
import { i18n } from '@kbn/i18n';
import type { VisualizationToolbarProps } from '../types';
import { LegendSettingsPopover } from '../shared_components';
import { LegendSettingsPopover, ToolbarPopover, ValueLabelsSettings } from '../shared_components';
import type { HeatmapVisualizationState } from './types';

const legendOptions: Array<{ id: string; value: 'auto' | 'show' | 'hide'; label: string }> = [
Expand All @@ -37,11 +37,29 @@ export const HeatmapToolbar = memo(
const legendMode = state.legend.isVisible ? 'show' : 'hide';

return (
<EuiFlexGroup gutterSize="m" justifyContent="spaceBetween">
<EuiFlexGroup gutterSize="m" justifyContent="spaceBetween" responsive={false}>
<EuiFlexItem>
<EuiFlexGroup gutterSize="none" responsive={false}>
<ToolbarPopover
title={i18n.translate('xpack.lens.shared.curveLabel', {
defaultMessage: 'Visual options',
})}
type="visualOptions"
groupPosition="left"
buttonDataTestSubj="lnsVisualOptionsButton"
>
<ValueLabelsSettings
valueLabels={state?.gridConfig.isCellLabelVisible ? 'inside' : 'hide'}
onValueLabelChange={(newMode) => {
setState({
...state,
gridConfig: { ...state.gridConfig, isCellLabelVisible: newMode === 'inside' },
});
}}
/>
</ToolbarPopover>
<LegendSettingsPopover
groupPosition={'none'}
groupPosition={'right'}
legendOptions={legendOptions}
mode={legendMode}
onDisplayChange={(optionId) => {
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/lens/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ export type {
XYLayerConfig,
LegendConfig,
SeriesType,
ValueLabelConfig,
YAxisMode,
XYCurveType,
YConfig,
} from '../common/expressions';
export type { ValueLabelConfig } from '../common/types';
export type { DatatableVisualizationState } from './datatable_visualization/visualization';
export type {
IndexPatternPersistedState,
Expand Down
Loading

0 comments on commit 22c8789

Please sign in to comment.