Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
111 commits
Select commit Hold shift + click to select a range
0d4922a
[Mappings editor] Core (#47335)
Oct 8, 2019
b2212c2
Remove unnecessary call to updateFormValidity() in validateAllFields()
Oct 8, 2019
5037b6b
Merge remote-tracking branch 'upstream/master' into feature/mappings-…
Oct 8, 2019
513fb38
Move mappings_editor from "static" to "public" folder
Oct 8, 2019
9d34a5d
[Mappings editor] Integrate inside Template UI (#47567)
Oct 8, 2019
3f0ca29
Merge remote-tracking branch 'upstream/master' into feature/mappings-…
Oct 8, 2019
c9ffd0f
Merge remote-tracking branch 'upstream/master' into feature/mappings-…
Oct 9, 2019
183ed1e
[Mappings editor] Add json editor to edit field settings (#47674)
Oct 9, 2019
b72e6d1
[Mappings Editor] JSON Editor (#47589)
jloleysens Oct 10, 2019
f4bec1a
Merge remote-tracking branch 'upstream/master' into feature/mappings-…
Oct 15, 2019
1054c0e
Merge remote-tracking branch 'upstream/master' into feature/mappings-…
Oct 22, 2019
1ffc5d5
[Mappings editor] Add UI/UX to mappings core (#48876)
Oct 23, 2019
e72a64b
Merge remote-tracking branch 'upstream/master' into feature/mappings-…
Oct 29, 2019
a6a3c42
[mapping editor]: Text, Keyword & Numeric types (#49594)
Oct 29, 2019
4841838
Index mappings editor text (#49937)
alisonelizabeth Nov 1, 2019
59a7730
[IM] [Mappings Editor] Boolean, binary and range parameters (#49950)
alisonelizabeth Nov 13, 2019
a01dabc
Merge branch 'master' into feature/mappings-editor
elasticmachine Nov 14, 2019
5f1949f
[Mappings editor] Alias type (#50643)
Nov 15, 2019
ac682ed
[Mappings editor]: Addons and bug fixes (#51018)
Nov 19, 2019
6789b59
Merge branch 'master' into merge_master
alisonelizabeth Nov 19, 2019
652be19
Merge branch 'master' into feature/mappings-editor
elasticmachine Nov 21, 2019
b72f02a
[Mappings editor] Add Search as you type, Flattened, Shape (#51276)
Nov 22, 2019
aa1e38d
Merge remote-tracking branch 'upstream/master' into feature/mappings-…
Nov 22, 2019
4e7479f
[Mappings editor]: Fix issues (#51429)
Nov 22, 2019
aaabbf7
[IM] [Mappings Editor] Date, Geopoint, Geoshape, IP, Completion, Toke…
alisonelizabeth Nov 23, 2019
b311958
address stakeholder feedback (#51550)
alisonelizabeth Nov 25, 2019
bc6b757
Merge branch 'master' into feature/mappings-editor
elasticmachine Nov 26, 2019
44c6cdd
[Mappings editor] Address feedback/bugs (#51747)
alisonelizabeth Dec 3, 2019
a677af6
Merge branch 'master' into feature/mappings-editor
elasticmachine Dec 3, 2019
6994087
[Mappings editor] fix existing tests (#52124)
alisonelizabeth Dec 4, 2019
7f36e7c
[Mappings editor] Prevent hover state on disabled field list items (#…
cjcenizal Dec 4, 2019
56e94ea
Merge branch 'master' into feature/mappings-editor
elasticmachine Dec 4, 2019
e69a54b
[Mappings editor] Stack revealed controls vertically (#52142)
cjcenizal Dec 6, 2019
369897a
[Mappings editor] Component integration tests for template wizard (#5…
alisonelizabeth Dec 9, 2019
d3f78b3
Merge branch 'master' into feature/mappings-editor
elasticmachine Dec 11, 2019
19fde18
[Mappings editor] Improvements to configuration section (#52650)
alisonelizabeth Dec 11, 2019
06ec5ee
[Mappings editor] Add dims parameter to dense vector (#52785)
alisonelizabeth Dec 11, 2019
79a63b4
[Mappings editor] Fix bug when loading an index template that has no …
cjcenizal Dec 12, 2019
6ea0b61
[Mappings editor] Refine Alias and Flattened data types (#52363)
cjcenizal Dec 12, 2019
2a3317f
[Mappings editor] Flatten field type list (#52400)
alisonelizabeth Dec 12, 2019
759d6d0
[Mappings editor] Add scaling_factor as a required parameter (#52819)
alisonelizabeth Dec 12, 2019
4e6c892
Fix behavior of null value fields for keyword, boolean, numeric, and …
cjcenizal Dec 12, 2019
6966043
Merge branch 'master' into feature/mappings-editor
elasticmachine Dec 12, 2019
e48857a
Refine data type flyout layout and support doc links in mappings edit…
cjcenizal Dec 13, 2019
1076efb
Add link to mapping types documentation. (#53036)
cjcenizal Dec 14, 2019
537edef
Merge branch 'master' into feature/mappings-editor
elasticmachine Dec 15, 2019
0410e1b
[Mappings editor] Address inconsistencies in basic/advanced sections …
alisonelizabeth Dec 16, 2019
1e95b3c
[Mappings editor] Improvements to multi-field (#53061)
alisonelizabeth Dec 16, 2019
1f69f5e
Merge branch 'master' into feature/mappings-editor
elasticmachine Dec 17, 2019
38cc1e1
[Mappings editor] Add doc links to parameters (#53197)
alisonelizabeth Dec 17, 2019
58e2a24
[Mappings editor] Add callout when fielddata is enabled (#53247)
alisonelizabeth Dec 17, 2019
b3f338c
Merge branch 'master' into feature/mappings-editor
elasticmachine Dec 17, 2019
bb4a940
Support _source field in mappings editor (#53525)
cjcenizal Dec 19, 2019
6b899f7
Merge branch 'master' into feature/mappings-editor
elasticmachine Dec 19, 2019
567ed9e
[Mappings editor] Keyword data type copy improvements (#53319)
alisonelizabeth Dec 19, 2019
558814b
Merge branch 'master' into feature/mappings-editor
elasticmachine Dec 19, 2019
7174ace
Add description text for Text data type and refactor data type sectio…
cjcenizal Dec 20, 2019
43f5396
[Mappings editor] Copy improvements for geo-shape, geo-point and shap…
alisonelizabeth Dec 20, 2019
6136e9d
[Mappings editor] Improvements to boolean, binary and ip copy (#53329)
alisonelizabeth Dec 21, 2019
afd3269
Refine text type description copy. (#53741)
cjcenizal Dec 21, 2019
f65f880
Merge branch 'master' into feature/mappings-editor
elasticmachine Dec 23, 2019
7cf54eb
[Mappings editor]: fix bugs (#53556)
sebelga Dec 23, 2019
1d8d03e
Merge branch 'master' into feature/mappings-editor
elasticmachine Dec 26, 2019
01d2339
Fix Tree item css
Dec 27, 2019
873cf54
Revert "Fix Tree item css"
Dec 27, 2019
a35d6f8
Merge branch 'master' into feature/mappings-editor
elasticmachine Dec 30, 2019
33c27df
Fix Tree item css (#53820)
Dec 30, 2019
7b83979
[Mappings editor]: load from JSON object (#53790)
Dec 30, 2019
eb3db9b
[Mappings editor] Fix analyzer bug (#53765)
Dec 30, 2019
d54fda8
Add support for _meta field (#53740)
cjcenizal Dec 31, 2019
4d289f8
Merge branch 'master' into feature/mappings-editor
elasticmachine Jan 2, 2020
4e2cc85
[Mappings editor] Support absolute value for fielddata_frequency_filt…
Jan 2, 2020
40fb0b9
[Mappings editor] Fix warning about alias to be deleted (#53818)
Jan 3, 2020
a24595c
Allow periods in mapping field names (#53895)
alisonelizabeth Jan 3, 2020
f6f562a
[Mappings editor] Description text for shape, geo-point types (#53943)
alisonelizabeth Jan 6, 2020
0d36bf5
Merge branch 'master' of github.com:elastic/kibana into feature/mappi…
alisonelizabeth Jan 7, 2020
48c314b
add back translations
alisonelizabeth Jan 7, 2020
9fa562e
fix jest tests
alisonelizabeth Jan 7, 2020
bb7527f
Merge branch 'master' into feature/mappings-editor
elasticmachine Jan 8, 2020
943318f
update geo-point description text (#54113)
alisonelizabeth Jan 8, 2020
6c60f4d
Update UX for fielddata percentage / absolute frequency (#53966)
alisonelizabeth Jan 8, 2020
6694eba
[Mappings editor] Update date, date-nanos copy (#54022)
alisonelizabeth Jan 8, 2020
2491221
Merge remote-tracking branch 'upstream/master' into feature/mappings-…
sebelga Jan 9, 2020
ebb183b
[Mappings editor] Fix UI and performance issues (#54224)
sebelga Jan 9, 2020
5d266c2
Fix: don't allow "join" type for non root field (create or edit) (#54…
sebelga Jan 9, 2020
a3c4e0a
Fix merge conflict resolution
sebelga Jan 9, 2020
9963397
add data type to multi-field badge (#54295)
alisonelizabeth Jan 9, 2020
0e2f181
[Mappings editor] Refactor field "path" format (#54146)
sebelga Jan 9, 2020
95e5e30
Merge branch 'master' into feature/mappings-editor
elasticmachine Jan 9, 2020
c7bbe40
fix TS errors
alisonelizabeth Jan 9, 2020
4e907c5
[Mappings editor] Add range copy + support for subtype descriptions (…
alisonelizabeth Jan 9, 2020
6290577
Merge branch 'master' into feature/mappings-editor
elasticmachine Jan 10, 2020
cd96c35
[Mappings editor] Set default value for configuration's raw and forma…
cjcenizal Jan 11, 2020
9592a52
Merge branch 'master' into feature/mappings-editor
elasticmachine Jan 13, 2020
b1a01e9
Allow spaces in field names. (#54529)
cjcenizal Jan 13, 2020
039dd38
Add help text to explain fielddata frequency and min segment size. (#…
cjcenizal Jan 13, 2020
7b4f00c
[Mappings editor] Fix load json button placement (#54533)
alisonelizabeth Jan 13, 2020
d94a35e
[Mappings editor] Support for dynamic templates (#54523)
alisonelizabeth Jan 14, 2020
e8d4566
[Mappings editor] Clarify the loading JSON will overwrite existing ma…
cjcenizal Jan 14, 2020
95a1da1
[Mappings editor] Search fields (#54241)
Jan 14, 2020
19b5309
Merge branch 'master' into feature/mappings-editor
Jan 14, 2020
ef21e52
Merge branch 'master' into feature/mappings-editor
elasticmachine Jan 14, 2020
383abd2
Merge branch 'master' of github.com:elastic/kibana into feature/mappi…
alisonelizabeth Jan 14, 2020
8a91cde
i18n fix
alisonelizabeth Jan 14, 2020
a290821
Merge branch 'master' into feature/mappings-editor
elasticmachine Jan 14, 2020
1888775
[Mappings editor] Add _routing advanced configuration (#54725)
Jan 14, 2020
358e87f
Always show row actions for the fields list in the Mappings Editor (#…
cjcenizal Jan 14, 2020
54e725f
[Mappings editor] Add descriptions for numeric types (#54800)
alisonelizabeth Jan 14, 2020
0e1b76f
add descriptions for data types (#54817)
alisonelizabeth Jan 14, 2020
f425993
[Mappings editor] Add descriptions for join, nested, object, percolat…
cjcenizal Jan 14, 2020
04d1efb
[Mappings editor] Improve data type descriptions. (#54844)
cjcenizal Jan 14, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions src/plugins/es_ui_shared/public/components/json_editor/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

export * from './json_editor';

export { OnJsonEditorUpdateHandler } from './use_json';
111 changes: 111 additions & 0 deletions src/plugins/es_ui_shared/public/components/json_editor/json_editor.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import React, { useCallback } from 'react';
import { EuiFormRow, EuiCodeEditor } from '@elastic/eui';
import { debounce } from 'lodash';

import { isJSON } from '../../../static/validators/string';
import { useJson, OnJsonEditorUpdateHandler } from './use_json';

interface Props {
onUpdate: OnJsonEditorUpdateHandler;
label?: string;
helpText?: React.ReactNode;
value?: string;
defaultValue?: { [key: string]: any };
euiCodeEditorProps?: { [key: string]: any };
error?: string | null;
}

export const JsonEditor = React.memo(
({
label,
helpText,
onUpdate,
value,
defaultValue,
euiCodeEditorProps,
error: propsError,
}: Props) => {
const isControlled = value !== undefined;

const { content, setContent, error: internalError } = useJson({
defaultValue,
onUpdate,
isControlled,
});

const debouncedSetContent = useCallback(debounce(setContent, 300), [setContent]);

// We let the consumer control the validation and the error message.
const error = isControlled ? propsError : internalError;

const onEuiCodeEditorChange = useCallback(
(updated: string) => {
if (isControlled) {
onUpdate({
data: {
raw: updated,
format() {
return JSON.parse(updated);
},
},
validate() {
return isJSON(updated);
},
isValid: undefined,
});
} else {
debouncedSetContent(updated);
}
},
[isControlled]
);

return (
<EuiFormRow
label={label}
helpText={helpText}
isInvalid={typeof error === 'string'}
error={error}
fullWidth
>
<EuiCodeEditor
mode="json"
theme="textmate"
width="100%"
height="500px"
setOptions={{
showLineNumbers: false,
tabSize: 2,
}}
editorProps={{
$blockScrolling: Infinity,
}}
showGutter={false}
minLines={6}
value={isControlled ? value : content}
onChange={onEuiCodeEditorChange}
{...euiCodeEditorProps}
/>
</EuiFormRow>
);
}
);
94 changes: 94 additions & 0 deletions src/plugins/es_ui_shared/public/components/json_editor/use_json.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import { useEffect, useState, useRef } from 'react';
import { i18n } from '@kbn/i18n';

import { isJSON } from '../../../static/validators/string';

export type OnJsonEditorUpdateHandler<T = { [key: string]: any }> = (arg: {
data: {
raw: string;
format(): T;
};
validate(): boolean;
isValid: boolean | undefined;
}) => void;

interface Parameters<T extends object> {
onUpdate: OnJsonEditorUpdateHandler<T>;
defaultValue?: T;
isControlled?: boolean;
}

const stringifyJson = (json: { [key: string]: any }) =>
Object.keys(json).length ? JSON.stringify(json, null, 2) : '{\n\n}';

export const useJson = <T extends object = { [key: string]: any }>({
defaultValue = {} as T,
onUpdate,
isControlled = false,
}: Parameters<T>) => {
const didMount = useRef(false);
const [content, setContent] = useState<string>(stringifyJson(defaultValue));
const [error, setError] = useState<string | null>(null);

const validate = () => {
// We allow empty string as it will be converted to "{}""
const isValid = content.trim() === '' ? true : isJSON(content);
if (!isValid) {
setError(
i18n.translate('esUi.validation.string.invalidJSONError', {
defaultMessage: 'Invalid JSON',
})
);
} else {
setError(null);
}
return isValid;
};

const formatContent = () => {
const isValid = validate();
const data = isValid && content.trim() !== '' ? JSON.parse(content) : {};
return data as T;
};

useEffect(() => {
if (didMount.current) {
const isValid = isControlled ? undefined : validate();
onUpdate({
data: {
raw: content,
format: formatContent,
},
validate,
isValid,
});
} else {
didMount.current = true;
}
}, [content]);

return {
content,
setContent,
error,
};
};
20 changes: 20 additions & 0 deletions src/plugins/es_ui_shared/public/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

export * from './components/json_editor';
6 changes: 3 additions & 3 deletions src/plugins/es_ui_shared/static/forms/components/field.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
* under the License.
*/

import React from 'react';
import React, { ComponentType } from 'react';
import { FieldHook, FIELD_TYPES } from '../hook_form_lib';

interface Props {
field: FieldHook;
euiFieldProps?: Record<string, any>;
euiFieldProps?: { [key: string]: any };
idAria?: string;
[key: string]: any;
}
Expand All @@ -41,7 +41,7 @@ import {
ToggleField,
} from './fields';

const mapTypeToFieldComponent = {
const mapTypeToFieldComponent: { [key: string]: ComponentType<any> } = {
[FIELD_TYPES.TEXT]: TextField,
[FIELD_TYPES.TEXTAREA]: TextAreaField,
[FIELD_TYPES.NUMBER]: NumericField,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export const CheckBoxField = ({ field, euiFieldProps = {}, ...rest }: Props) =>

return (
<EuiFormRow
helpText={field.helpText}
helpText={typeof field.helpText === 'function' ? field.helpText() : field.helpText}
error={errorMessage}
isInvalid={isInvalid}
fullWidth
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export const ComboBoxField = ({ field, euiFieldProps = {}, ...rest }: Props) =>
<EuiFormRow
label={field.label}
labelAppend={field.labelAppend}
helpText={field.helpText}
helpText={typeof field.helpText === 'function' ? field.helpText() : field.helpText}
error={errorMessage}
isInvalid={isInvalid}
fullWidth
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,4 @@ export * from './select_field';
export * from './super_select_field';
export * from './toggle_field';
export * from './text_area_field';
export * from './json_editor_field';
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import React, { useCallback } from 'react';

import { JsonEditor, OnJsonEditorUpdateHandler } from '../../../../public';
import { FieldHook, getFieldValidityAndErrorMessage } from '../../hook_form_lib';

interface Props {
field: FieldHook;
euiCodeEditorProps?: { [key: string]: any };
[key: string]: any;
}

export const JsonEditorField = ({ field, ...rest }: Props) => {
const { errorMessage } = getFieldValidityAndErrorMessage(field);

const { label, helpText, value, setValue } = field;

const onJsonUpdate: OnJsonEditorUpdateHandler = useCallback<OnJsonEditorUpdateHandler>(
updatedJson => {
setValue(updatedJson.data.raw);
},
[setValue]
);

return (
<JsonEditor
label={label}
helpText={helpText}
value={value as string}
onUpdate={onJsonUpdate}
error={errorMessage}
{...rest}
/>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export const MultiSelectField = ({ field, euiFieldProps = {}, ...rest }: Props)
return (
<EuiFormRow
label={field.label}
helpText={field.helpText}
helpText={typeof field.helpText === 'function' ? field.helpText() : field.helpText}
error={errorMessage}
isInvalid={isInvalid}
fullWidth
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export const NumericField = ({ field, euiFieldProps = {}, ...rest }: Props) => {
return (
<EuiFormRow
label={field.label}
helpText={field.helpText}
helpText={typeof field.helpText === 'function' ? field.helpText() : field.helpText}
error={errorMessage}
isInvalid={isInvalid}
fullWidth
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export const RadioGroupField = ({ field, euiFieldProps = {}, ...rest }: Props) =
return (
<EuiFormRow
label={field.label}
helpText={field.helpText}
helpText={typeof field.helpText === 'function' ? field.helpText() : field.helpText}
error={errorMessage}
isInvalid={isInvalid}
fullWidth
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export const RangeField = ({ field, euiFieldProps = {}, ...rest }: Props) => {
return (
<EuiFormRow
label={field.label}
helpText={field.helpText}
helpText={typeof field.helpText === 'function' ? field.helpText() : field.helpText}
error={errorMessage}
isInvalid={isInvalid}
fullWidth
Expand Down
Loading