Skip to content

Commit

Permalink
[Mappings editor] Handle unsupported field types
Browse files Browse the repository at this point in the history
  • Loading branch information
ElenaStoeva committed Oct 29, 2024
1 parent e70b533 commit aed02e7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,7 @@ export const getFieldsMatchingFilterFromState = (
} => {
return Object.fromEntries(
Object.entries(state.fields.byId).filter(([_, fieldId]) =>
filteredDataTypes.includes(TYPE_DEFINITION[state.fields.byId[fieldId.id].source.type].label)
filteredDataTypes.includes(getTypeLabelFromField(state.fields.byId[fieldId.id].source))
)
);
};
Expand All @@ -646,9 +646,7 @@ export const getFieldsFromState = (
const getField = (fieldId: string) => {
if (filteredDataTypes) {
if (
filteredDataTypes.includes(
TYPE_DEFINITION[normalizedFields.byId[fieldId].source.type].label
)
filteredDataTypes.includes(getTypeLabelFromField(normalizedFields.byId[fieldId].source))
) {
return normalizedFields.byId[fieldId];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ import {
deNormalizeRuntimeFields,
getAllFieldTypesFromState,
getFieldsFromState,
getTypeLabelFromField,
} from './lib';
import { useMappingsState, useDispatch } from './mappings_state_context';
import { TYPE_DEFINITION } from './constants';

interface Args {
onChange?: OnUpdateHandler;
Expand Down Expand Up @@ -56,7 +56,7 @@ export const useMappingsStateListener = ({ onChange, value, status }: Args) => {
const allFieldsTypes = getAllFieldTypesFromState(deNormalize(normalize(mappedFields)));
return allFieldsTypes.map((dataType) => ({
checked: undefined,
label: TYPE_DEFINITION[dataType].label,
label: getTypeLabelFromField({ type: dataType }),
'data-test-subj': `indexDetailsMappingsSelectFilter-${dataType}`,
}));
}, [mappedFields]);
Expand Down

0 comments on commit aed02e7

Please sign in to comment.