[Discover] Fix horizontal rule in Additional display settings popover (#177460)

- Noticed in https://github.com/elastic/kibana/pull/176064

## Summary

This PR renders `EuiHorizontalRule` only between available options.

Before:
<img width="494" alt="Screenshot 2024-02-21 at 15 57 24"
src="f718008e-82fb-48f2-9e30-bc607e571e44">

After:
<img width="491" alt="Screenshot 2024-02-21 at 15 56 47"
src="fe6b2bf1-93b6-4913-bd40-d7187a06e7ee">
This commit is contained in:
Julia Rechkunova 2024-02-21 22:12:20 +01:00 committed by GitHub
parent 9f2bde1b8a
commit 97fcb20a94
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -90,9 +90,10 @@ export const UnifiedDataTableAdditionalDisplaySettings: React.FC<
setActiveSampleSize(sampleSize); // reset local state
}, [sampleSize, setActiveSampleSize]);
return (
<>
{onChangeHeaderRowHeight && onChangeHeaderRowHeightLines && (
const settings = [];
if (onChangeHeaderRowHeight && onChangeHeaderRowHeightLines) {
settings.push(
<RowHeightSettings
rowHeight={headerRowHeight}
rowHeightLines={headerRowHeightLines}
@ -104,10 +105,11 @@ export const UnifiedDataTableAdditionalDisplaySettings: React.FC<
data-test-subj="unifiedDataTableHeaderRowHeightSettings"
maxRowHeight={5}
/>
)}
{onChangeRowHeight && onChangeRowHeightLines && (
<>
<EuiHorizontalRule margin="s" />
);
}
if (onChangeRowHeight && onChangeRowHeightLines) {
settings.push(
<RowHeightSettings
rowHeight={rowHeight}
rowHeightLines={rowHeightLines}
@ -118,11 +120,11 @@ export const UnifiedDataTableAdditionalDisplaySettings: React.FC<
onChangeRowHeightLines={onChangeRowHeightLines}
data-test-subj="unifiedDataTableRowHeightSettings"
/>
</>
)}
{onChangeSampleSize && (
<>
<EuiHorizontalRule margin="s" />
);
}
if (onChangeSampleSize) {
settings.push(
<EuiFormRow label={sampleSizeLabel} display="columnCompressed">
<EuiRange
compressed
@ -136,8 +138,17 @@ export const UnifiedDataTableAdditionalDisplaySettings: React.FC<
data-test-subj="unifiedDataTableSampleSizeInput"
/>
</EuiFormRow>
</>
)}
);
}
return (
<>
{settings.map((setting, index) => (
<React.Fragment key={`setting-${index}`}>
{index > 0 && <EuiHorizontalRule margin="s" />}
{setting}
</React.Fragment>
))}
</>
);
};