Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[7.5] [Index template] Fix editor should support mappings types (#55804) #56279

Conversation

sebelga
Copy link
Contributor

@sebelga sebelga commented Jan 29, 2020

This PR is the backport of #55804 for the 7.5 branch. As the original fix relies on the mappings editor lib files, I manually copied the needed lib files, constants files and type.ts file from the mappings editor.

I slightly changed the content of the constants file to avoid having to bring with the whole jungle 😊 (the form hook lib for example).

How to test

Follow the steps in the original PR #55804

The only difference is that here we directly edit the JSON to create custom types.

Screen Shot 2020-01-29 at 15 34 14

Screen Shot 2020-01-29 at 15 34 24

Screen Shot 2020-01-29 at 15 34 35

As this is not a 1:1 backport from the original PR can you have a look @cjcenizal ? Thanks!

@sebelga sebelga added bug Fixes for quality problems that affect the customer experience Feature:Index Management Index and index templates UI Team:Kibana Management Dev Tools, Index Management, Upgrade Assistant, ILM, Ingest Node Pipelines, and more labels Jan 29, 2020
@elasticmachine
Copy link
Contributor

Pinging @elastic/es-ui (Team:Elasticsearch UI)

@sebelga sebelga added backport and removed Feature:Index Management Index and index templates UI Team:Kibana Management Dev Tools, Index Management, Upgrade Assistant, ILM, Ingest Node Pipelines, and more bug Fixes for quality problems that affect the customer experience labels Jan 29, 2020
Copy link
Contributor

@cjcenizal cjcenizal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested locally and it works great! Custom types can be loaded, added/removed, and the changes preserved on save.

I found a lot of code that looks like it's unused. Was this intentional? My initial thought is that if the code isn't needed we should avoid backporting it, to keep both the codebase and the PR easy to understand.


type ParametersOptions = ParameterName | 'languageAnalyzer';

export const PARAMETERS_OPTIONS: {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't look like this is being used. Can we remove it? If so, will this allow us to remove more code as well?


const DATE_FORMAT_OPTIONS = DATE_FORMATS.map(({ label }) => ({ label }));

export const ALL_DATE_FORMAT_OPTIONS = [...DATE_FORMAT_OPTIONS, ...STRICT_DATE_FORMAT_OPTIONS];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also unused?

| TermVectorOptions
| OrientationOptions;

export const FIELD_OPTIONS_TEXTS: { [key in FieldOption]: Optioni18n } = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like removing PARAMETERS_OPTIONS lets us remove getOptionTexts which will also allow us to remove FIELD_OPTIONS_TEXTS.

*
* @param properties A mappings "properties" object
*/
export const validateProperties = (properties = {}): PropertiesValidatorResponse => {
Copy link
Contributor

@cjcenizal cjcenizal Jan 29, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks unused too. Removing it will let us remove its test file too, which will address the CI failure.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, this one is quite important as it is used by the validateMappings() function on L282

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

EDIT: Sorry my bad, validateMappings() is not used on this branch, great catch! I also removed it.

@sebelga
Copy link
Contributor Author

sebelga commented Jan 30, 2020

Thanks for the review @cjcenizal !

I found a lot of code that looks like it's unused. Was this intentional?

I haven't cleaned up the files as I first thought it was better to have them as close as possible from the 7.x branch for future backports... but now that I think about it, it will never happen on those files 😊 So you're right, we need to remove all the unused code.

Can you have another look? thanks 👍

Copy link
Contributor

@cjcenizal cjcenizal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sebelga I found some more opportunities to remove code via sebelga#15. I tested locally and everything works as expected with those changes. If you're OK with merging my PR then I think we're good to go!

@sebelga
Copy link
Contributor Author

sebelga commented Jan 31, 2020

Great thanks for the PR @cjcenizal !

@sebelga
Copy link
Contributor Author

sebelga commented Jan 31, 2020

@elasticmachine merge upstream

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@sebelga sebelga merged commit 8cd0a03 into elastic:7.5 Jan 31, 2020
@sebelga sebelga deleted the backport/7.5/fix-Index-template-editor-should-support-mappings-types branch January 31, 2020 10:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants