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

Prevents negative values for Snapshot retention policies #51295

Conversation

ffknob
Copy link
Contributor

@ffknob ffknob commented Nov 21, 2019

Summary

Related to #51134

Sets the min prop of the EuiFieldNumber to 0 so the user cannot use the arrow controls to get to a negative number. Also prevents the user from entering manually the - symbol.

Checklist

Use strikethroughs to remove checklist items you don't feel are applicable to this PR.

For maintainers

@elasticmachine
Copy link
Contributor

Since this is a community submitted pull request, a Jenkins build has not been kicked off automatically. Can an Elastic organization member please verify the contents of this patch and then kick off a build manually?

1 similar comment
@elasticmachine
Copy link
Contributor

Since this is a community submitted pull request, a Jenkins build has not been kicked off automatically. Can an Elastic organization member please verify the contents of this patch and then kick off a build manually?

@alisonelizabeth alisonelizabeth added bug Fixes for quality problems that affect the customer experience Feature:Snapshot and Restore Elasticsearch snapshots and repositories UI 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.6.0 v8.0.0 labels Nov 21, 2019
@elasticmachine
Copy link
Contributor

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

@alisonelizabeth
Copy link
Contributor

@ffknob thanks so much for the contribution! 😄 I will try to take a look at this sometime next week.

@cuff-links
Copy link
Contributor

jenkins test this

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@alisonelizabeth
Copy link
Contributor

@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.

@ffknob nice work! Thanks again for this contribution.

I left one suggested change around how to handling the validation. Let me know if you have any questions.

@@ -93,13 +93,19 @@ export const PolicyStepRetention: React.FunctionComponent<StepProps> = ({
<EuiFieldNumber
value={retention.expireAfterValue || ''}
onBlur={() => setTouched({ ...touched, expireAfterValue: true })}
onKeyDown={e => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Rather than preventing the user from entering the - symbol, I think it might be better to add a new validation rule that prevents negative numbers. This way, a validation error message will appear as well, and the user will not be able to proceed to the next step until it is corrected.

For example, there is currently validation in place so that a user cannot set the min_count greater than max_count.

Screen Shot 2019-11-25 at 1 47 48 PM

You should be able to modify this file: https://github.com/elastic/kibana/blob/cda7eba4c9dbb3739c726a194ceed155111f15fc/x-pack/legacy/plugins/snapshot_restore/public/app/services/validation/validate_policy.ts

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @alisonelizabeth thanks for the tip. It surely looks better as a validation.
I did some testing and it looks like the image below.

I also tryied to add a Jest test, but I don't know eactly how to run it locally (do you? I mean, doyou know how I could have run specifically the x-pack/legacy/plugins/snapshot_restore/__jest__/client_integration/policy_add.test.ts test locally before pushing?)

Let me know what do you think!

Bildschirmfoto vom 2019-11-25 20-17-19

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.

@ffknob this looks great! Thanks!

In regards to your question, the tests are currently being skipped, as they require react 16.9 for testing asynchronous code inside act() and we're not quite ready to upgrade across kibana. In order to run locally, you would need to install the newer version of react and remove the skip. I tested your changes locally and also ran the tests and confirmed they're all green 🎉

Screen Shot 2019-11-25 at 10 07 57 PM

I will take care of merging the PR and backporting once CI is green 😄

@alisonelizabeth
Copy link
Contributor

jenkins test this

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Fixes for quality problems that affect the customer experience Feature:Snapshot and Restore Elasticsearch snapshots and repositories UI 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.6.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants