Skip to content

Commit

Permalink
Merge branch 'main' into d/2021-12-30-significant-text-agg
Browse files Browse the repository at this point in the history
  • Loading branch information
kibanamachine authored Jan 4, 2022
2 parents 88edfd0 + 348bfb8 commit 1ef1187
Show file tree
Hide file tree
Showing 66 changed files with 877 additions and 47,146 deletions.
2 changes: 1 addition & 1 deletion NOTICE.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Kibana source code with Kibana X-Pack source code
Copyright 2012-2021 Elasticsearch B.V.
Copyright 2012-2022 Elasticsearch B.V.

---
Pretty handling of logarithmic axes.
Expand Down
2 changes: 1 addition & 1 deletion src/dev/storybook/aliases.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const storybookAliases = {
expression_shape: 'src/plugins/expression_shape/.storybook',
expression_tagcloud: 'src/plugins/chart_expressions/expression_tagcloud/.storybook',
expression_metric_vis: 'src/plugins/chart_expressions/expression_metric/.storybook',
fleet: 'x-pack/plugins/fleet/storybook',
fleet: 'x-pack/plugins/fleet/.storybook',
infra: 'x-pack/plugins/infra/.storybook',
security_solution: 'x-pack/plugins/security_solution/.storybook',
ui_actions_enhanced: 'x-pack/plugins/ui_actions_enhanced/.storybook',
Expand Down
14 changes: 10 additions & 4 deletions src/plugins/kibana_react/common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@
* Side Public License, v 1.
*/

// TODO: https://github.com/elastic/kibana/issues/109898
/* eslint-disable @kbn/eslint/no_export_all */

export * from './eui_styled_components';
export type { EuiTheme } from './eui_styled_components';
export {
EuiThemeProviderDecorator,
css,
euiStyled,
EuiThemeProvider,
createGlobalStyle,
keyframes,
withTheme,
} from './eui_styled_components';
82 changes: 67 additions & 15 deletions src/plugins/kibana_react/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,80 @@
* Side Public License, v 1.
*/

// TODO: https://github.com/elastic/kibana/issues/109898
/* eslint-disable @kbn/eslint/no_export_all */

export * from './code_editor';
export * from './url_template_editor';
export * from './exit_full_screen_button';
export * from './context';
export * from './overview_page';
export * from './overlays';
export * from './ui_settings';
export * from './table_list_view';
export * from './toolbar_button';
export * from './react_router_navigate';
export * from './page_template';
export type { CodeEditorProps } from './code_editor';
export {
CssLang,
MarkdownLang,
YamlLang,
HandlebarsLang,
HJsonLang,
CodeEditor,
CodeEditorField,
} from './code_editor';

export type { UrlTemplateEditorVariable, UrlTemplateEditorProps } from './url_template_editor';
export { UrlTemplateEditor } from './url_template_editor';

export type { ExitFullScreenButtonProps } from './exit_full_screen_button';
export { ExitFullScreenButton } from './exit_full_screen_button';

export type { KibanaReactContext, KibanaReactContextValue, KibanaServices } from './context';
export {
context,
createKibanaReactContext,
KibanaContextProvider,
useKibana,
withKibana,
} from './context';

export { overviewPageActions, OverviewPageFooter } from './overview_page';

export type { KibanaReactOverlays } from './overlays';
export { createReactOverlays } from './overlays';

export { useUiSetting, useUiSetting$ } from './ui_settings';

export type { TableListViewProps, TableListViewState } from './table_list_view';
export { TableListView } from './table_list_view';

export type { ToolbarButtonProps } from './toolbar_button';
export { POSITIONS, WEIGHTS, TOOLBAR_BUTTON_SIZES, ToolbarButton } from './toolbar_button';

export { reactRouterNavigate, reactRouterOnClickHandler } from './react_router_navigate';

export type {
KibanaPageTemplateProps,
NoDataPageActions,
NoDataPageActionsProps,
NoDataPageProps,
ElasticAgentCardProps,
} from './page_template';
export {
KibanaPageTemplate,
KibanaPageTemplateSolutionNavAvatar,
NO_DATA_PAGE_MAX_WIDTH,
NO_DATA_PAGE_TEMPLATE_PROPS,
NO_DATA_RECOMMENDED,
NoDataPage,
ElasticAgentCard,
NoDataCard,
} from './page_template';

export type { Value } from './validated_range';
export { ValidatedDualRange } from './validated_range';
export * from './notifications';

export type { ToastInput, KibanaReactNotifications } from './notifications';
export { createNotifications } from './notifications';

export { Markdown, MarkdownSimple } from './markdown';

export { reactToUiComponent, uiToReactComponent } from './adapters';

export { toMountPoint, MountPointPortal } from './util';
export type { ToMountPointOptions } from './util';

export { RedirectAppLinks } from './app_links';

export { wrapWithTheme, KibanaThemeProvider } from './theme';

/** dummy plugin, we just want kibanaReact to have its own bundle */
Expand Down
41 changes: 40 additions & 1 deletion src/plugins/vis_types/xy/public/config/get_config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
*/

import { getConfig } from './get_config';
import { visData, visParamsWithTwoYAxes } from '../mocks';
import { visData, visDataPercentile, visParamsWithTwoYAxes } from '../mocks';
import { VisParams } from '../types';

// ToDo: add more tests for all the config properties
describe('getConfig', () => {
Expand Down Expand Up @@ -65,4 +66,42 @@ describe('getConfig', () => {
const config = getConfig(visData, newVisParams);
expect(config.yAxes.length).toBe(1);
});

it('assigns the correct number of yAxes if the agg is Percentile', () => {
const newVisParams = {
...visParamsWithTwoYAxes,
seriesParams: [
{
type: 'line',
data: {
label: 'Percentiles of bytes',
id: '1',
},
drawLinesBetweenPoints: true,
interpolate: 'linear',
lineWidth: 2,
mode: 'normal',
show: true,
showCircles: true,
circlesRadius: 3,
valueAxis: 'ValueAxis-1',
},
],
dimensions: {
...visParamsWithTwoYAxes.dimensions,
y: ['1st', '5th', '25th', '50th', '75th', '95th', '99th'].map((prefix, accessor) => ({
label: `${prefix} percentile of bytes`,
aggType: 'percentiles',
params: {},
accessor,
format: {
id: 'number',
params: {},
},
})),
},
} as VisParams;
const config = getConfig(visDataPercentile, newVisParams);
expect(config.yAxes.length).toBe(1);
});
});
9 changes: 7 additions & 2 deletions src/plugins/vis_types/xy/public/config/get_config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import { getLegend } from './get_legend';
import { getAxis } from './get_axis';
import { getAspects } from './get_aspects';
import { ChartType } from '../index';
import { getSafeId } from '../utils/accessors';

export function getConfig(
table: Datatable,
Expand All @@ -51,13 +52,17 @@ export function getConfig(

const yAxes: Array<AxisConfig<ScaleContinuousType>> = [];

// avoid duplicates based on aggId
const aspectVisited = new Set();
params.dimensions.y.forEach((y) => {
const accessor = y.accessor;
const aspect = aspects.y.find(({ column }) => column === accessor);
const serie = params.seriesParams.find(({ data: { id } }) => id === aspect?.aggId);
const aggId = getSafeId(aspect?.aggId);
const serie = params.seriesParams.find(({ data: { id } }) => id === aggId);
const valueAxis = params.valueAxes.find(({ id }) => id === serie?.valueAxis);
if (aspect && valueAxis) {
if (aspect && valueAxis && !aspectVisited.has(aggId)) {
yAxes.push(getAxis<YScaleType>(valueAxis, params.grid, aspect, params.seriesParams));
aspectVisited.add(aggId);
}
});

Expand Down
80 changes: 80 additions & 0 deletions src/plugins/vis_types/xy/public/mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,86 @@ export const visData = {
],
} as Datatable;

export const visDataPercentile = {
type: 'datatable',
columns: [
{
id: 'col-0-1.1',
name: '1st percentile of bytes',
meta: {
type: 'number',
field: 'bytes',
index: 'kibana_sample_data_logs',
},
},
{
id: 'col-1-1.5',
name: '5th percentile of bytes',
meta: {
type: 'number',
field: 'bytes',
index: 'kibana_sample_data_logs',
},
},
{
id: 'col-2-1.25',
name: '25th percentile of bytes',
meta: {
type: 'number',
field: 'bytes',
index: 'kibana_sample_data_logs',
},
},
{
id: 'col-3-1.50',
name: '50th percentile of bytes',
meta: {
type: 'number',
field: 'bytes',
index: 'kibana_sample_data_logs',
},
},
{
id: 'col-4-1.75',
name: '75th percentile of bytes',
meta: {
type: 'number',
field: 'bytes',
index: 'kibana_sample_data_logs',
},
},
{
id: 'col-5-1.95',
name: '95th percentile of bytes',
meta: {
type: 'number',
field: 'bytes',
index: 'kibana_sample_data_logs',
},
},
{
id: 'col-6-1.99',
name: '99th percentile of bytes',
meta: {
type: 'number',
field: 'bytes',
index: 'kibana_sample_data_logs',
},
},
],
rows: [
{
'col-0-1.1': 0,
'col-1-1.5': 0,
'col-2-1.25': 1741.5,
'col-3-1.50': 4677,
'col-4-1.75': 5681.5,
'col-5-1.95': 6816,
'col-6-1.99': 6816,
},
],
} as Datatable;

export const visParamsWithTwoYAxes = {
type: 'histogram',
addLegend: true,
Expand Down
9 changes: 7 additions & 2 deletions src/plugins/vis_types/xy/public/utils/accessors.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,13 @@ export const getSplitSeriesAccessorFnMap = (
};

// For percentile, the aggregation id is coming in the form %s.%d, where %s is agg_id and %d - percents
export const isPercentileIdEqualToSeriesId = (columnId: number | string, seriesColumnId: string) =>
columnId.toString().split('.')[0] === seriesColumnId;
export const getSafeId = (columnId?: number | string | null) =>
(columnId || '').toString().split('.')[0];

export const isPercentileIdEqualToSeriesId = (
columnId: number | string | null | undefined,
seriesColumnId: string
) => getSafeId(columnId) === seriesColumnId;

export const isValidSeriesForDimension = (seriesColumnId: string, { aggId, accessor }: Aspect) =>
(aggId === seriesColumnId || isPercentileIdEqualToSeriesId(aggId ?? '', seriesColumnId)) &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,6 @@
* 2.0.
*/

import { defaultConfigWebFinal } from '@kbn/storybook';
import { defaultConfig } from '@kbn/storybook';

module.exports = {
...defaultConfigWebFinal,
addons: ['@storybook/addon-essentials'],
babel: () => ({
presets: [require.resolve('@kbn/babel-preset/webpack_preset')],
}),
};
module.exports = defaultConfig;
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion x-pack/plugins/fleet/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
},
"include": [
// add all the folders containg files to be compiled
".storybook/**/*",
"common/**/*",
"public/**/*",
"server/**/*",
"server/**/*.json",
"scripts/**/*",
"package.json",
"storybook/**/*",
"../../../typings/**/*"
],
"references": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export type TestSubjects =
| 'deleteTemplatesConfirmation'
| 'documentationLink'
| 'emptyPrompt'
| 'forcemergeIndexMenuButton'
| 'filterList.filterItem'
| 'ilmPolicyLink'
| 'includeStatsSwitch'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export interface IndicesTestBed extends TestBed<TestSubjects> {
clickDataStreamAt: (index: number) => void;
clickManageContextMenuButton: () => void;
clickContextMenuOption: (optionDataTestSubject: string) => void;
clickModalConfirm: () => void;
};
findDataStreamDetailPanel: () => ReactWrapper;
findDataStreamDetailPanelTitle: () => string;
Expand Down Expand Up @@ -97,6 +98,15 @@ export const setup = async (overridingDependencies: any = {}): Promise<IndicesTe
component.update();
};

const clickModalConfirm = async () => {
const { find, component } = testBed;

await act(async () => {
find('confirmModalConfirmButton').simulate('click');
});
component.update();
};

const findDataStreamDetailPanel = () => {
const { find } = testBed;
return find('dataStreamDetailPanel');
Expand All @@ -116,6 +126,7 @@ export const setup = async (overridingDependencies: any = {}): Promise<IndicesTe
clickDataStreamAt,
clickManageContextMenuButton,
clickContextMenuOption,
clickModalConfirm,
},
findDataStreamDetailPanel,
findDataStreamDetailPanelTitle,
Expand Down
Loading

0 comments on commit 1ef1187

Please sign in to comment.