Skip to content

Commit d885377

Browse files
[Lens] Extract legend settings content from the toolbar popover (elastic#237863)
## Summary Extract the legend settings content from the toolbar popover. ## Issues Closes elastic#238790 ## Checklist - [x] The PR description includes the appropriate Release Notes section, and the correct `release_note:*` label is applied per the [guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process) - [x] Review the [backport guidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing) and apply applicable `backport:*` labels.
1 parent 24305db commit d885377

1 file changed

Lines changed: 23 additions & 12 deletions

File tree

x-pack/platform/plugins/shared/lens/public/shared_components/legend/legend_settings_popover.tsx

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,27 @@ export function shouldDisplayTable(legendValues: LegendValue[]) {
209209
return legendValues.some((v) => v !== LegendValue.CurrentAndLastValue);
210210
}
211211

212-
export function LegendSettingsPopover<LegendStats extends LegendValue = XYLegendValue>({
212+
export function LegendSettingsPopover<LegendStats extends LegendValue = XYLegendValue>(
213+
props: LegendSettingsPopoverProps<LegendStats>
214+
) {
215+
const { groupPosition = 'none' } = props;
216+
217+
return (
218+
<ToolbarPopover
219+
title={i18n.translate('xpack.lens.shared.legendLabel', {
220+
defaultMessage: 'Legend',
221+
})}
222+
type="legend"
223+
groupPosition={groupPosition}
224+
buttonDataTestSubj="lnsLegendButton"
225+
panelStyle={PANEL_STYLE}
226+
>
227+
<LegendSettings {...props} />
228+
</ToolbarPopover>
229+
);
230+
}
231+
232+
function LegendSettings<LegendStats extends LegendValue = XYLegendValue>({
213233
allowedLegendStats = [],
214234
legendOptions,
215235
mode,
@@ -231,7 +251,6 @@ export function LegendSettingsPopover<LegendStats extends LegendValue = XYLegend
231251
onNestedLegendChange = noop,
232252
legendStats = [],
233253
onLegendStatsChange = noop,
234-
groupPosition = 'none',
235254
maxLines,
236255
onMaxLinesChange = noop,
237256
shouldTruncate,
@@ -254,15 +273,7 @@ export function LegendSettingsPopover<LegendStats extends LegendValue = XYLegend
254273
const showsLegendTitleSetting = shouldDisplayTable(legendStats) && !!onLegendTitleChange;
255274

256275
return (
257-
<ToolbarPopover
258-
title={i18n.translate('xpack.lens.shared.legendLabel', {
259-
defaultMessage: 'Legend',
260-
})}
261-
type="legend"
262-
groupPosition={groupPosition}
263-
buttonDataTestSubj="lnsLegendButton"
264-
panelStyle={PANEL_STYLE}
265-
>
276+
<>
266277
<EuiFormRow
267278
display="columnCompressed"
268279
label={i18n.translate('xpack.lens.shared.legendVisibilityLabel', {
@@ -434,6 +445,6 @@ export function LegendSettingsPopover<LegendStats extends LegendValue = XYLegend
434445
/>
435446
</EuiFormRow>
436447
)}
437-
</ToolbarPopover>
448+
</>
438449
);
439450
}

0 commit comments

Comments
 (0)