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

[ILM] Convert node allocation component to TS and use hooks #72888

Merged
merged 15 commits into from
Aug 6, 2020

Conversation

yuliacech
Copy link
Contributor

@yuliacech yuliacech commented Jul 22, 2020

Summary

This PR is a part of an ongoing effort to convert ILM codebase from JavaScript to TypeScript. In this PR, NodeAllocation component of the ILM policy edit page (in warm and cold phases) has been refactored. As a result, the component will not use the redux store for loaded node attributes anymore, but it will use a hook for that. Also a callout was added for the case, when the request fails.

Error loading node attributes

Before

  • Loading indicator never disappears.
  • No way to try reloading node attributes.
    node_attrs_error_before

After

  • Loading indicator is only shown while the request is in progress.
  • A callout was added where the user can try to reload node attributes.
    Error_loading_nodes_attributes

Checklist

@yuliacech yuliacech added Feature:ILM v7.10.0 v8.0.0 release_note:skip Skip the PR/issue when compiling release notes Team:Kibana Management Dev Tools, Index Management, Upgrade Assistant, ILM, Ingest Node Pipelines, and more labels Jul 22, 2020
@yuliacech
Copy link
Contributor Author

@elasticmachine merge upstream

@yuliacech yuliacech marked this pull request as ready for review July 24, 2020 15:50
@yuliacech yuliacech requested a review from a team as a code owner July 24, 2020 15:50
@elasticmachine
Copy link
Contributor

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

@yuliacech
Copy link
Contributor Author

@elasticmachine merge upstream

Copy link
Contributor

@alisonelizabeth alisonelizabeth left a comment

Choose a reason for hiding this comment

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

Nice work @yuliacech! This is a great improvement. I left a few comments in the code. I think some of the things I noticed were pre-existing, but would be nice to address as part of the refactor.

@yuliacech
Copy link
Contributor Author

@elasticmachine merge upstream

@yuliacech
Copy link
Contributor Author

Hi @alisonelizabeth ,
thank you for such a detailed code review!
I implemented everything you commented on, could you please have another look?

Copy link
Contributor

@alisonelizabeth alisonelizabeth left a comment

Choose a reason for hiding this comment

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

Thanks @yuliacech for making the suggested changes! Overall LGTM.

I found a couple other minor things when I did a second round of testing. I think it would be nice if they could be addressed before merging, but I'm going to go ahead and approve to not block you.

  • Invalid doc link (commented in code)
  • I didn't check if this is a regression or not, but the "View a list of nodes..." link doesn't appear to be aligned correctly when I have node attributes configured.

Screen Shot 2020-07-29 at 9 08 44 PM

  • [nit] The error callout is a little hard for me to parse with the status code, error string, and error message in the same <p> tag. It may be worth reaching out to design - or maybe the docs team is more appropriate - for feedback.

Screen Shot 2020-07-29 at 9 07 08 PM

@yuliacech
Copy link
Contributor Author

yuliacech commented Jul 30, 2020

Great suggestions, @alisonelizabeth !
I fixed the docs link and the "View list ..." link.
Screenshot 2020-07-30 at 15 45 29

There was also a type check error, so I added a type for the api error:

export const useRequest = <T = any, E = { statusCode: number; error: string; message: string }>(

@yuliacech yuliacech requested a review from esdocs July 30, 2020 13:54
@yuliacech
Copy link
Contributor Author

Hello @esdocs team,

I added a new callout instead of a toast notification when there is an error loading node attributes. I used the same wording for error information but it seems a bit hard to read. So I was hoping for some feedback to improve it.

Toast notification before:
node_attrs_error_before

New callout:
Error_loading_nodes_attributes

The text is build like this: {statusCode}: {errorString}. {message} where statusCode is 404, 500 etc, errorString is "Bad Request", "Internal Server Error" etc and message is the information from API error but can be the same as errorString.
Some examples of current callout wordings:
Screenshot 2020-07-30 at 15 28 42
Screenshot 2020-07-30 at 15 36 31
Screenshot 2020-07-29 at 18 07 28

@yuliacech
Copy link
Contributor Author

@elasticmachine merge upstream

@yuliacech
Copy link
Contributor Author

@elasticmachine merge upstream

@lockewritesdocs
Copy link

@yuliacech, thanks for the ping 👍 I’m curious whether we want to display {errorString} if we’re essentially restating the same information in the {message}. I suggest refocusing the content to put the message first, removing {errorString}, and putting the {statusCode} last.

Pinging @probakowski and @leehinman to provide any additional context that might be useful to the user in understanding these messages.

Unable to load node attributes
Elasticsearch failed to load node attributes (400).

Unable to load node attributes
Elasticsearch cannot find node attributes (404).

Unable to load node attributes
Elasticsearch encountered an internal server error (500).

@yuliacech
Copy link
Contributor Author

@elasticmachine merge upstream

@yuliacech
Copy link
Contributor Author

@elasticmachine merge upstream

@yuliacech
Copy link
Contributor Author

Thanks a lot for your suggestion, @lockewritesdocs !
I updated how error is displayed, would you mind having another look?
Screenshot 2020-08-06 at 15 39 44

Copy link

@lockewritesdocs lockewritesdocs left a comment

Choose a reason for hiding this comment

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

Left a very minor suggestion, but 👍 otherwise!

title={
<FormattedMessage
id="xpack.indexLifecycleMgmt.editPolicy.nodeAttributesLoadingFailedTitle"
defaultMessage="Unable to load node attributes."

Choose a reason for hiding this comment

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

Suggest removing the period here, but that's totally minor. If having a period at the end matches other Kibana error message conventions, then please ignore.

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Build metrics

@kbn/optimizer bundle module count

id value diff baseline
indexLifecycleManagement 177 -1 178

async chunks size

id value diff baseline
indexLifecycleManagement 268.5KB -6.5KB 275.0KB

page load bundle size

id value diff baseline
indexLifecycleManagement 238.3KB -375.0B 238.7KB

History

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

@yuliacech yuliacech merged commit d764499 into elastic:master Aug 6, 2020
@yuliacech yuliacech deleted the ilm_typescript branch August 6, 2020 16:06
@yuliacech yuliacech restored the ilm_typescript branch August 6, 2020 16:06
yuliacech added a commit to yuliacech/kibana that referenced this pull request Aug 6, 2020
…72888)

* [ILM] Convert node allocation component to TS and use hooks

* [ILM] Fix jest tests

* [ILM] Fix i18n check

* [ILM] Implement code review suggestions

* [ILM] Fix type check, docs link and button maxWidth in NodeAllocation component

* Fix internaliation error

* [ILM] Change error message when unable to load node attributes

* [ILM] Delete a period in error callout

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
yuliacech added a commit that referenced this pull request Aug 6, 2020
…74556)

* [ILM] Convert node allocation component to TS and use hooks

* [ILM] Fix jest tests

* [ILM] Fix i18n check

* [ILM] Implement code review suggestions

* [ILM] Fix type check, docs link and button maxWidth in NodeAllocation component

* Fix internaliation error

* [ILM] Change error message when unable to load node attributes

* [ILM] Delete a period in error callout

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
@yuliacech yuliacech deleted the ilm_typescript branch August 6, 2020 17:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:ILM release_note:skip Skip the PR/issue when compiling release notes Team:Kibana Management Dev Tools, Index Management, Upgrade Assistant, ILM, Ingest Node Pipelines, and more v7.10.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants