Skip to content

Commit

Permalink
Merge branch 'master' into dls.apm.snm
Browse files Browse the repository at this point in the history
  • Loading branch information
szabosteve authored Sep 6, 2021
2 parents 515e7c4 + 00fac96 commit d6ff363
Show file tree
Hide file tree
Showing 51 changed files with 907 additions and 190 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ readonly links: {
readonly kibanaSettings: string;
readonly supportedServiceMaps: string;
readonly upgrading: string;
readonly metaData: string;
};
readonly canvas: {
readonly guide: string;
Expand Down

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions src/core/public/doc_links/doc_links_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export class DocLinksService {
kibanaSettings: `${KIBANA_DOCS}apm-settings-in-kibana.html`,
supportedServiceMaps: `${KIBANA_DOCS}service-maps.html#service-maps-supported`,
upgrading: `${APM_DOCS}server/${DOC_LINK_VERSION}/upgrading.html`,
metaData: `${APM_DOCS}get-started/${DOC_LINK_VERSION}/metadata.html`,
},
canvas: {
guide: `${KIBANA_DOCS}canvas.html`,
Expand Down Expand Up @@ -461,6 +462,7 @@ export interface DocLinksStart {
readonly kibanaSettings: string;
readonly supportedServiceMaps: string;
readonly upgrading: string;
readonly metaData: string;
};
readonly canvas: {
readonly guide: string;
Expand Down
1 change: 1 addition & 0 deletions src/core/public/public.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,7 @@ export interface DocLinksStart {
readonly kibanaSettings: string;
readonly supportedServiceMaps: string;
readonly upgrading: string;
readonly metaData: string;
};
readonly canvas: {
readonly guide: string;
Expand Down
1 change: 1 addition & 0 deletions src/dev/storybook/aliases.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export const storybookAliases = {
expression_repeat_image: 'src/plugins/expression_repeat_image/.storybook',
expression_reveal_image: 'src/plugins/expression_reveal_image/.storybook',
expression_shape: 'src/plugins/expression_shape/.storybook',
expression_tagcloud: 'src/plugins/chart_expressions/expression_tagcloud/.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
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
import { defaultConfig } from '@kbn/storybook';
import webpackMerge from 'webpack-merge';
import { resolve } from 'path';

const mockConfig = {
resolve: {
alias: {
'../format_service': resolve(__dirname, '../public/__mocks__/format_service.ts'),
},
},
};

module.exports = {
...defaultConfig,
webpackFinal: (config) => webpackMerge(config, mockConfig),
};

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,76 @@
import { tagcloudFunction } from './tagcloud_function';

import { functionWrapper } from '../../../../expressions/common/expression_functions/specs/tests/utils';
import { ExpressionValueVisDimension } from '../../../../visualizations/public';
import { Datatable } from '../../../../expressions/common/expression_types/specs';

describe('interpreter/functions#tagcloud', () => {
const fn = functionWrapper(tagcloudFunction());
const column1 = 'Count';
const column2 = 'country';
const context = {
type: 'datatable',
rows: [{ 'col-0-1': 0 }],
columns: [{ id: 'col-0-1', name: 'Count' }],
columns: [
{ id: column1, name: column1 },
{ id: column2, name: column2 },
],
rows: [
{ [column1]: 0, [column2]: 'US' },
{ [column1]: 10, [column2]: 'UK' },
],
};
const visConfig = {
scale: 'linear',
orientation: 'single',
minFontSize: 18,
maxFontSize: 72,
showLabel: true,
metric: { accessor: 0, format: { id: 'number' } },
bucket: { accessor: 1, format: { id: 'number' } },
};

it('returns an object with the correct structure', () => {
const actual = fn(context, visConfig, undefined);
const numberAccessors = {
metric: { accessor: 0 },
bucket: { accessor: 1 },
};

const stringAccessors: {
metric: ExpressionValueVisDimension;
bucket: ExpressionValueVisDimension;
} = {
metric: {
type: 'vis_dimension',
accessor: {
id: column1,
name: column1,
meta: {
type: 'number',
},
},
format: {
params: {},
},
},
bucket: {
type: 'vis_dimension',
accessor: {
id: column2,
name: column2,
meta: {
type: 'string',
},
},
format: {
params: {},
},
},
};

it('returns an object with the correct structure for number accessors', () => {
const actual = fn(context, { ...visConfig, ...numberAccessors }, undefined);
expect(actual).toMatchSnapshot();
});

it('returns an object with the correct structure for string accessors', () => {
const actual = fn(context, { ...visConfig, ...stringAccessors }, undefined);
expect(actual).toMatchSnapshot();
});

Expand All @@ -44,7 +93,7 @@ describe('interpreter/functions#tagcloud', () => {
},
},
};
await fn(context, visConfig, handlers as any);
await fn(context, { ...visConfig, ...numberAccessors }, handlers as any);

expect(loggedTable!).toMatchSnapshot();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import { i18n } from '@kbn/i18n';

import { prepareLogTable, Dimension } from '../../../../visualizations/common/prepare_log_table';
import { TagCloudVisParams } from '../types';
import { TagCloudRendererParams } from '../types';
import { ExpressionTagcloudFunction } from '../types';
import { EXPRESSION_NAME } from '../constants';

Expand Down Expand Up @@ -125,7 +125,7 @@ export const tagcloudFunction: ExpressionTagcloudFunction = () => {
},
},
fn(input, args, handlers) {
const visParams = {
const visParams: TagCloudRendererParams = {
scale: args.scale,
orientation: args.orientation,
minFontSize: args.minFontSize,
Expand All @@ -139,7 +139,7 @@ export const tagcloudFunction: ExpressionTagcloudFunction = () => {
type: 'palette',
name: args.palette,
},
} as TagCloudVisParams;
};

if (handlers?.inspectorAdapters?.tables) {
const argsTable: Dimension[] = [[[args.metric], dimension.tagSize]];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,10 @@ import {
Datatable,
ExpressionFunctionDefinition,
ExpressionValueRender,
SerializedFieldFormat,
} from '../../../../expressions';
import { ExpressionValueVisDimension } from '../../../../visualizations/common';
import { EXPRESSION_NAME } from '../constants';

interface Dimension {
accessor: number;
format: {
id?: string;
params?: SerializedFieldFormat<object>;
};
}

interface TagCloudCommonParams {
scale: 'linear' | 'log' | 'square root';
orientation: 'single' | 'right angled' | 'multiple';
Expand All @@ -36,16 +27,16 @@ export interface TagCloudVisConfig extends TagCloudCommonParams {
bucket?: ExpressionValueVisDimension;
}

export interface TagCloudVisParams extends TagCloudCommonParams {
export interface TagCloudRendererParams extends TagCloudCommonParams {
palette: PaletteOutput;
metric: Dimension;
bucket?: Dimension;
metric: ExpressionValueVisDimension;
bucket?: ExpressionValueVisDimension;
}

export interface TagcloudRendererConfig {
visType: typeof EXPRESSION_NAME;
visData: Datatable;
visParams: TagCloudVisParams;
visParams: TagCloudRendererParams;
syncColors: boolean;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

export const getFormatService = () => ({
deserialize: (target: any) => ({
convert: (text: string, format: string) => text,
}),
});
Loading

0 comments on commit d6ff363

Please sign in to comment.