-
Notifications
You must be signed in to change notification settings - Fork 12
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
Connect state of save/revert buttons to something sensible #310
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #310 +/- ##
==========================================
+ Coverage 73.71% 73.80% +0.09%
==========================================
Files 27 27
Lines 3390 3402 +12
==========================================
+ Hits 2499 2511 +12
Misses 891 891 ☔ View full report in Codecov by Sentry. |
""" | ||
A handler must take an argument but we don't use it here. | ||
""" | ||
needs_to_save = widget.is_valid and widget.savebuttonbar.unsaved_changes |
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.
Clever bit of logic here.
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 had to break it into steps because I was confusing myself when I tried to make it a single line 😬
# Which means we don't need the button to show/hide them | ||
assert ui.bn_shownull.layout.display == "none" | ||
|
||
# For now we do not show the validaation output because it is painfully |
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.
Typo of "validation", somewhat ironic since it passed initial review by the author....
|
||
# So it turns out that the validation stuff only updates when changes are made | ||
# in the UI rather than programmatically. Since we know we've set a valid value, | ||
# and that we've made changes we just manually set the relevant values. |
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 rather sad, forcing the test to work, but I suppose it checks that changing ui.savebuttonbar.unsaved_changes
and ui.is_valid.value
have the intended effects on the save button.
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.
Yeah, this was not my first choice. I tried calling the handlers that I thought ipyautoui
was invoking, but i) they were private (started with _
) and ii) didn't do anything.
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.
Might want to fix the typo, otherwise all good.
Remove save button code made unnecessary by #310
I think the save and revert buttons should only be enabled when the value of the widget is valid (in the pydantic model sense) and there are unsaved changes.
This PR does that, and adds a test for it.