Skip to content

Commit

Permalink
Merge branch 'master' into remove-unuses-server-uuid
Browse files Browse the repository at this point in the history
  • Loading branch information
elasticmachine authored May 19, 2020
2 parents e68d58f + d9d8777 commit e47e144
Show file tree
Hide file tree
Showing 7 changed files with 84 additions and 31 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@

# Canvas
/x-pack/plugins/canvas/ @elastic/kibana-canvas
/x-pack/test/functional/apps/canvas/ @elastic/kibana-canvas

# Observability UIs
/x-pack/legacy/plugins/infra/ @elastic/logs-metrics-ui
Expand Down

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 @@ -197,7 +197,8 @@ export const javaSettings: RawSettingDefinition[] = [
'The minimum duration of an inferred span. Note that the min duration is also implicitly set by the sampling interval. However, increasing the sampling interval also decreases the accuracy of the duration of inferred spans.'
}
),
includeAgents: ['java']
includeAgents: ['java'],
min: '0ms'
},
{
key: 'profiling_inferred_spans_included_classes',
Expand Down

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 @@ -14,6 +14,7 @@ import { createMockExecutionContext } from '../../../../../src/plugins/expressio
import { IFieldFormat } from '../../../../../src/plugins/data/public';
import { IAggType } from 'src/plugins/data/public';
const onClickValue = jest.fn();
import { EmptyPlaceholder } from '../shared_components';

function sampleArgs() {
const data: LensMultiTable = {
Expand All @@ -22,11 +23,11 @@ function sampleArgs() {
l1: {
type: 'kibana_datatable',
columns: [
{ id: 'a', name: 'a', meta: { type: 'count' } },
{ id: 'a', name: 'a', meta: { type: 'terms' } },
{ id: 'b', name: 'b', meta: { type: 'date_histogram', aggConfigParams: { field: 'b' } } },
{ id: 'c', name: 'c', meta: { type: 'cardinality' } },
{ id: 'c', name: 'c', meta: { type: 'count' } },
],
rows: [{ a: 10110, b: 1588024800000, c: 3 }],
rows: [{ a: 'shoes', b: 1588024800000, c: 3 }],
},
},
};
Expand Down Expand Up @@ -103,7 +104,7 @@ describe('datatable_expression', () => {
column: 0,
row: 0,
table: data.tables.l1,
value: 10110,
value: 'shoes',
},
],
negate: true,
Expand Down Expand Up @@ -148,5 +149,31 @@ describe('datatable_expression', () => {
timeFieldName: 'b',
});
});

test('it shows emptyPlaceholder for undefined bucketed data', () => {
const { args, data } = sampleArgs();
const emptyData: LensMultiTable = {
...data,
tables: {
l1: {
...data.tables.l1,
rows: [{ a: undefined, b: undefined, c: 0 }],
},
},
};

const component = shallow(
<DatatableComponent
data={emptyData}
args={args}
formatFactory={x => x as IFieldFormat}
onClickValue={onClickValue}
getType={jest.fn(type =>
type === 'count' ? ({ type: 'metrics' } as IAggType) : ({ type: 'buckets' } as IAggType)
)}
/>
);
expect(component.find(EmptyPlaceholder).prop('icon')).toEqual('visTable');
});
});
});
64 changes: 42 additions & 22 deletions x-pack/plugins/lens/public/datatable_visualization/expression.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/

import React from 'react';
import React, { useMemo } from 'react';
import ReactDOM from 'react-dom';
import { i18n } from '@kbn/i18n';
import { I18nProvider } from '@kbn/i18n/react';
Expand All @@ -21,6 +21,8 @@ import {
ExpressionRenderDefinition,
} from '../../../../../src/plugins/expressions/public';
import { VisualizationContainer } from '../visualization_container';
import { EmptyPlaceholder } from '../shared_components';

export interface DatatableColumns {
columnIds: string[];
}
Expand Down Expand Up @@ -158,26 +160,45 @@ export function DatatableComponent(props: DatatableRenderProps) {
formatters[column.id] = props.formatFactory(column.formatHint);
});

const handleFilterClick = (field: string, value: unknown, colIndex: number, negate = false) => {
const col = firstTable.columns[colIndex];
const isDateHistogram = col.meta?.type === 'date_histogram';
const timeFieldName = negate && isDateHistogram ? undefined : col?.meta?.aggConfigParams?.field;
const rowIndex = firstTable.rows.findIndex(row => row[field] === value);
const handleFilterClick = useMemo(
() => (field: string, value: unknown, colIndex: number, negate: boolean = false) => {
const col = firstTable.columns[colIndex];
const isDateHistogram = col.meta?.type === 'date_histogram';
const timeFieldName =
negate && isDateHistogram ? undefined : col?.meta?.aggConfigParams?.field;
const rowIndex = firstTable.rows.findIndex(row => row[field] === value);

const data: LensFilterEvent['data'] = {
negate,
data: [
{
row: rowIndex,
column: colIndex,
value,
table: firstTable,
},
],
timeFieldName,
};
props.onClickValue(data);
};
const data: LensFilterEvent['data'] = {
negate,
data: [
{
row: rowIndex,
column: colIndex,
value,
table: firstTable,
},
],
timeFieldName,
};
props.onClickValue(data);
},
[firstTable]
);

const bucketColumns = firstTable.columns
.filter(col => {
return col?.meta?.type && props.getType(col.meta.type)?.type === 'buckets';
})
.map(col => col.id);

const isEmpty =
firstTable.rows.length === 0 ||
(bucketColumns.length &&
firstTable.rows.every(row => bucketColumns.every(col => typeof row[col] === 'undefined')));

if (isEmpty) {
return <EmptyPlaceholder icon="visTable" />;
}

return (
<VisualizationContainer>
Expand All @@ -188,9 +209,8 @@ export function DatatableComponent(props: DatatableRenderProps) {
columns={props.args.columns.columnIds
.map(field => {
const col = firstTable.columns.find(c => c.id === field);
const filterable = bucketColumns.includes(field);
const colIndex = firstTable.columns.findIndex(c => c.id === field);

const filterable = col?.meta?.type && props.getType(col.meta.type)?.type === 'buckets';
return {
field,
name: (col && col.name) || '',
Expand Down
8 changes: 6 additions & 2 deletions x-pack/test/functional/page_objects/canvas_page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,12 @@ export function CanvasPageProvider({ getService }: FtrProviderContext) {

async fillOutCustomElementForm(name: string, description: string) {
// Fill out the custom element form and submit it
await testSubjects.setValue('canvasCustomElementForm-name', name);
await testSubjects.setValue('canvasCustomElementForm-description', description);
await testSubjects.setValue('canvasCustomElementForm-name', name, {
clearWithKeyboard: true,
});
await testSubjects.setValue('canvasCustomElementForm-description', description, {
clearWithKeyboard: true,
});

await testSubjects.click('canvasCustomElementForm-submit');
},
Expand Down

0 comments on commit e47e144

Please sign in to comment.