diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/field_item.scss b/x-pack/plugins/lens/public/indexpattern_datasource/field_item.scss index 1b55d9623e223..8c10ca9d30b73 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/field_item.scss +++ b/x-pack/plugins/lens/public/indexpattern_datasource/field_item.scss @@ -42,7 +42,6 @@ max-width: 300px; } -.lnsFieldItem__buttonGroup { - // Enforce lowercase for buttons or else some browsers inherit all caps from flyout title +.lnsFieldItem__fieldPanelTitle { text-transform: none; } diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/field_item.tsx b/x-pack/plugins/lens/public/indexpattern_datasource/field_item.tsx index 48241886eb345..a98ba5735b8cd 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/field_item.tsx +++ b/x-pack/plugins/lens/public/indexpattern_datasource/field_item.tsx @@ -10,7 +10,7 @@ import React, { useState } from 'react'; import DateMath from '@elastic/datemath'; import { EuiButtonGroup, - EuiButton, + EuiButtonIcon, EuiFlexGroup, EuiFlexItem, EuiIconTip, @@ -19,7 +19,9 @@ import { EuiPopoverFooter, EuiPopoverTitle, EuiProgress, + EuiSpacer, EuiText, + EuiTitle, EuiToolTip, } from '@elastic/eui'; import { @@ -270,20 +272,28 @@ function FieldItemPopoverContents(props: State & FieldItemProps) { const [showingHistogram, setShowingHistogram] = useState(histogramDefault); - if (hideDetails) { - return ( - - + const FieldPanelHeader = () => ( + + + +
{field.displayName}
+
- ); + + +
+ ); + + if (hideDetails) { + return ; } let formatter: { convert: (data: unknown) => string }; @@ -316,25 +326,18 @@ function FieldItemPopoverContents(props: State & FieldItemProps) { (!props.topValues || props.topValues.buckets.length === 0) ) { return ( -
+ <> + + + + {i18n.translate('xpack.lens.indexPattern.fieldStatsNoData', { defaultMessage: 'This field is empty because it doesn’t exist in the 500 sampled documents. Adding this field to the configuration may result in a blank chart.', })} - - - -
+ ); } @@ -369,31 +372,42 @@ function FieldItemPopoverContents(props: State & FieldItemProps) { ); } else if (field.type === 'date') { title = ( - <> - {i18n.translate('xpack.lens.indexPattern.fieldTimeDistributionLabel', { - defaultMessage: 'Time distribution', - })} - + +
+ {i18n.translate('xpack.lens.indexPattern.fieldTimeDistributionLabel', { + defaultMessage: 'Time distribution', + })} +
+
); } else if (topValues && topValues.buckets.length) { title = ( - <> - {i18n.translate('xpack.lens.indexPattern.fieldTopValuesLabel', { - defaultMessage: 'Top values', - })} - + +
+ {i18n.translate('xpack.lens.indexPattern.fieldTopValuesLabel', { + defaultMessage: 'Top values', + })} +
+
); } function wrapInPopover(el: React.ReactElement) { return ( <> - {title ? {title} : <>} + + + + + {title ? title : <>} + + + {el} {props.totalDocuments ? ( - + {props.sampledDocuments && ( <> {i18n.translate('xpack.lens.indexPattern.percentageOfLabel', { @@ -413,17 +427,6 @@ function FieldItemPopoverContents(props: State & FieldItemProps) { defaultMessage: 'documents', })} - - - ) : ( <> @@ -585,45 +588,24 @@ function FieldItemPopoverContents(props: State & FieldItemProps) { } const DragToWorkspaceButton = ({ field, getSuggestionForField, dropOntoWorkspace }) => { - if (!getSuggestionForField(field)) { + const buttonTitle = i18n.translate('xpack.lens.indexPattern.moveToWorkspace', { + defaultMessage: 'Add field to workspace', + }); + + if (getSuggestionForField(field)) { return ( - - + { dropOntoWorkspace(field); }} - > - {i18n.translate('xpack.lens.indexPattern.moveToWorkspace', { - defaultMessage: 'Move to workspace', - })} - - + title={buttonTitle} + /> +
); + } else { + return null; } - - return ( - { - dropOntoWorkspace(field); - }} - > - {i18n.translate('xpack.lens.indexPattern.moveToWorkspace', { - defaultMessage: 'Move to workspace', - })} - - ); };