;
}
-export function FieldName({ field, fieldName, fieldType, useShortDots }: Props) {
+export function FieldName({ field, fieldName, fieldType, useShortDots, fieldIconProps }: Props) {
const type = field ? String(field.type) : String(fieldType);
const typeName = getFieldTypeName(type);
const name = field ? String(field.name) : String(fieldName);
const displayName = useShortDots ? shortenDottedString(name) : name;
- const className = classNames({
- 'dscField--noResults': field ? !field.rowCount && !field.scripted : false,
- // this is currently not styled, should display an icon
- scripted: field ? field.scripted : false,
+ const noResults = field ? !field.rowCount && !field.scripted : false;
+
+ const className = classNames('dscFieldName', {
+ 'dscFieldName--noResults': noResults,
});
return (
-
-
- {displayName}
-
+
+
+
+
+
+ {displayName}
+
+
);
}
diff --git a/src/legacy/core_plugins/kibana/public/discover/np_ready/components/field_chooser/_field_chooser.scss b/src/legacy/core_plugins/kibana/public/discover/np_ready/components/field_chooser/_field_chooser.scss
index fe13ac2fafa01..b05775c4ee95c 100644
--- a/src/legacy/core_plugins/kibana/public/discover/np_ready/components/field_chooser/_field_chooser.scss
+++ b/src/legacy/core_plugins/kibana/public/discover/np_ready/components/field_chooser/_field_chooser.scss
@@ -10,7 +10,6 @@
.dscFieldName {
color: $euiColorDarkShade;
- padding-left: $euiSizeS;
}
diff --git a/src/legacy/core_plugins/kibana/public/discover/np_ready/components/table/table_row.tsx b/src/legacy/core_plugins/kibana/public/discover/np_ready/components/table/table_row.tsx
index 7a78e89416361..5b13f6b3655c3 100644
--- a/src/legacy/core_plugins/kibana/public/discover/np_ready/components/table/table_row.tsx
+++ b/src/legacy/core_plugins/kibana/public/discover/np_ready/components/table/table_row.tsx
@@ -87,7 +87,12 @@ export function DocViewTableRow({
)}
-
+
|
{isCollapsible && (
diff --git a/src/plugins/kibana_react/public/field_icon/__snapshots__/field_icon.test.tsx.snap b/src/plugins/kibana_react/public/field_icon/__snapshots__/field_icon.test.tsx.snap
index 870dbdc533267..cde6a625ac8e8 100644
--- a/src/plugins/kibana_react/public/field_icon/__snapshots__/field_icon.test.tsx.snap
+++ b/src/plugins/kibana_react/public/field_icon/__snapshots__/field_icon.test.tsx.snap
@@ -1,37 +1,159 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
-exports[`FieldIcon renders a blackwhite icon for a string 1`] = `
-
`;
-exports[`FieldIcon renders a colored icon for a number 1`] = `
-
`;
-exports[`FieldIcon renders an icon for an unknown type 1`] = `
-
+`;
+
+exports[`FieldIcon renders known field types boolean is rendered 1`] = `
+
+`;
+
+exports[`FieldIcon renders known field types conflict is rendered 1`] = `
+
+`;
+
+exports[`FieldIcon renders known field types date is rendered 1`] = `
+
+`;
+
+exports[`FieldIcon renders known field types geo_point is rendered 1`] = `
+
+`;
+
+exports[`FieldIcon renders known field types geo_shape is rendered 1`] = `
+
+`;
+
+exports[`FieldIcon renders known field types ip is rendered 1`] = `
+
+`;
+
+exports[`FieldIcon renders known field types murmur3 is rendered 1`] = `
+
+`;
+
+exports[`FieldIcon renders known field types nested is rendered 1`] = `
+
+`;
+
+exports[`FieldIcon renders known field types number is rendered 1`] = `
+
+`;
+
+exports[`FieldIcon renders known field types string is rendered 1`] = `
+
`;
exports[`FieldIcon renders with className if provided 1`] = `
-
+`;
+
+exports[`FieldIcon supports same props as EuiToken 1`] = `
+
`;
diff --git a/src/plugins/kibana_react/public/field_icon/field_icon.test.tsx b/src/plugins/kibana_react/public/field_icon/field_icon.test.tsx
index 90a858e31b4f3..51ff5f603ea37 100644
--- a/src/plugins/kibana_react/public/field_icon/field_icon.test.tsx
+++ b/src/plugins/kibana_react/public/field_icon/field_icon.test.tsx
@@ -18,24 +18,44 @@
*/
import React from 'react';
import { shallow } from 'enzyme';
-import { FieldIcon } from './field_icon';
+import { FieldIcon, typeToEuiIconMap } from './field_icon';
-test('FieldIcon renders a blackwhite icon for a string', () => {
- const component = shallow();
+const availableTypes = Object.keys(typeToEuiIconMap);
+
+describe('FieldIcon renders known field types', () => {
+ availableTypes.forEach(type => {
+ test(`${type} is rendered`, () => {
+ const component = shallow();
+ expect(component).toMatchSnapshot();
+ });
+ });
+});
+
+test('FieldIcon renders an icon for an unknown type', () => {
+ const component = shallow();
expect(component).toMatchSnapshot();
});
-test('FieldIcon renders a colored icon for a number', () => {
- const component = shallow();
+test('FieldIcon supports same props as EuiToken', () => {
+ const component = shallow(
+
+ );
expect(component).toMatchSnapshot();
});
-test('FieldIcon renders an icon for an unknown type', () => {
- const component = shallow();
+test('FieldIcon changes fill when scripted is true', () => {
+ const component = shallow();
expect(component).toMatchSnapshot();
});
test('FieldIcon renders with className if provided', () => {
- const component = shallow();
+ const component = shallow();
expect(component).toMatchSnapshot();
});
diff --git a/src/plugins/kibana_react/public/field_icon/field_icon.tsx b/src/plugins/kibana_react/public/field_icon/field_icon.tsx
index 2e199a7471a64..2da1eba31e254 100644
--- a/src/plugins/kibana_react/public/field_icon/field_icon.tsx
+++ b/src/plugins/kibana_react/public/field_icon/field_icon.tsx
@@ -17,14 +17,10 @@
* under the License.
*/
import React from 'react';
-import { euiPaletteColorBlind, EuiIcon } from '@elastic/eui';
-import { IconSize } from '@elastic/eui/src/components/icon/icon';
+import classNames from 'classnames';
+import { EuiToken, EuiTokenProps } from '@elastic/eui';
-interface IconMapEntry {
- icon: string;
- color: string;
-}
-interface FieldIconProps {
+export interface FieldIconProps extends Omit {
type:
| 'boolean'
| 'conflict'
@@ -39,51 +35,50 @@ interface FieldIconProps {
| string
| 'nested';
label?: string;
- size?: IconSize;
- useColor?: boolean;
- className?: string;
+ scripted?: boolean;
}
-const colors = euiPaletteColorBlind();
-
// defaultIcon => a unknown datatype
-const defaultIcon = { icon: 'questionInCircle', color: colors[0] };
+const defaultIcon = { iconType: 'questionInCircle', color: 'gray' };
-export const typeToEuiIconMap: Partial> = {
- boolean: { icon: 'invert', color: colors[5] },
+export const typeToEuiIconMap: Partial> = {
+ boolean: { iconType: 'tokenBoolean' },
// icon for an index pattern mapping conflict in discover
- conflict: { icon: 'alert', color: colors[8] },
- date: { icon: 'calendar', color: colors[7] },
- geo_point: { icon: 'globe', color: colors[2] },
- geo_shape: { icon: 'globe', color: colors[2] },
- ip: { icon: 'storage', color: colors[8] },
+ conflict: { iconType: 'alert', color: 'euiVisColor9' },
+ date: { iconType: 'tokenDate' },
+ geo_point: { iconType: 'tokenGeo' },
+ geo_shape: { iconType: 'tokenGeo' },
+ ip: { iconType: 'tokenIP' },
// is a plugin's data type https://www.elastic.co/guide/en/elasticsearch/plugins/current/mapper-murmur3-usage.html
- murmur3: { icon: 'document', color: colors[1] },
- number: { icon: 'number', color: colors[0] },
- _source: { icon: 'editorCodeBlock', color: colors[3] },
- string: { icon: 'string', color: colors[4] },
- nested: { icon: 'nested', color: colors[2] },
+ murmur3: { iconType: 'tokenFile' },
+ number: { iconType: 'tokenNumber' },
+ _source: { iconType: 'editorCodeBlock', color: 'gray' },
+ string: { iconType: 'tokenString' },
+ nested: { iconType: 'tokenNested' },
};
/**
- * Field icon used across the app
+ * Field token icon used across the app
*/
export function FieldIcon({
type,
label,
size = 's',
- useColor = false,
- className = undefined,
+ scripted,
+ className,
+ ...rest
}: FieldIconProps) {
- const euiIcon = typeToEuiIconMap[type] || defaultIcon;
+ const token = typeToEuiIconMap[type] || defaultIcon;
return (
-
);
}
diff --git a/x-pack/legacy/plugins/graph/public/components/field_manager/field_editor.tsx b/x-pack/legacy/plugins/graph/public/components/field_manager/field_editor.tsx
index 6152f33350917..f2a4c28afcdae 100644
--- a/x-pack/legacy/plugins/graph/public/components/field_manager/field_editor.tsx
+++ b/x-pack/legacy/plugins/graph/public/components/field_manager/field_editor.tsx
@@ -237,10 +237,18 @@ export function FieldEditor({
renderOption={(option, searchValue, contentClassName) => {
const { type, label } = option;
return (
-
- {' '}
- {label}
-
+
+
+
+
+
+ {label}
+
+
);
}}
compressed
diff --git a/x-pack/legacy/plugins/graph/public/components/field_manager/field_icon.tsx b/x-pack/legacy/plugins/graph/public/components/field_manager/field_icon.tsx
deleted file mode 100644
index 0c099135f631d..0000000000000
--- a/x-pack/legacy/plugins/graph/public/components/field_manager/field_icon.tsx
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License;
- * you may not use this file except in compliance with the Elastic License.
- */
-
-import React from 'react';
-import { ICON_TYPES, euiPaletteColorBlind, EuiIcon } from '@elastic/eui';
-
-function stringToNum(s: string) {
- return Array.from(s).reduce((acc, ch) => acc + ch.charCodeAt(0), 1);
-}
-
-function getIconForDataType(dataType: string) {
- const icons: Partial>> = {
- boolean: 'invert',
- date: 'calendar',
- geo_point: 'globe',
- ip: 'storage',
- };
- return icons[dataType] || ICON_TYPES.find(t => t === dataType) || 'document';
-}
-
-export function getColorForDataType(type: string) {
- const iconType = getIconForDataType(type);
- const colors = euiPaletteColorBlind();
- const colorIndex = stringToNum(iconType) % colors.length;
- return colors[colorIndex];
-}
-
-export type UnwrapArray = T extends Array ? P : T;
-
-export function FieldIcon({ type }: { type: string }) {
- const iconType = getIconForDataType(type);
-
- return ;
-}
diff --git a/x-pack/legacy/plugins/graph/public/components/field_manager/field_picker.tsx b/x-pack/legacy/plugins/graph/public/components/field_manager/field_picker.tsx
index b38e3f8430980..30f1fcffd4f67 100644
--- a/x-pack/legacy/plugins/graph/public/components/field_manager/field_picker.tsx
+++ b/x-pack/legacy/plugins/graph/public/components/field_manager/field_picker.tsx
@@ -122,7 +122,7 @@ function toOptions(
.filter(field => isExplorable(field) || field.selected)
.map(field => ({
label: field.name,
- prepend: ,
+ prepend: ,
checked: field.selected ? 'on' : undefined,
}))
);
diff --git a/x-pack/legacy/plugins/lens/public/indexpattern_datasource/__snapshots__/lens_field_icon.test.tsx.snap b/x-pack/legacy/plugins/lens/public/indexpattern_datasource/__snapshots__/lens_field_icon.test.tsx.snap
index 5593a1af00d70..8bbe49b2e0d7f 100644
--- a/x-pack/legacy/plugins/lens/public/indexpattern_datasource/__snapshots__/lens_field_icon.test.tsx.snap
+++ b/x-pack/legacy/plugins/lens/public/indexpattern_datasource/__snapshots__/lens_field_icon.test.tsx.snap
@@ -1,10 +1,16 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
+exports[`LensFieldIcon accepts FieldIcon props 1`] = `
+
+`;
+
exports[`LensFieldIcon renders properly 1`] = `
`;
diff --git a/x-pack/legacy/plugins/lens/public/indexpattern_datasource/_datapanel.scss b/x-pack/legacy/plugins/lens/public/indexpattern_datasource/_datapanel.scss
index ed39beeb7d088..77d4b41a0413c 100644
--- a/x-pack/legacy/plugins/lens/public/indexpattern_datasource/_datapanel.scss
+++ b/x-pack/legacy/plugins/lens/public/indexpattern_datasource/_datapanel.scss
@@ -52,3 +52,16 @@
@include euiFormControlLayoutPadding(1, 'right');
@include euiFormControlLayoutPadding(1, 'left');
}
+
+.lnsInnerIndexPatternDataPanel__filterType {
+ padding: $euiSizeS;
+}
+
+.lnsInnerIndexPatternDataPanel__filterTypeInner {
+ display: flex;
+ align-items: center;
+
+ .lnsFieldListPanel__fieldIcon {
+ margin-right: $euiSizeS;
+ }
+}
diff --git a/x-pack/legacy/plugins/lens/public/indexpattern_datasource/_field_item.scss b/x-pack/legacy/plugins/lens/public/indexpattern_datasource/_field_item.scss
index 54f9a3787466d..89f6bbf908419 100644
--- a/x-pack/legacy/plugins/lens/public/indexpattern_datasource/_field_item.scss
+++ b/x-pack/legacy/plugins/lens/public/indexpattern_datasource/_field_item.scss
@@ -14,7 +14,7 @@
}
.lnsFieldItem--missing {
- background: lightOrDarkTheme(transparentize($euiColorMediumShade, .9), $euiColorEmptyShade);
+ background: lightOrDarkTheme(transparentize($euiColorMediumShade, 0.9), $euiColorEmptyShade);
color: $euiColorDarkShade;
}
@@ -24,10 +24,10 @@
display: flex;
align-items: flex-start;
transition: box-shadow $euiAnimSpeedFast $euiAnimSlightResistance,
- background-color $euiAnimSpeedFast $euiAnimSlightResistance; // sass-lint:disable-line indentation
+ background-color $euiAnimSpeedFast $euiAnimSlightResistance; // sass-lint:disable-line indentation
.lnsFieldItem__name {
- margin-left: $euiSizeXS;
+ margin-left: $euiSizeS;
flex-grow: 1;
}
@@ -37,7 +37,8 @@
}
.lnsFieldListPanel__fieldIcon {
- margin-top: 2px;
+ margin-top: $euiSizeXS / 2;
+ margin-right: $euiSizeXS / 2;
}
.lnsFieldItem__infoIcon {
diff --git a/x-pack/legacy/plugins/lens/public/indexpattern_datasource/datapanel.tsx b/x-pack/legacy/plugins/lens/public/indexpattern_datasource/datapanel.tsx
index 3231ab7d7ff12..69982aed78b40 100644
--- a/x-pack/legacy/plugins/lens/public/indexpattern_datasource/datapanel.tsx
+++ b/x-pack/legacy/plugins/lens/public/indexpattern_datasource/datapanel.tsx
@@ -384,6 +384,7 @@ export const InnerIndexPatternDataPanel = function InnerIndexPatternDataPanel({
data-test-subj="lnsIndexPatternTypeFilterOptions"
items={(availableFieldTypes as DataType[]).map(type => (
- {fieldTypeNames[type]}
+
+ {fieldTypeNames[type]}
+
))}
/>
diff --git a/x-pack/legacy/plugins/lens/public/indexpattern_datasource/dimension_panel/field_select.tsx b/x-pack/legacy/plugins/lens/public/indexpattern_datasource/dimension_panel/field_select.tsx
index 46d7233ba9587..77435fcdf3eed 100644
--- a/x-pack/legacy/plugins/lens/public/indexpattern_datasource/dimension_panel/field_select.tsx
+++ b/x-pack/legacy/plugins/lens/public/indexpattern_datasource/dimension_panel/field_select.tsx
@@ -169,6 +169,7 @@ export function FieldSelect({
diff --git a/x-pack/legacy/plugins/lens/public/indexpattern_datasource/field_icon.test.tsx b/x-pack/legacy/plugins/lens/public/indexpattern_datasource/field_icon.test.tsx
deleted file mode 100644
index 6b12bb5feef1b..0000000000000
--- a/x-pack/legacy/plugins/lens/public/indexpattern_datasource/field_icon.test.tsx
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License;
- * you may not use this file except in compliance with the Elastic License.
- */
-
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License;
- * you may not use this file except in compliance with the Elastic License.
- */
-
-import { shallow } from 'enzyme';
-import React from 'react';
-import { FieldIcon } from './field_icon';
-
-describe('FieldIcon', () => {
- it('should render icons', () => {
- expect(shallow()).toMatchInlineSnapshot(`
-
- `);
- expect(shallow()).toMatchInlineSnapshot(`
-
- `);
- expect(shallow()).toMatchInlineSnapshot(`
-
- `);
- expect(shallow()).toMatchInlineSnapshot(`
-
- `);
- expect(shallow()).toMatchInlineSnapshot(`
-
- `);
- });
-});
diff --git a/x-pack/legacy/plugins/lens/public/indexpattern_datasource/field_icon.tsx b/x-pack/legacy/plugins/lens/public/indexpattern_datasource/field_icon.tsx
deleted file mode 100644
index 796f200bffd97..0000000000000
--- a/x-pack/legacy/plugins/lens/public/indexpattern_datasource/field_icon.tsx
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License;
- * you may not use this file except in compliance with the Elastic License.
- */
-
-import React from 'react';
-import { ICON_TYPES, euiPaletteColorBlind, EuiIcon } from '@elastic/eui';
-import classNames from 'classnames';
-import { DataType } from '../types';
-
-function stringToNum(s: string) {
- return Array.from(s).reduce((acc, ch) => acc + ch.charCodeAt(0), 1);
-}
-
-function getIconForDataType(dataType: string) {
- const icons: Partial>> = {
- boolean: 'invert',
- date: 'calendar',
- ip: 'ip',
- };
- return icons[dataType] || ICON_TYPES.find(t => t === dataType) || 'empty';
-}
-
-export function getColorForDataType(type: string) {
- const iconType = getIconForDataType(type);
- const colors = euiPaletteColorBlind();
- const colorIndex = stringToNum(iconType) % colors.length;
- return colors[colorIndex];
-}
-
-export type UnwrapArray = T extends Array ? P : T;
-
-export function FieldIcon({ type }: { type: DataType }) {
- const iconType = getIconForDataType(type);
-
- const classes = classNames(
- 'lnsFieldListPanel__fieldIcon',
- `lnsFieldListPanel__fieldIcon--${type}`
- );
-
- return ;
-}
diff --git a/x-pack/legacy/plugins/lens/public/indexpattern_datasource/field_item.tsx b/x-pack/legacy/plugins/lens/public/indexpattern_datasource/field_item.tsx
index 0271d2ca021c5..94d644e6590e1 100644
--- a/x-pack/legacy/plugins/lens/public/indexpattern_datasource/field_item.tsx
+++ b/x-pack/legacy/plugins/lens/public/indexpattern_datasource/field_item.tsx
@@ -46,7 +46,7 @@ import { DragDrop } from '../drag_drop';
import { DatasourceDataPanelProps, DataType } from '../types';
import { BucketedAggregation, FieldStatsResponse } from '../../../../../plugins/lens/common';
import { IndexPattern, IndexPatternField } from './types';
-import { getColorForDataType, LensFieldIcon } from './lens_field_icon';
+import { LensFieldIcon } from './lens_field_icon';
import { trackUiEvent } from '../lens_ui_telemetry';
export interface FieldItemProps {
@@ -294,11 +294,6 @@ function FieldItemPopoverContents(props: State & FieldItemProps) {
);
}
- const euiButtonColor =
- field.type === 'string' ? 'accent' : field.type === 'number' ? 'secondary' : 'primary';
- const euiTextColor =
- field.type === 'string' ? 'accent' : field.type === 'number' ? 'secondary' : 'default';
-
const fromDate = DateMath.parse(dateRange.fromDate);
const toDate = DateMath.parse(dateRange.toDate);
@@ -391,8 +386,6 @@ function FieldItemPopoverContents(props: State & FieldItemProps) {
const specId = i18n.translate('xpack.lens.indexPattern.fieldStatsCountLabel', {
defaultMessage: 'Count',
});
- const expectedColor = getColorForDataType(field.type);
- const seriesColors = expectedColor ? [expectedColor] : undefined;
if (field.type === 'date') {
return wrapInPopover(
@@ -429,7 +422,6 @@ function FieldItemPopoverContents(props: State & FieldItemProps) {
yAccessors={['count']}
xScaleType={ScaleType.Time}
yScaleType={ScaleType.Linear}
- customSeriesColors={seriesColors}
timeZone="local"
/>
@@ -453,7 +445,6 @@ function FieldItemPopoverContents(props: State & FieldItemProps) {
yAccessors={['count']}
xScaleType={ScaleType.Linear}
yScaleType={ScaleType.Linear}
- customSeriesColors={seriesColors}
/>
);
@@ -486,7 +477,7 @@ function FieldItemPopoverContents(props: State & FieldItemProps) {
)}
-
+
{Math.round((topValue.count / props.sampledValues!) * 100)}%
@@ -497,7 +488,7 @@ function FieldItemPopoverContents(props: State & FieldItemProps) {
value={topValue.count / props.sampledValues!}
max={1}
size="s"
- color={euiButtonColor}
+ color="accent"
/>
);
diff --git a/x-pack/legacy/plugins/lens/public/indexpattern_datasource/lens_field_icon.test.tsx b/x-pack/legacy/plugins/lens/public/indexpattern_datasource/lens_field_icon.test.tsx
index 961e22380bdca..317ce8f032f94 100644
--- a/x-pack/legacy/plugins/lens/public/indexpattern_datasource/lens_field_icon.test.tsx
+++ b/x-pack/legacy/plugins/lens/public/indexpattern_datasource/lens_field_icon.test.tsx
@@ -11,19 +11,14 @@
*/
import React from 'react';
import { shallow } from 'enzyme';
-import { LensFieldIcon, getColorForDataType } from './lens_field_icon';
+import { LensFieldIcon } from './lens_field_icon';
test('LensFieldIcon renders properly', () => {
const component = shallow();
expect(component).toMatchSnapshot();
});
-test('LensFieldIcon getColorForDataType for a valid type', () => {
- const color = getColorForDataType('date');
- expect(color).toEqual('#DA8B45');
-});
-
-test('LensFieldIcon getColorForDataType for an invalid type', () => {
- const color = getColorForDataType('invalid');
- expect(color).toEqual('#54B399');
+test('LensFieldIcon accepts FieldIcon props', () => {
+ const component = shallow();
+ expect(component).toMatchSnapshot();
});
diff --git a/x-pack/legacy/plugins/lens/public/indexpattern_datasource/lens_field_icon.tsx b/x-pack/legacy/plugins/lens/public/indexpattern_datasource/lens_field_icon.tsx
index 2e6a5fcd8115f..06eda73748cef 100644
--- a/x-pack/legacy/plugins/lens/public/indexpattern_datasource/lens_field_icon.tsx
+++ b/x-pack/legacy/plugins/lens/public/indexpattern_datasource/lens_field_icon.tsx
@@ -5,26 +5,16 @@
*/
import React from 'react';
-import { euiPaletteColorBlind } from '@elastic/eui';
-import { FieldIcon, typeToEuiIconMap } from '../../../../../../src/plugins/kibana_react/public';
+import { FieldIcon, FieldIconProps } from '../../../../../../src/plugins/kibana_react/public';
import { DataType } from '../types';
import { normalizeOperationDataType } from './utils';
-export function getColorForDataType(type: string) {
- const iconMap = typeToEuiIconMap[normalizeOperationDataType(type as DataType)];
- if (iconMap) {
- return iconMap.color;
- }
- return euiPaletteColorBlind()[0];
-}
-
-export function LensFieldIcon({ type }: { type: DataType }) {
+export function LensFieldIcon({ type, ...rest }: FieldIconProps & { type: DataType }) {
return (
);
}
diff --git a/x-pack/legacy/plugins/maps/public/components/__snapshots__/add_tooltip_field_popover.test.js.snap b/x-pack/legacy/plugins/maps/public/components/__snapshots__/add_tooltip_field_popover.test.js.snap
index f37dfdd879c5b..d0cdbe7243abe 100644
--- a/x-pack/legacy/plugins/maps/public/components/__snapshots__/add_tooltip_field_popover.test.js.snap
+++ b/x-pack/legacy/plugins/maps/public/components/__snapshots__/add_tooltip_field_popover.test.js.snap
@@ -23,7 +23,7 @@ exports[`Should remove selected fields from selectable 1`] = `
id="addTooltipFieldPopover"
isOpen={false}
ownFocus={true}
- panelPaddingSize="m"
+ panelPaddingSize="none"
>
,
"value": "@timestamp",
},
]
}
+ searchProps={
+ Object {
+ "compressed": true,
+ }
+ }
searchable={true}
singleSelection={false}
>
@@ -88,7 +93,7 @@ exports[`Should render 1`] = `
id="addTooltipFieldPopover"
isOpen={false}
ownFocus={true}
- panelPaddingSize="m"
+ panelPaddingSize="none"
>
,
"value": "@timestamp",
},
Object {
"label": "custom label for prop1",
"prepend": ,
"value": "prop1",
},
Object {
"label": "prop2",
"prepend": ,
"value": "prop2",
},
]
}
+ searchProps={
+ Object {
+ "compressed": true,
+ }
+ }
searchable={true}
singleSelection={false}
>
diff --git a/x-pack/legacy/plugins/maps/public/components/add_tooltip_field_popover.js b/x-pack/legacy/plugins/maps/public/components/add_tooltip_field_popover.js
index bddb74596f4ef..07bc54663c1d8 100644
--- a/x-pack/legacy/plugins/maps/public/components/add_tooltip_field_popover.js
+++ b/x-pack/legacy/plugins/maps/public/components/add_tooltip_field_popover.js
@@ -39,7 +39,10 @@ function getOptions(fields, selectedFields) {
.map(field => {
return {
value: field.name,
- prepend: 'type' in field ? : null,
+ prepend:
+ 'type' in field ? (
+
+ ) : null,
label: 'label' in field ? field.label : field.name,
};
})
@@ -127,7 +130,12 @@ export class AddTooltipFieldPopover extends Component {
return (
-
+
{(list, search) => (
{search}
@@ -161,6 +169,7 @@ export class AddTooltipFieldPopover extends Component {
button={this._renderAddButton()}
isOpen={this.state.isPopoverOpen}
closePopover={this._closePopover}
+ panelPaddingSize="none"
ownFocus
>
{this._renderContent()}
diff --git a/x-pack/legacy/plugins/maps/public/components/single_field_select.js b/x-pack/legacy/plugins/maps/public/components/single_field_select.js
index 7351ce7691a82..98e33454b041b 100644
--- a/x-pack/legacy/plugins/maps/public/components/single_field_select.js
+++ b/x-pack/legacy/plugins/maps/public/components/single_field_select.js
@@ -8,7 +8,7 @@ import _ from 'lodash';
import PropTypes from 'prop-types';
import React from 'react';
-import { EuiComboBox, EuiHighlight } from '@elastic/eui';
+import { EuiComboBox, EuiHighlight, EuiFlexGroup, EuiFlexItem } from '@elastic/eui';
import { FieldIcon } from '../../../../../../src/plugins/kibana_react/public';
function fieldsToOptions(fields) {
@@ -30,11 +30,14 @@ function fieldsToOptions(fields) {
function renderOption(option, searchValue, contentClassName) {
return (
-
-
-
- {option.label}
-
+
+
+
+
+
+ {option.label}
+
+
);
}
diff --git a/x-pack/legacy/plugins/maps/public/layers/styles/vector/components/field_select.js b/x-pack/legacy/plugins/maps/public/layers/styles/vector/components/field_select.js
index a32c2ce04d735..cf0ec5589d6bc 100644
--- a/x-pack/legacy/plugins/maps/public/layers/styles/vector/components/field_select.js
+++ b/x-pack/legacy/plugins/maps/public/layers/styles/vector/components/field_select.js
@@ -7,18 +7,21 @@
import PropTypes from 'prop-types';
import React from 'react';
-import { EuiComboBox, EuiHighlight } from '@elastic/eui';
+import { EuiComboBox, EuiHighlight, EuiFlexGroup, EuiFlexItem } from '@elastic/eui';
import { FIELD_ORIGIN } from '../../../../../common/constants';
import { i18n } from '@kbn/i18n';
import { FieldIcon } from '../../../../../../../../../src/plugins/kibana_react/public';
function renderOption(option, searchValue, contentClassName) {
return (
-
-
-
- {option.label}
-
+
+
+
+
+
+ {option.label}
+
+
);
}
From 9c8c47befb177ba9fd5e4a102ae363140e2668a7 Mon Sep 17 00:00:00 2001
From: Aaron Caldwell
Date: Fri, 21 Feb 2020 16:37:39 -0700
Subject: [PATCH 2/2] [File upload] Update remaining File Upload dependencies
for NP migration (#58128)
* Remove old route ref, no longer used
* Use core elasticsearch service
* Remove getSavedObjectsRepository, use NP internalRepository
* Update tests and clean up
* Remove unused test vars
---
x-pack/legacy/plugins/file_upload/index.js | 22 ++++-------
.../call_with_internal_user_factory.d.ts | 7 ----
.../client/call_with_internal_user_factory.js | 18 ---------
.../call_with_internal_user_factory.test.ts | 22 -----------
.../client/call_with_request_factory.js | 15 ++++---
.../server/kibana_server_services.js | 18 +++++++++
.../plugins/file_upload/server/plugin.js | 22 ++++++-----
.../file_upload/server/routes/file_upload.js | 10 ++---
.../telemetry/file_upload_usage_collector.ts | 12 +-----
.../server/telemetry/telemetry.test.ts | 10 +----
.../file_upload/server/telemetry/telemetry.ts | 39 ++++---------------
11 files changed, 63 insertions(+), 132 deletions(-)
delete mode 100644 x-pack/legacy/plugins/file_upload/server/client/call_with_internal_user_factory.d.ts
delete mode 100644 x-pack/legacy/plugins/file_upload/server/client/call_with_internal_user_factory.js
delete mode 100644 x-pack/legacy/plugins/file_upload/server/client/call_with_internal_user_factory.test.ts
create mode 100644 x-pack/legacy/plugins/file_upload/server/kibana_server_services.js
diff --git a/x-pack/legacy/plugins/file_upload/index.js b/x-pack/legacy/plugins/file_upload/index.js
index d29226c802b06..23e1e1d98aa7f 100644
--- a/x-pack/legacy/plugins/file_upload/index.js
+++ b/x-pack/legacy/plugins/file_upload/index.js
@@ -8,9 +8,10 @@ import { mappings } from './mappings';
export const fileUpload = kibana => {
return new kibana.Plugin({
- require: ['elasticsearch', 'xpack_main'],
+ require: ['elasticsearch'],
name: 'file_upload',
id: 'file_upload',
+ // TODO: uiExports and savedObjectSchemas to be removed on migration
uiExports: {
mappings,
},
@@ -22,23 +23,14 @@ export const fileUpload = kibana => {
init(server) {
const coreSetup = server.newPlatform.setup.core;
+ const coreStart = server.newPlatform.start.core;
const { usageCollection } = server.newPlatform.setup.plugins;
- const pluginsSetup = {
+ const pluginsStart = {
usageCollection,
};
-
- // legacy dependencies
- const __LEGACY = {
- route: server.route.bind(server),
- plugins: {
- elasticsearch: server.plugins.elasticsearch,
- },
- savedObjects: {
- getSavedObjectsRepository: server.savedObjects.getSavedObjectsRepository,
- },
- };
-
- new FileUploadPlugin().setup(coreSetup, pluginsSetup, __LEGACY);
+ const fileUploadPlugin = new FileUploadPlugin();
+ fileUploadPlugin.setup(coreSetup);
+ fileUploadPlugin.start(coreStart, pluginsStart);
},
});
};
diff --git a/x-pack/legacy/plugins/file_upload/server/client/call_with_internal_user_factory.d.ts b/x-pack/legacy/plugins/file_upload/server/client/call_with_internal_user_factory.d.ts
deleted file mode 100644
index 9c1000db8cb56..0000000000000
--- a/x-pack/legacy/plugins/file_upload/server/client/call_with_internal_user_factory.d.ts
+++ /dev/null
@@ -1,7 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License;
- * you may not use this file except in compliance with the Elastic License.
- */
-
-export function callWithInternalUserFactory(elasticsearchPlugin: any): any;
diff --git a/x-pack/legacy/plugins/file_upload/server/client/call_with_internal_user_factory.js b/x-pack/legacy/plugins/file_upload/server/client/call_with_internal_user_factory.js
deleted file mode 100644
index 2e5431bdd6ce2..0000000000000
--- a/x-pack/legacy/plugins/file_upload/server/client/call_with_internal_user_factory.js
+++ /dev/null
@@ -1,18 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License;
- * you may not use this file except in compliance with the Elastic License.
- */
-
-import { once } from 'lodash';
-
-const _callWithInternalUser = once(elasticsearchPlugin => {
- const { callWithInternalUser } = elasticsearchPlugin.getCluster('admin');
- return callWithInternalUser;
-});
-
-export const callWithInternalUserFactory = elasticsearchPlugin => {
- return (...args) => {
- return _callWithInternalUser(elasticsearchPlugin)(...args);
- };
-};
diff --git a/x-pack/legacy/plugins/file_upload/server/client/call_with_internal_user_factory.test.ts b/x-pack/legacy/plugins/file_upload/server/client/call_with_internal_user_factory.test.ts
deleted file mode 100644
index 04c5013ed8e67..0000000000000
--- a/x-pack/legacy/plugins/file_upload/server/client/call_with_internal_user_factory.test.ts
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License;
- * you may not use this file except in compliance with the Elastic License.
- */
-
-import { callWithInternalUserFactory } from './call_with_internal_user_factory';
-
-describe('call_with_internal_user_factory', () => {
- describe('callWithInternalUserFactory', () => {
- it('should use internal user "admin"', () => {
- const callWithInternalUser: any = jest.fn();
- const elasticsearchPlugin: any = {
- getCluster: jest.fn(() => ({ callWithInternalUser })),
- };
- const callWithInternalUserInstance = callWithInternalUserFactory(elasticsearchPlugin);
- callWithInternalUserInstance();
-
- expect(elasticsearchPlugin.getCluster).toHaveBeenCalledWith('admin');
- });
- });
-});
diff --git a/x-pack/legacy/plugins/file_upload/server/client/call_with_request_factory.js b/x-pack/legacy/plugins/file_upload/server/client/call_with_request_factory.js
index a0b0d2d1c7ce3..bef6c369fd9ac 100644
--- a/x-pack/legacy/plugins/file_upload/server/client/call_with_request_factory.js
+++ b/x-pack/legacy/plugins/file_upload/server/client/call_with_request_factory.js
@@ -5,14 +5,17 @@
*/
import { once } from 'lodash';
+import { getDataClient } from '../kibana_server_services';
-const callWithRequest = once(elasticsearchPlugin => {
- const cluster = elasticsearchPlugin.getCluster('data');
- return cluster.callWithRequest;
-});
+const callWithRequest = once(() => getDataClient());
-export const callWithRequestFactory = (elasticsearchPlugin, request) => {
+export const callWithRequestFactory = request => {
return (...args) => {
- return callWithRequest(elasticsearchPlugin)(request, ...args);
+ return (
+ callWithRequest()
+ .asScoped(request)
+ // @ts-ignore
+ .callAsCurrentUser(...args)
+ );
};
};
diff --git a/x-pack/legacy/plugins/file_upload/server/kibana_server_services.js b/x-pack/legacy/plugins/file_upload/server/kibana_server_services.js
new file mode 100644
index 0000000000000..104e49015ba80
--- /dev/null
+++ b/x-pack/legacy/plugins/file_upload/server/kibana_server_services.js
@@ -0,0 +1,18 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License;
+ * you may not use this file except in compliance with the Elastic License.
+ */
+
+let dataClient;
+
+export const setElasticsearchClientServices = elasticsearch => {
+ ({ dataClient } = elasticsearch);
+};
+export const getDataClient = () => dataClient;
+
+let internalRepository;
+export const setInternalRepository = createInternalRepository => {
+ internalRepository = createInternalRepository();
+};
+export const getInternalRepository = () => internalRepository;
diff --git a/x-pack/legacy/plugins/file_upload/server/plugin.js b/x-pack/legacy/plugins/file_upload/server/plugin.js
index 23fb8bda897f0..c448676f813ea 100644
--- a/x-pack/legacy/plugins/file_upload/server/plugin.js
+++ b/x-pack/legacy/plugins/file_upload/server/plugin.js
@@ -5,19 +5,23 @@
*/
import { initRoutes } from './routes/file_upload';
+import { setElasticsearchClientServices, setInternalRepository } from './kibana_server_services';
import { registerFileUploadUsageCollector } from './telemetry';
export class FileUploadPlugin {
- setup(core, plugins, __LEGACY) {
- const elasticsearchPlugin = __LEGACY.plugins.elasticsearch;
- const getSavedObjectsRepository = __LEGACY.savedObjects.getSavedObjectsRepository;
- const router = core.http.createRouter();
+ constructor() {
+ this.router = null;
+ }
+
+ setup(core) {
+ setElasticsearchClientServices(core.elasticsearch);
+ this.router = core.http.createRouter();
+ }
- initRoutes(router, elasticsearchPlugin, getSavedObjectsRepository);
+ start(core, plugins) {
+ initRoutes(this.router, core.savedObjects.getSavedObjectsRepository);
+ setInternalRepository(core.savedObjects.createInternalRepository);
- registerFileUploadUsageCollector(plugins.usageCollection, {
- elasticsearchPlugin,
- getSavedObjectsRepository,
- });
+ registerFileUploadUsageCollector(plugins.usageCollection);
}
}
diff --git a/x-pack/legacy/plugins/file_upload/server/routes/file_upload.js b/x-pack/legacy/plugins/file_upload/server/routes/file_upload.js
index 1c27c2d7d68e9..acbc907729d95 100644
--- a/x-pack/legacy/plugins/file_upload/server/routes/file_upload.js
+++ b/x-pack/legacy/plugins/file_upload/server/routes/file_upload.js
@@ -75,7 +75,7 @@ export const idConditionalValidation = (body, boolHasId) =>
)
.validate(body);
-const finishValidationAndProcessReq = (elasticsearchPlugin, getSavedObjectsRepository) => {
+const finishValidationAndProcessReq = () => {
return async (con, req, { ok, badRequest }) => {
const {
query: { id },
@@ -86,7 +86,7 @@ const finishValidationAndProcessReq = (elasticsearchPlugin, getSavedObjectsRepos
let resp;
try {
const validIdReqData = idConditionalValidation(body, boolHasId);
- const callWithRequest = callWithRequestFactory(elasticsearchPlugin, req);
+ const callWithRequest = callWithRequestFactory(req);
const { importData: importDataFunc } = importDataProvider(callWithRequest);
const { index, settings, mappings, ingestPipeline, data } = validIdReqData;
@@ -103,7 +103,7 @@ const finishValidationAndProcessReq = (elasticsearchPlugin, getSavedObjectsRepos
resp = ok({ body: processedReq });
// If no id's been established then this is a new index, update telemetry
if (!boolHasId) {
- await updateTelemetry({ elasticsearchPlugin, getSavedObjectsRepository });
+ await updateTelemetry();
}
} else {
resp = badRequest(`Error processing request 1: ${processedReq.error.message}`, ['body']);
@@ -115,7 +115,7 @@ const finishValidationAndProcessReq = (elasticsearchPlugin, getSavedObjectsRepos
};
};
-export const initRoutes = (router, esPlugin, getSavedObjectsRepository) => {
+export const initRoutes = router => {
router.post(
{
path: `${IMPORT_ROUTE}{id?}`,
@@ -125,6 +125,6 @@ export const initRoutes = (router, esPlugin, getSavedObjectsRepository) => {
},
options,
},
- finishValidationAndProcessReq(esPlugin, getSavedObjectsRepository)
+ finishValidationAndProcessReq()
);
};
diff --git a/x-pack/legacy/plugins/file_upload/server/telemetry/file_upload_usage_collector.ts b/x-pack/legacy/plugins/file_upload/server/telemetry/file_upload_usage_collector.ts
index a2b359ae11638..2c2b1183fd5bf 100644
--- a/x-pack/legacy/plugins/file_upload/server/telemetry/file_upload_usage_collector.ts
+++ b/x-pack/legacy/plugins/file_upload/server/telemetry/file_upload_usage_collector.ts
@@ -9,19 +9,11 @@ import { getTelemetry, initTelemetry } from './telemetry';
const TELEMETRY_TYPE = 'fileUploadTelemetry';
-export function registerFileUploadUsageCollector(
- usageCollection: UsageCollectionSetup,
- deps: {
- elasticsearchPlugin: any;
- getSavedObjectsRepository: any;
- }
-): void {
- const { elasticsearchPlugin, getSavedObjectsRepository } = deps;
+export function registerFileUploadUsageCollector(usageCollection: UsageCollectionSetup): void {
const fileUploadUsageCollector = usageCollection.makeUsageCollector({
type: TELEMETRY_TYPE,
isReady: () => true,
- fetch: async () =>
- (await getTelemetry(elasticsearchPlugin, getSavedObjectsRepository)) || initTelemetry(),
+ fetch: async () => (await getTelemetry()) || initTelemetry(),
});
usageCollection.registerCollector(fileUploadUsageCollector);
diff --git a/x-pack/legacy/plugins/file_upload/server/telemetry/telemetry.test.ts b/x-pack/legacy/plugins/file_upload/server/telemetry/telemetry.test.ts
index 1c785d8e7b61c..fadad307c0710 100644
--- a/x-pack/legacy/plugins/file_upload/server/telemetry/telemetry.test.ts
+++ b/x-pack/legacy/plugins/file_upload/server/telemetry/telemetry.test.ts
@@ -6,8 +6,6 @@
import { getTelemetry, updateTelemetry } from './telemetry';
-const elasticsearchPlugin: any = null;
-const getSavedObjectsRepository: any = null;
const internalRepository = () => ({
get: jest.fn(() => null),
create: jest.fn(() => ({ attributes: 'test' })),
@@ -25,7 +23,7 @@ describe('file upload plugin telemetry', () => {
describe('getTelemetry', () => {
it('should get existing telemetry', async () => {
const internalRepo = mockInit();
- await getTelemetry(elasticsearchPlugin, getSavedObjectsRepository, internalRepo);
+ await getTelemetry(internalRepo);
expect(internalRepo.update.mock.calls.length).toBe(0);
expect(internalRepo.get.mock.calls.length).toBe(1);
expect(internalRepo.create.mock.calls.length).toBe(0);
@@ -40,11 +38,7 @@ describe('file upload plugin telemetry', () => {
},
});
- await updateTelemetry({
- elasticsearchPlugin,
- getSavedObjectsRepository,
- internalRepo,
- });
+ await updateTelemetry(internalRepo);
expect(internalRepo.update.mock.calls.length).toBe(1);
expect(internalRepo.get.mock.calls.length).toBe(1);
expect(internalRepo.create.mock.calls.length).toBe(0);
diff --git a/x-pack/legacy/plugins/file_upload/server/telemetry/telemetry.ts b/x-pack/legacy/plugins/file_upload/server/telemetry/telemetry.ts
index 5ffa735f4c83a..2978dec7aa68d 100644
--- a/x-pack/legacy/plugins/file_upload/server/telemetry/telemetry.ts
+++ b/x-pack/legacy/plugins/file_upload/server/telemetry/telemetry.ts
@@ -5,7 +5,8 @@
*/
import _ from 'lodash';
-import { callWithInternalUserFactory } from '../client/call_with_internal_user_factory';
+// @ts-ignore
+import { getInternalRepository } from '../kibana_server_services';
export const TELEMETRY_DOC_ID = 'file-upload-telemetry';
@@ -17,27 +18,14 @@ export interface TelemetrySavedObject {
attributes: Telemetry;
}
-export function getInternalRepository(
- elasticsearchPlugin: any,
- getSavedObjectsRepository: any
-): any {
- const callWithInternalUser = callWithInternalUserFactory(elasticsearchPlugin);
- return getSavedObjectsRepository(callWithInternalUser);
-}
-
export function initTelemetry(): Telemetry {
return {
filesUploadedTotalCount: 0,
};
}
-export async function getTelemetry(
- elasticsearchPlugin: any,
- getSavedObjectsRepository: any,
- internalRepo?: object
-): Promise {
- const internalRepository =
- internalRepo || getInternalRepository(elasticsearchPlugin, getSavedObjectsRepository);
+export async function getTelemetry(internalRepo?: object): Promise {
+ const internalRepository = internalRepo || getInternalRepository();
let telemetrySavedObject;
try {
@@ -49,22 +37,9 @@ export async function getTelemetry(
return telemetrySavedObject ? telemetrySavedObject.attributes : null;
}
-export async function updateTelemetry({
- elasticsearchPlugin,
- getSavedObjectsRepository,
- internalRepo,
-}: {
- elasticsearchPlugin: any;
- getSavedObjectsRepository: any;
- internalRepo?: any;
-}) {
- const internalRepository =
- internalRepo || getInternalRepository(elasticsearchPlugin, getSavedObjectsRepository);
- let telemetry = await getTelemetry(
- elasticsearchPlugin,
- getSavedObjectsRepository,
- internalRepository
- );
+export async function updateTelemetry(internalRepo?: any) {
+ const internalRepository = internalRepo || getInternalRepository();
+ let telemetry = await getTelemetry(internalRepository);
// Create if doesn't exist
if (!telemetry || _.isEmpty(telemetry)) {
const newTelemetrySavedObject = await internalRepository.create(
|