forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
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 constant_keyword field type (elasti…
- Loading branch information
1 parent
475ba3e
commit 40d919f
Showing
6 changed files
with
196 additions
and
2 deletions.
There are no files selected for viewing
82 changes: 82 additions & 0 deletions
82
...s/mappings_editor/components/document_fields/fields/field_types/constant_keyword_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,82 @@ | ||
/* | ||
* 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, Field, JsonEditorField } from '../../../../shared_imports'; | ||
import { getFieldConfig } from '../../../../lib'; | ||
import { NormalizedField } from '../../../../types'; | ||
import { AdvancedParametersSection, EditFieldFormRow, BasicParametersSection } from '../edit_field'; | ||
|
||
interface Props { | ||
field: NormalizedField; | ||
} | ||
|
||
export const ConstantKeywordType: FunctionComponent<Props> = ({ field }) => { | ||
return ( | ||
<> | ||
<BasicParametersSection> | ||
{/* Value field */} | ||
<EditFieldFormRow | ||
title={i18n.translate('xpack.idxMgmt.mappingsEditor.constantKeyword.valueFieldTitle', { | ||
defaultMessage: 'Set value', | ||
})} | ||
description={i18n.translate( | ||
'xpack.idxMgmt.mappingsEditor.constantKeyword.valueFieldDescription', | ||
{ | ||
defaultMessage: | ||
'The value of this field for all documents in the index. If not specified, defaults to the value specified in the first document indexed.', | ||
} | ||
)} | ||
defaultToggleValue={field.source?.value !== undefined} | ||
> | ||
<UseField path="value" config={getFieldConfig('value')} component={Field} /> | ||
</EditFieldFormRow> | ||
</BasicParametersSection> | ||
|
||
<AdvancedParametersSection> | ||
{/* Meta field */} | ||
<EditFieldFormRow | ||
title={i18n.translate('xpack.idxMgmt.mappingsEditor.constantKeyword.metaFieldTitle', { | ||
defaultMessage: 'Set metadata', | ||
})} | ||
description={i18n.translate( | ||
'xpack.idxMgmt.mappingsEditor.constantKeyword.metaFieldDescription', | ||
{ | ||
defaultMessage: | ||
'Arbitrary information about the field. Specify as JSON key-value pairs.', | ||
} | ||
)} | ||
defaultToggleValue={field.source?.meta !== undefined} | ||
docLink={{ | ||
text: i18n.translate('xpack.idxMgmt.mappingsEditor.constantKeyword.metaDocLinkText', { | ||
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.constantKeyword.metaFieldAriaLabel', | ||
{ | ||
defaultMessage: 'metadata field data editor', | ||
} | ||
), | ||
}, | ||
}} | ||
/> | ||
</EditFieldFormRow> | ||
</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
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