-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
[7.5] [Index template] Fix editor should support mappings types (#55804) #56279
Conversation
Pinging @elastic/es-ui (Team:Elasticsearch UI) |
There was a problem hiding this 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: { |
There was a problem hiding this comment.
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]; |
There was a problem hiding this comment.
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 } = { |
There was a problem hiding this comment.
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 => { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
Thanks for the review @cjcenizal !
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 👍 |
There was a problem hiding this 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!
Great thanks for the PR @cjcenizal ! |
@elasticmachine merge upstream |
…-support-mappings-types
💚 Build SucceededHistory
To update your PR or re-run it, just comment with: |
This PR is the backport of #55804 for the
7.5
branch. As the original fix relies on the mappings editorlib
files, I manually copied the neededlib
files,constants
files andtype.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.
As this is not a 1:1 backport from the original PR can you have a look @cjcenizal ? Thanks!