Skip to content

Commit

Permalink
Merge branch '7.5' into backport/7.5/pr-49670
Browse files Browse the repository at this point in the history
  • Loading branch information
elasticmachine authored Oct 29, 2019
2 parents cea17fd + d80895c commit 1fdecb1
Show file tree
Hide file tree
Showing 31 changed files with 424 additions and 290 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ export const ChartSection = ({
key={`series-${section.id}-${series.id}`}
id={`series-${section.id}-${series.id}`}
series={series}
name={getChartName(section, series.id, series.label)}
name={getChartName(section, series.id, series.id)}
type={getChartType(section, series.id)}
color={getChartColor(section, series.id)}
stack={visConfig.stacked}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,6 @@ export const AreaChart = ({ id, color, series, name, type, stack }: Props) => {
strokeWidth: InfraMetricLayoutVisualizationType.area === type ? 1 : 2,
visible: true,
},
point: {
visible: true,
radius: 1,
strokeWidth: 2,
opacity: 1,
},
};
const colors: DataSeriesColorsValues = {
colorValues: [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,6 @@ export const MetricsExplorerAreaChart = ({ metric, id, series, type, stack }: Pr
opacity: 0.5,
visible: type === MetricsExplorerChartType.area,
},
point: {
visible: true,
radius: 2,
strokeWidth: 2,
opacity: 1,
},
};
return (
<AreaSeries
Expand All @@ -87,7 +81,7 @@ export const MetricsExplorerAreaChart = ({ metric, id, series, type, stack }: Pr
);
};

export const MetricsExplorerBarChart = ({ metric, id, series, type, stack }: Props) => {
export const MetricsExplorerBarChart = ({ metric, id, series, stack }: Props) => {
const color =
(metric.color && colorTransformer(metric.color)) ||
colorTransformer(MetricsExplorerColor.color0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,20 @@
* you may not use this file except in compliance with the Elastic License.
*/

import React, { useMemo } from 'react';
import moment, { Moment } from 'moment';

import { i18n } from '@kbn/i18n';
import {
EuiDescribedFormGroup,
EuiFormRow,
EuiDatePicker,
EuiDatePickerProps,
EuiDescribedFormGroup,
EuiFlexGroup,
EuiFormControlLayout,
EuiFormRow,
} from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n/react';
import moment, { Moment } from 'moment';
import React, { useMemo } from 'react';

import { euiStyled } from '../../../../../../../../common/eui_styled_components';

const startTimeLabel = i18n.translate('xpack.infra.analysisSetup.startTimeLabel', {
defaultMessage: 'Start time',
Expand Down Expand Up @@ -84,7 +86,7 @@ export const AnalysisSetupTimerangeForm: React.FunctionComponent<{
<EuiFormControlLayout
clear={startTime ? { onClick: () => setStartTime(undefined) } : undefined}
>
<EuiDatePicker
<FixedDatePicker
showTimeSelect
selected={startTimeValue}
onChange={date => setStartTime(selectedDateToParam(date))}
Expand All @@ -105,7 +107,7 @@ export const AnalysisSetupTimerangeForm: React.FunctionComponent<{
<EuiFormControlLayout
clear={endTime ? { onClick: () => setEndTime(undefined) } : undefined}
>
<EuiDatePicker
<FixedDatePicker
showTimeSelect
selected={endTimeValue}
onChange={date => setEndTime(selectedDateToParam(date))}
Expand All @@ -129,3 +131,18 @@ export const AnalysisSetupTimerangeForm: React.FunctionComponent<{
</EuiDescribedFormGroup>
);
};

const FixedDatePicker = euiStyled(
({
className,
inputClassName,
...datePickerProps
}: {
className?: string;
inputClassName?: string;
} & EuiDatePickerProps) => (
<EuiDatePicker {...datePickerProps} className={inputClassName} popperClassName={className} />
)
)`
z-index: 3 !important;
`;
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { IndexPatternPrivateState } from './types';
import { mountWithIntl, shallowWithIntl } from 'test_utils/enzyme_helpers';
import { ChangeIndexPattern } from './change_indexpattern';
import { EuiProgress } from '@elastic/eui';
import { documentField } from './document_field';

jest.mock('ui/new_platform');
jest.mock('../../../../../../src/legacy/ui/public/registry/field_formats');
Expand Down Expand Up @@ -121,6 +122,7 @@ const initialState: IndexPatternPrivateState = {
aggregatable: true,
searchable: true,
},
documentField,
],
},
'2': {
Expand Down Expand Up @@ -174,6 +176,7 @@ const initialState: IndexPatternPrivateState = {
},
},
},
documentField,
],
},
'3': {
Expand All @@ -199,6 +202,7 @@ const initialState: IndexPatternPrivateState = {
aggregatable: true,
searchable: true,
},
documentField,
],
},
},
Expand Down Expand Up @@ -565,6 +569,7 @@ describe('IndexPattern Data Panel', () => {
);

expect(wrapper.find(FieldItem).map(fieldItem => fieldItem.prop('field').name)).toEqual([
'Records',
'bytes',
'client',
'memory',
Expand Down Expand Up @@ -630,6 +635,7 @@ describe('IndexPattern Data Panel', () => {
.simulate('click');

expect(wrapper.find(FieldItem).map(fieldItem => fieldItem.prop('field').name)).toEqual([
'Records',
'bytes',
'client',
'memory',
Expand Down Expand Up @@ -698,6 +704,7 @@ describe('IndexPattern Data Panel', () => {
const wrapper = shallowWithIntl(<InnerIndexPatternDataPanel {...props} />);

expect(wrapper.find(FieldItem).map(fieldItem => fieldItem.prop('field').name)).toEqual([
'Records',
'bytes',
'memory',
]);
Expand Down
69 changes: 53 additions & 16 deletions x-pack/legacy/plugins/lens/public/indexpattern_plugin/datapanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@ import {
EuiPopoverTitle,
EuiPopoverFooter,
EuiCallOut,
EuiText,
EuiFormControlLayout,
EuiSwitch,
EuiFacetButton,
EuiIcon,
EuiButton,
EuiButtonEmpty,
EuiSpacer,
EuiFormLabel,
} from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n/react';
Expand Down Expand Up @@ -60,10 +61,11 @@ function sortFields(fieldA: IndexPatternField, fieldB: IndexPatternField) {
return fieldA.name.localeCompare(fieldB.name, undefined, { sensitivity: 'base' });
}

const supportedFieldTypes = new Set(['string', 'number', 'boolean', 'date', 'ip']);
const supportedFieldTypes = new Set(['string', 'number', 'boolean', 'date', 'ip', 'document']);
const PAGINATION_SIZE = 50;

const fieldTypeNames: Record<DataType, string> = {
document: i18n.translate('xpack.lens.datatypes.record', { defaultMessage: 'record' }),
string: i18n.translate('xpack.lens.datatypes.string', { defaultMessage: 'string' }),
number: i18n.translate('xpack.lens.datatypes.number', { defaultMessage: 'number' }),
boolean: i18n.translate('xpack.lens.datatypes.boolean', { defaultMessage: 'boolean' }),
Expand Down Expand Up @@ -255,7 +257,8 @@ export const InnerIndexPatternDataPanel = function InnerIndexPatternDataPanel({
if (!showEmptyFields) {
const indexField = currentIndexPattern && fieldByName[field.name];
const exists =
indexField && fieldExists(existingFields, currentIndexPattern.title, indexField.name);
field.type === 'document' ||
(indexField && fieldExists(existingFields, currentIndexPattern.title, indexField.name));
if (localState.typeFilter.length > 0) {
return exists && localState.typeFilter.includes(field.type as DataType);
}
Expand All @@ -270,7 +273,12 @@ export const InnerIndexPatternDataPanel = function InnerIndexPatternDataPanel({
return true;
});

const paginatedFields = displayedFields.sort(sortFields).slice(0, pageSize);
const specialFields = displayedFields.filter(f => f.type === 'document');
const paginatedFields = displayedFields
.filter(f => f.type !== 'document')
.sort(sortFields)
.slice(0, pageSize);
const hilight = localState.nameFilter.toLowerCase();

return (
<ChildDragDropProvider {...dragDropContext}>
Expand Down Expand Up @@ -418,6 +426,31 @@ export const InnerIndexPatternDataPanel = function InnerIndexPatternDataPanel({
onScroll={lazyScroll}
>
<div className="lnsInnerIndexPatternDataPanel__list">
{specialFields.map(field => (
<FieldItem
core={core}
key={field.name}
indexPattern={currentIndexPattern}
field={field}
highlight={hilight}
exists={paginatedFields.length > 0}
dateRange={dateRange}
query={query}
filters={filters}
hideDetails={true}
/>
))}
{specialFields.length > 0 && (
<>
<EuiSpacer size="s" />
<EuiFormLabel>
{i18n.translate('xpack.lens.indexPattern.individualFieldsLabel', {
defaultMessage: 'Individual fields',
})}
</EuiFormLabel>
<EuiSpacer size="s" />
</>
)}
{paginatedFields.map(field => {
const overallField = fieldByName[field.name];
return (
Expand All @@ -426,7 +459,7 @@ export const InnerIndexPatternDataPanel = function InnerIndexPatternDataPanel({
indexPattern={currentIndexPattern}
key={field.name}
field={field}
highlight={localState.nameFilter.toLowerCase()}
highlight={hilight}
exists={
overallField &&
fieldExists(existingFields, currentIndexPattern.title, overallField.name)
Expand All @@ -439,9 +472,11 @@ export const InnerIndexPatternDataPanel = function InnerIndexPatternDataPanel({
})}

{paginatedFields.length === 0 && (
<EuiText size="s" color="subdued">
<p>
{showEmptyFields
<EuiCallOut
size="s"
color="warning"
title={
showEmptyFields
? localState.typeFilter.length || localState.nameFilter.length
? i18n.translate('xpack.lens.indexPatterns.noFilteredFieldsLabel', {
defaultMessage:
Expand All @@ -453,15 +488,17 @@ export const InnerIndexPatternDataPanel = function InnerIndexPatternDataPanel({
: i18n.translate('xpack.lens.indexPatterns.emptyFieldsWithDataLabel', {
defaultMessage:
'No fields have data with the current filters and time range. Try changing your filters or time range.',
})}
</p>

})
}
>
{(!showEmptyFields ||
localState.typeFilter.length ||
localState.nameFilter.length) && (
<EuiButton
<EuiButtonEmpty
size="xs"
color="primary"
flush="left"
data-test-subj="lnsDataPanelShowAllFields"
size="s"
onClick={() => {
trackUiEvent('indexpattern_show_all_fields_clicked');
clearLocalState();
Expand All @@ -471,9 +508,9 @@ export const InnerIndexPatternDataPanel = function InnerIndexPatternDataPanel({
{i18n.translate('xpack.lens.indexPatterns.showAllFields.buttonText', {
defaultMessage: 'Show all fields',
})}
</EuiButton>
</EuiButtonEmpty>
)}
</EuiText>
</EuiCallOut>
)}
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ import {
} from 'src/core/public';
import { Storage } from 'ui/storage';
import { IndexPatternPrivateState } from '../types';
import { documentField } from '../document_field';

jest.mock('ui/new_platform');
jest.mock('../loader');
jest.mock('../state_helpers');
jest.mock('../operations');

// Used by indexpattern plugin, which is a dependency of a dependency
jest.mock('ui/chrome');
Expand Down Expand Up @@ -67,6 +67,7 @@ const expectedIndexPatterns = {
searchable: true,
exists: true,
},
documentField,
],
},
};
Expand Down Expand Up @@ -200,7 +201,7 @@ describe('IndexPatternDimensionPanel', () => {

expect(options).toHaveLength(2);

expect(options![0].label).toEqual('Document');
expect(options![0].label).toEqual('Records');

expect(options![1].options!.map(({ label }) => label)).toEqual([
'timestamp',
Expand Down Expand Up @@ -232,7 +233,7 @@ describe('IndexPatternDimensionPanel', () => {
expect(options![1].options!.map(({ label }) => label)).toEqual(['timestamp', 'source']);
});

it('should indicate fields which are imcompatible for the operation of the current column', () => {
it('should indicate fields which are incompatible for the operation of the current column', () => {
wrapper = mount(
<IndexPatternDimensionPanel
{...defaultProps}
Expand Down Expand Up @@ -263,7 +264,7 @@ describe('IndexPatternDimensionPanel', () => {

const options = wrapper.find(EuiComboBox).prop('options');

expect(options![0]['data-test-subj']).toEqual('lns-documentOptionIncompatible');
expect(options![0]['data-test-subj']).toEqual('lns-fieldOptionIncompatible-Records');

expect(
options![1].options!.filter(({ label }) => label === 'timestamp')[0]['data-test-subj']
Expand Down Expand Up @@ -659,6 +660,7 @@ describe('IndexPatternDimensionPanel', () => {
isBucketed: false,
label: '',
operationType: 'count',
sourceField: 'Records',
},
},
},
Expand Down Expand Up @@ -853,6 +855,7 @@ describe('IndexPatternDimensionPanel', () => {
isBucketed: false,
label: '',
operationType: 'count',
sourceField: 'Records',
},
},
},
Expand Down
Loading

0 comments on commit 1fdecb1

Please sign in to comment.