Skip to content

Commit 10ecc27

Browse files
SoniaSanzVmattkime
andauthored
[8.19] [Index Management] Move field_list_item out of scss (#219669) (#220195)
# Backport This will backport the following commits from `main` to `8.19`: - [[Index Management] Move field_list_item out of scss (#219669)](#219669) <!--- Backport version: 9.6.6 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Sonia Sanz Vivas","email":"[email protected]"},"sourceCommit":{"committedDate":"2025-05-05T14:59:22Z","message":"[Index Management] Move field_list_item out of scss (#219669)\n\nFixes https://github.com/elastic/kibana/issues/219021\n\n## Summary\nIn serverless, when the user loads the index mapping page and refresh\nthe page, the styles get lost for the fields. It only happens in\nserverless.\n\nTo address that and as part of the [migration to emotion\ninitiative](#205027), I decided\nto move the styles to emotion. I didn't remove the scss file because\nit's a complex package of shared components and it needs a thorough\ntesting to verify that no other component is using that styles (we have\nmultiple components and scss files with the same class names).\n\n### How to test\n\n1. Run serverless elasticsearch (`yarn serverless-es`)\n2. Open Kibana\n3. Create an index\n4. Navigate to the index details page (URL\n`/app/elasticsearch/indices/index_details/<index_name>`)\n5. Select the Mappings tab (URL\n`/app/elasticsearch/indices/index_details/<index_name>/mappings`)\n6. Hard-refresh the browser (Cmd+Shift+R on Mac)\n7. Verify that the styles are not missed.\n\nCo-authored-by: Matthew Kime <[email protected]>","sha":"d4e4e4ee4246b32f47cb933551a036b0257e75ca","branchLabelMapping":{"^v9.1.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Feature:Index Management","Team:Kibana Management","release_note:skip","backport:prev-minor","v9.1.0","v8.19.0","v9.0.1"],"title":"[Index Management] Move field_list_item out of scss","number":219669,"url":"https://github.com/elastic/kibana/pull/219669","mergeCommit":{"message":"[Index Management] Move field_list_item out of scss (#219669)\n\nFixes https://github.com/elastic/kibana/issues/219021\n\n## Summary\nIn serverless, when the user loads the index mapping page and refresh\nthe page, the styles get lost for the fields. It only happens in\nserverless.\n\nTo address that and as part of the [migration to emotion\ninitiative](#205027), I decided\nto move the styles to emotion. I didn't remove the scss file because\nit's a complex package of shared components and it needs a thorough\ntesting to verify that no other component is using that styles (we have\nmultiple components and scss files with the same class names).\n\n### How to test\n\n1. Run serverless elasticsearch (`yarn serverless-es`)\n2. Open Kibana\n3. Create an index\n4. Navigate to the index details page (URL\n`/app/elasticsearch/indices/index_details/<index_name>`)\n5. Select the Mappings tab (URL\n`/app/elasticsearch/indices/index_details/<index_name>/mappings`)\n6. Hard-refresh the browser (Cmd+Shift+R on Mac)\n7. Verify that the styles are not missed.\n\nCo-authored-by: Matthew Kime <[email protected]>","sha":"d4e4e4ee4246b32f47cb933551a036b0257e75ca"}},"sourceBranch":"main","suggestedTargetBranches":["8.19"],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/219669","number":219669,"mergeCommit":{"message":"[Index Management] Move field_list_item out of scss (#219669)\n\nFixes https://github.com/elastic/kibana/issues/219021\n\n## Summary\nIn serverless, when the user loads the index mapping page and refresh\nthe page, the styles get lost for the fields. It only happens in\nserverless.\n\nTo address that and as part of the [migration to emotion\ninitiative](#205027), I decided\nto move the styles to emotion. I didn't remove the scss file because\nit's a complex package of shared components and it needs a thorough\ntesting to verify that no other component is using that styles (we have\nmultiple components and scss files with the same class names).\n\n### How to test\n\n1. Run serverless elasticsearch (`yarn serverless-es`)\n2. Open Kibana\n3. Create an index\n4. Navigate to the index details page (URL\n`/app/elasticsearch/indices/index_details/<index_name>`)\n5. Select the Mappings tab (URL\n`/app/elasticsearch/indices/index_details/<index_name>/mappings`)\n6. Hard-refresh the browser (Cmd+Shift+R on Mac)\n7. Verify that the styles are not missed.\n\nCo-authored-by: Matthew Kime <[email protected]>","sha":"d4e4e4ee4246b32f47cb933551a036b0257e75ca"}},{"branch":"8.19","label":"v8.19.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"9.0","label":"v9.0.1","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"url":"https://github.com/elastic/kibana/pull/220102","number":220102,"state":"MERGED","mergeCommit":{"sha":"47b93c57479d40abc01a09e95ab87c609e58a80a","message":"[9.0] [Index Management] Move field_list_item out of scss (#219669) (#220102)\n\n# Backport\n\nThis will backport the following commits from `main` to `9.0`:\n- [[Index Management] Move field_list_item out of scss\n(#219669)](https://github.com/elastic/kibana/pull/219669)\n\n\n\n### Questions ?\nPlease refer to the [Backport tool\ndocumentation](https://github.com/sorenlouv/backport)\n\n\n\nCo-authored-by: Sonia Sanz Vivas <[email protected]>"}}]}] BACKPORT--> Co-authored-by: Matthew Kime <[email protected]>
1 parent 0002d09 commit 10ecc27

File tree

2 files changed

+72
-33
lines changed

2 files changed

+72
-33
lines changed

x-pack/platform/plugins/shared/index_management/public/application/components/mappings_editor/components/document_fields/fields/fields_list.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export const FieldsList = React.memo(function FieldsListComponent({
3131
return null;
3232
}
3333
return (
34-
<ul className="mappingsEditor__fieldsList" data-test-subj="fieldsList">
34+
<ul data-test-subj="fieldsList">
3535
{fields.map((field, index) => (
3636
<FieldsListItemContainer
3737
key={field.id}

x-pack/platform/plugins/shared/index_management/public/application/components/mappings_editor/components/document_fields/fields/fields_list_item.tsx

Lines changed: 71 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,20 @@
66
*/
77

88
import React, { forwardRef } from 'react';
9-
import classNames from 'classnames';
109
import {
1110
EuiFlexGroup,
1211
EuiFlexItem,
1312
EuiBadge,
1413
EuiButtonIcon,
1514
EuiToolTip,
1615
EuiIcon,
16+
useEuiTheme,
17+
EuiThemeComputed,
1718
} from '@elastic/eui';
1819
import { i18n } from '@kbn/i18n';
19-
20+
import { css } from '@emotion/react';
2021
import { NormalizedField, NormalizedFields, State } from '../../../types';
22+
2123
import { getTypeLabelFromField } from '../../../lib';
2224
import { CHILD_FIELD_INDENT_SIZE, LEFT_PADDING_SIZE_FIELD_ITEM_WRAPPER } from '../../../constants';
2325

@@ -46,6 +48,51 @@ const i18nTexts = {
4648
}),
4749
};
4850

51+
const getListItemStyle = ({ border, colors, size }: EuiThemeComputed<{}>) => ({
52+
dotted: css`
53+
border-bottom-style: dashed;
54+
`,
55+
field: css`
56+
border-bottom: ${border.thin};
57+
height: calc(${size.xl} * 2);
58+
margin-top: ${size.xs};
59+
`,
60+
fieldEnabled: css`
61+
&:hover {
62+
background-color: ${colors.backgroundBaseHighlighted};
63+
}
64+
`,
65+
fieldHighlighted: css`
66+
background-color: ${colors.backgroundBaseHighlighted};
67+
`,
68+
fieldDim: css`
69+
opacity: 0.3;
70+
&:hover {
71+
background-color: initial;
72+
}
73+
`,
74+
wrapper: css`
75+
padding-left: ${size.xs};
76+
`,
77+
wrapperIndent: css`
78+
padding-left: ${size};
79+
`,
80+
content: css`
81+
height: calc(${size.xl} * 2);
82+
position: relative;
83+
`,
84+
contentIndent: css`
85+
padding-left: ${size.xl};
86+
`,
87+
toggle: css`
88+
padding-left: ${size.xs};
89+
width: ${size.l};
90+
`,
91+
actions: css`
92+
padding-left: ${size.s};
93+
`,
94+
});
95+
4996
interface Props {
5097
field: NormalizedField;
5198
allFields: NormalizedFields['byId'];
@@ -101,6 +148,8 @@ function FieldListItemComponent(
101148
isExpanded,
102149
path,
103150
} = field;
151+
const { euiTheme } = useEuiTheme();
152+
const styles = getListItemStyle(euiTheme);
104153

105154
// When there aren't any "child" fields (the maxNestedDepth === 0), there is no toggle icon on the left of any field.
106155
// For that reason, we need to compensate and substract some indent to left align on the page.
@@ -145,7 +194,7 @@ function FieldListItemComponent(
145194
const { addMultiFieldButtonLabel, addPropertyButtonLabel, editButtonLabel, deleteButtonLabel } =
146195
i18nTexts;
147196
return (
148-
<EuiFlexGroup gutterSize="s" className="mappingsEditor__fieldsListItem__actions">
197+
<EuiFlexGroup gutterSize="s" css={styles.actions}>
149198
{canHaveMultiFields && (
150199
<EuiFlexItem grow={false}>
151200
<EuiToolTip content={addMultiFieldButtonLabel}>
@@ -205,39 +254,33 @@ function FieldListItemComponent(
205254
const dataTestSubj = `${path.join('')}Field`;
206255

207256
return (
208-
<li
209-
className={classNames('mappingsEditor__fieldsListItem', {
210-
'mappingsEditor__fieldsListItem--dottedLine': hasDottedLine,
211-
})}
212-
data-test-subj={`fieldsListItem ${dataTestSubj}`}
213-
ref={ref}
214-
>
257+
<li data-test-subj={`fieldsListItem ${dataTestSubj}`} ref={ref}>
215258
<div
216259
style={{ paddingLeft: `${indent}px` }}
217-
className={classNames('mappingsEditor__fieldsListItem__field', {
218-
'mappingsEditor__fieldsListItem__field--enabled': areActionButtonsVisible,
219-
'mappingsEditor__fieldsListItem__field--highlighted': isHighlighted,
220-
'mappingsEditor__fieldsListItem__field--dim': isDimmed,
221-
})}
260+
css={[
261+
styles.field,
262+
areActionButtonsVisible && styles.fieldEnabled,
263+
isHighlighted && styles.fieldHighlighted,
264+
isDimmed && styles.fieldDim,
265+
hasDottedLine && styles.dotted,
266+
]}
222267
>
223268
<div
224-
className={classNames('mappingsEditor__fieldsListItem__wrapper', {
225-
'mappingsEditor__fieldsListItem__wrapper--indent':
226-
treeDepth === 0 && maxNestedDepth === 0,
227-
})}
269+
css={[styles.wrapper, treeDepth === 0 && maxNestedDepth === 0 && styles.wrapperIndent]}
228270
>
229271
<EuiFlexGroup
230272
gutterSize="s"
231273
alignItems="center"
232-
className={classNames('mappingsEditor__fieldsListItem__content', {
233-
'mappingsEditor__fieldsListItem__content--toggle': hasChildFields || hasMultiFields,
234-
'mappingsEditor__fieldsListItem__content--multiField': isMultiField,
235-
'mappingsEditor__fieldsListItem__content--indent':
236-
!hasChildFields && !hasMultiFields && maxNestedDepth > treeDepth,
237-
})}
274+
css={[
275+
styles.content,
276+
!hasChildFields &&
277+
!hasMultiFields &&
278+
maxNestedDepth > treeDepth &&
279+
styles.contentIndent,
280+
]}
238281
>
239282
{(hasChildFields || hasMultiFields) && (
240-
<EuiFlexItem grow={false} className="mappingsEditor__fieldsListItem__toggle">
283+
<EuiFlexItem grow={false} css={styles.toggle}>
241284
<EuiButtonIcon
242285
color="text"
243286
onClick={toggleExpand}
@@ -263,16 +306,12 @@ function FieldListItemComponent(
263306
)}
264307

265308
{isMultiField && (
266-
<EuiFlexItem grow={false} className="mappingsEditor__fieldsListItem__icon">
309+
<EuiFlexItem grow={false}>
267310
<EuiIcon color="subdued" type="documents" />
268311
</EuiFlexItem>
269312
)}
270313

271-
<EuiFlexItem
272-
grow={false}
273-
className="mappingsEditor__fieldsListItem__name"
274-
data-test-subj={`fieldName ${dataTestSubj}-fieldName`}
275-
>
314+
<EuiFlexItem grow={false} data-test-subj={`fieldName ${dataTestSubj}-fieldName`}>
276315
{source.name}
277316
</EuiFlexItem>
278317

0 commit comments

Comments
 (0)