Skip to content

Commit

Permalink
[Lens] Better disabled messages for Value labels popup (#85592)
Browse files Browse the repository at this point in the history
Co-authored-by: Kibana Machine <[email protected]>
  • Loading branch information
dej611 and kibanamachine authored Dec 14, 2020
1 parent d4f4a2c commit 1ff2331
Showing 1 changed file with 28 additions and 9 deletions.
37 changes: 28 additions & 9 deletions x-pack/plugins/lens/public/xy_visualization/xy_config_panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,28 @@ export function LayerContextMenu(props: VisualizationLayerWidgetProps<State>) {
);
}

function getValueLabelDisableReason({
isAreaPercentage,
isHistogramSeries,
}: {
isAreaPercentage: boolean;
isHistogramSeries: boolean;
}): string {
if (isHistogramSeries) {
return i18n.translate('xpack.lens.xyChart.valuesHistogramDisabledHelpText', {
defaultMessage: 'This setting cannot be changed on histograms.',
});
}
if (isAreaPercentage) {
return i18n.translate('xpack.lens.xyChart.valuesPercentageDisabledHelpText', {
defaultMessage: 'This setting cannot be changed on percentage area charts.',
});
}
return i18n.translate('xpack.lens.xyChart.valuesStackedDisabledHelpText', {
defaultMessage: 'This setting cannot be changed on stacked or percentage bar charts',
});
}

export function XyToolbar(props: VisualizationToolbarProps<State>) {
const { state, setState, frame } = props;

Expand Down Expand Up @@ -246,20 +268,17 @@ export function XyToolbar(props: VisualizationToolbarProps<State>) {
const isValueLabelsEnabled = !hasNonBarSeries && hasBarNotStacked && !isHistogramSeries;
const isFittingEnabled = hasNonBarSeries;

const valueLabelsDisabledReason = getValueLabelDisableReason({
isAreaPercentage,
isHistogramSeries,
});

return (
<EuiFlexGroup gutterSize="m" justifyContent="spaceBetween">
<EuiFlexItem>
<EuiFlexGroup gutterSize="none" responsive={false}>
<TooltipWrapper
tooltipContent={
isAreaPercentage
? i18n.translate('xpack.lens.xyChart.valuesPercentageDisabledHelpText', {
defaultMessage: 'This setting cannot be changed on percentage area charts.',
})
: i18n.translate('xpack.lens.xyChart.valuesStackedDisabledHelpText', {
defaultMessage: 'This setting cannot be changed on histograms.',
})
}
tooltipContent={valueLabelsDisabledReason}
condition={!isValueLabelsEnabled && !isFittingEnabled}
>
<ToolbarPopover
Expand Down

0 comments on commit 1ff2331

Please sign in to comment.