-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Mappings editor] Add support for histogram field type (#76671)
- Loading branch information
1 parent
53c8fad
commit 11f100b
Showing
18 changed files
with
167 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
...components/mappings_editor/components/document_fields/field_parameters/meta_parameter.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import React, { FunctionComponent } from 'react'; | ||
|
||
import { i18n } from '@kbn/i18n'; | ||
|
||
import { documentationService } from '../../../../../services/documentation'; | ||
import { UseField, JsonEditorField } from '../../../shared_imports'; | ||
import { getFieldConfig } from '../../../lib'; | ||
import { EditFieldFormRow } from '../fields/edit_field'; | ||
|
||
interface Props { | ||
defaultToggleValue: boolean; | ||
} | ||
|
||
export const MetaParameter: FunctionComponent<Props> = ({ defaultToggleValue }) => ( | ||
<EditFieldFormRow | ||
title={i18n.translate('xpack.idxMgmt.mappingsEditor.metaParameterTitle', { | ||
defaultMessage: 'Set metadata', | ||
})} | ||
description={i18n.translate('xpack.idxMgmt.mappingsEditor.metaParameterDescription', { | ||
defaultMessage: 'Arbitrary information about the field. Specify as JSON key-value pairs.', | ||
})} | ||
defaultToggleValue={defaultToggleValue} | ||
docLink={{ | ||
text: i18n.translate('xpack.idxMgmt.mappingsEditor.metaParameterDocLinkText', { | ||
defaultMessage: 'Metadata documentation', | ||
}), | ||
href: documentationService.getMetaLink(), | ||
}} | ||
> | ||
<UseField | ||
path="meta" | ||
config={getFieldConfig('meta')} | ||
component={JsonEditorField} | ||
componentProps={{ | ||
euiCodeEditorProps: { | ||
height: '300px', | ||
'aria-label': i18n.translate('xpack.idxMgmt.mappingsEditor.metaParameterAriaLabel', { | ||
defaultMessage: 'metadata field data editor', | ||
}), | ||
}, | ||
}} | ||
/> | ||
</EditFieldFormRow> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
...mponents/mappings_editor/components/document_fields/fields/field_types/histogram_type.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
import React from 'react'; | ||
|
||
import { NormalizedField, Field as FieldType, ParameterName } from '../../../../types'; | ||
import { getFieldConfig } from '../../../../lib'; | ||
import { IgnoreMalformedParameter, MetaParameter } from '../../field_parameters'; | ||
import { AdvancedParametersSection } from '../edit_field'; | ||
|
||
interface Props { | ||
field: NormalizedField; | ||
} | ||
|
||
const getDefaultToggleValue = (param: ParameterName, field: FieldType) => { | ||
return field[param] !== undefined && field[param] !== getFieldConfig(param).defaultValue; | ||
}; | ||
|
||
export const HistogramType = ({ field }: Props) => { | ||
return ( | ||
<AdvancedParametersSection> | ||
<IgnoreMalformedParameter /> | ||
|
||
<MetaParameter defaultToggleValue={getDefaultToggleValue('meta', field.source)} /> | ||
</AdvancedParametersSection> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.