-
Notifications
You must be signed in to change notification settings - Fork 8.5k
[Composable template] Demo and PR review fixes #71065
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
[Composable template] Demo and PR review fixes #71065
Conversation
|
Pinging @elastic/es-ui (Team:Elasticsearch UI) |
jloleysens
left a comment
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 is looking good @sebelga , great work!
Remarks on UI/UX:
Borders
I noticed that the mappings editor does not have a border top, I am guessing this is intentional but it did look a little weird to me:
Similarly for the global view selector (this time the right border looks like it is "missing")
Drag 'n drop composable templates
Not a massive issue at all, but thought dragging a component template outside of the droppable area should not cut it off, at the moment it does (not really visible in screenshot, just adding to confirm what I am referring to)
Fuzzy match bug
I noticed adding a regex char into the search component templates bar caused the UI to hard crash with this error (provided input logs*):
Uncaught SyntaxError: Invalid regular expression: /.*l.*o.*g.*s.**.*/: Nothing to repeat
at new RegExp (<anonymous>)
at fuzzyMatch (component_templates.tsx:17)
at component_templates.tsx:82
at Array.filter (<anonymous>)
at component_templates.tsx:65
at updateMemo (react-dom.development.js:16854)
at Object.useMemo (react-dom.development.js:17334)
at useMemo (react.development.js:1643)
at ComponentTemplates (component_templates.tsx:60)
at renderWithHooks (react-dom.development.js:16260)
We can reuse kibana/x-pack/plugins/index_management/public/application/components/mappings_editor/lib/search_fields.tsx escapeRegExp function to address this. Perhaps we can move this to es-ui-shared (not necessary for now though).
Navigation
Unrelated to this PR, but just wanted to field the idea here. Clicking between composable templates and index templates (or any other tab in Index Management) feels like a bit of a chore. I think we could help users out by remembering what tab they were last on in index management and going back there, only when they have actually entered the app and started click between tabs (i.e., do not persist in localStorage that could be annyoing in a different way). Let me know what you think!
| import { TemplateDeserialized, TemplateType, TemplateListItem } from '../../common'; | ||
|
|
||
| const objHasProperties = (obj?: Record<string, any>): boolean => { | ||
| return obj === undefined || Object.keys(obj).length === 0 ? false : true; |
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.
Not sure this function name and the logic match up for me. I would expect objHasProperties to return false for when the value passed in is undefined.
Object.keys(obj).length === 0 ? false : true can be written as Object.keys(obj).length !== 0
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 would expect objHasProperties to return false for when the value passed in is undefined.
🤔 hmmm isn't it what this code does?
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.
Maybe the code could be made a bit more verbose to make its behavior more obvious?
const objHasProperties = (obj?: Record<string, any>): boolean => {
if (obj === undefined) {
return false;
}
if (Object.keys(obj).length === 0) {
return false;
}
return true;
}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 see that I misread the precedence of the evaluation.
I thought obj === undefined would short-circuit Object.keys(obj).length === 0... check. That is also why I recommended changing it to Object.keys(obj).length !== 0. If prettier allows, adding () around the predicate could also help.
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 to clarify; I am happy with return obj !== undefined && Object.keys(obj).length !== 0. Or CJ's suggestion :)
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.
What is wrong with the "or" operator? 😄
const objHasProperties = (obj?: Record<string, any>): boolean => {
if (obj === undefined || Object.keys(obj).length === 0) {
return false;
}
return true;
}And then, I decided to use a ternary to remove the if clause.
I thought obj === undefined would short-circuit Object.keys(obj).length === 0...
I does short-circuit so it does not execute Object.keys(...) on an undefined value
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 does short-circuit so it does not execute Object.keys(...) on an undefined value
I see my comment was not very clear, I meant short circuit the whole -> Object.keys(obj).length === 0 ? false : true part of the line (which is wrong). This is a case where the JS grammar seems ambiguous to me.
I'll leave it up to you!
|
Thanks for the review @jloleysens ! For the borders, it is all EUI so I prefer to leave it like this for the moment. We could revisit and see if this is inconsistent with the rest of Kibana.
Good call. 👍 This is also EUI that adds a
Great catch! I've copied the sanitized function over and fixed it 👍
This is a great point. There has been multiple times I wish we had a simple Can you have another look at the PR and give it a 👍 if everything is good? |
…e-template-review-changes
jloleysens
left a comment
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.
Thanks for making those changes @sebelga !
Tested again locally and everything looks to be in order 🍻
| description: ( | ||
| <FormattedMessage | ||
| id="xpack.idxMgmt.templateForm.stepLogistics.dataStreamDescription" | ||
| defaultMessage="Wheter indices that match the index patterns should automatically create a data stream. {docsLink}" |
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.
"Wheter" is misspelled, and I don't think we need a line break between these two sentences. I'd also suggest rewording the text as an action but would like to hear @jrodewig's input:
Create a data stream instead of an index. Learn more about data streams.
| docsLink: ( | ||
| <> | ||
| <br /> | ||
| <EuiLink href={`${esDocsBase}/data-streams.html`} target="_blank"> |
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.
Can we use documentationService.getDataStreamsDocumentationLink() for this href instead? And I think we need to add the external prop to this link.
💚 Build SucceededBuild metrics
History
To update your PR or re-run it, just comment with: |
|
@cjcenizal I'm going to go ahead and merge this PR since CI is finally green 😄 . I'll address your comments in a separate PR. |
# Conflicts: # x-pack/plugins/index_management/public/application/components/mappings_editor/mappings_state.tsx



In this PR I've addressed all the concerns during the demo regarding the creation/edition flow of composable index templates. I've also addressed the PR review changes from @alisonelizabeth and @jrodewig in #70814
Changes
_metaparameter behind a toggle (bb56efa)templateparameter of the payload (f8b0425)It is important to not send a template object with empty content like so
I've updated the code to strip those out. Now, if you navigate to the "Index settings" tab, the "Mappings" tab or the "Aliases" tab and don't make any changes, you should be able to preview the request in the "Review" step and see that no "template" is provided
Note there is still an outstanding issue that we will need to address at the form lib level: if you navigate to the "Advanced options" of the mappings editor, and then you go check the request in the "Review" step, all the default values for the mappings will be present.
@alisonelizabeth You might want to copy what I did here in the component template form wizard. Then when you get to the Review step, if there is no "template" in the body, show a red callout and not allow saving the component.
Order the component templates by name in the "Component templates" step (913cfeb)
Add the missing "Data stream" toggle field in the "Logistics" step (a4bf5e4)