-
Notifications
You must be signed in to change notification settings - Fork 691
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
Css: Delete confirmation with css-only modal #2946
Conversation
It looks awesome 💯 ! |
And it works like a charm: manually tested all I could and did not find a problem. Very goooooood :-) |
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 all looks both nice and straightforward. Nicely done !
Please let me know if you need guidance to modify the tests. The failure you see
self = def test_journalist_interface_ui_with_javascript(self): self._source_visits_source_homepage() self._source_chooses_to_submit_documents() self._source_continues_to_submit_page() self._source_submits_a_file() self._source_logs_out() self._journalist_logs_in() self._journalist_uses_js_filter_by_sources() self._journalist_selects_all_sources_then_selects_none() self._journalist_selects_the_first_source() self._journalist_uses_js_buttons_to_download_unread() > self._journalist_delete_all_javascript() tests/functional/test_journalist.py:71: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ tests/functional/journalist_navigation_steps.py:688: in _journalist_delete_all_javascript self._alert_wait() tests/functional/functional_test.py:211: in _alert_wait 'Timed out waiting for confirmation popup.') _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = method = message = 'Timed out waiting for confirmation popup.' def until(self, method, message=''): """Calls the method provided with the driver as an argument until the \ return value is not False.""" screen = None stacktrace = None end_time = time.time() + self._timeout while True: try: value = method(self._driver) if value: return value except self._ignored_exceptions as exc: screen = getattr(exc, 'screen', None) stacktrace = getattr(exc, 'stacktrace', None) time.sleep(self._poll) if time.time() > end_time: break > raise TimeoutException(message, screen, stacktrace) E TimeoutException: Message: Timed out waiting for confirmation popup.
Leads you directly to the files where you can find examples to copy/paste. If this is all too unfamiliar for you I'd be happy to help and provide you with a draft implementation of the tests to get you started.
securedrop/sass/journalist.sass
Outdated
background: rgba(0, 0, 0, 0.8) | ||
z-index: 99999 | ||
opacity: 0 | ||
-webkit-transition: opacity 100ms ease-in |
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 think we can loose this because we don't support webkit ?
securedrop/static/js/journalist.js
Outdated
}); | ||
if (checked.length > 0) { | ||
return confirm(get_string("collection-multi-delete-confirm-string").supplant({ size: checked.length })); | ||
var checkboxes = document.querySelectorAll(".submission > [type='checkbox']"); |
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.
Nit: there is no need to change spacing here and that clarifies this part of the code is left untouched by this PR. Not a blocker for merge at all :-)
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.
Sure
2e85020
to
436c3bb
Compare
Update functional tests for journalist to expect a modal with the cancel and delete button and actions based on it rather than the previous confirmation alert.
436c3bb
to
1ed2ec3
Compare
Page layout tests now take screenshot of the modal instead of the confirmation message text being saved.
fcecb9d
to
5f0b1e0
Compare
Codecov Report
@@ Coverage Diff @@
## develop #2946 +/- ##
========================================
Coverage 89.28% 89.28%
========================================
Files 31 31
Lines 1810 1810
Branches 209 209
========================================
Hits 1616 1616
Misses 144 144
Partials 50 50 Continue to review full report at Codecov.
|
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.
Great job on this @SaptakS! We just need to wrap the strings used on the buttons in gettext()
(see notes inline)
<h2>{{ gettext('Delete Confirmation') }}</h2> | ||
<p>{{ gettext('Are you sure you want to delete the selected documents?') }}</p> | ||
<a href="#close" id="cancel-selected-deletions" title="Cancel" class="btn sd-button">Cancel</a> | ||
<button type="submit" name="action" value="confirm_delete" id="delete-selected" class="sd-button danger">Delete</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.
We should make sure each string is wrapped in gettext
for translators, so instead of 'Delete'
, we should use {{ gettext('Delete') }}
. This is also true for Cancel
.
<a href="#close" title="Close" class="close">X</a> | ||
<h2>{{ gettext('Delete Confirmation') }}</h2> | ||
<p>{{ gettext('Are you sure you want to delete this collection?') }}</p> | ||
<a href="#close" id="cancel-collection-deletions" title="Cancel" class="btn sd-button">Cancel</a> |
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.
gettext
here too
<a href="#close" title="Close" class="close">X</a> | ||
<h2>{{ gettext('Delete Confirmation') }}</h2> | ||
<p>{{ gettext('Are you sure you want to delete the selected collections?') }}</p> | ||
<a href="#close" id="cancel-collections-deletions" title="Cancel" class="btn sd-button">Cancel</a> |
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.
Last place for gettext
5f0b1e0
to
d98b7ee
Compare
d98b7ee
to
51e8472
Compare
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.
Impressive job on the tests: their logic is not for the faint of heart 💯
A few comments were added but they are minor: once addressed I'm confident we're good to merge :-)
If you feel inspired (but that's not a blocker for merge), it would be nice to factor the modal HTML blocks into a single file that is included and modified by variables to keep it DRY.
self._journalist_clicks_delete_selected_javascript() | ||
self._alert_dismiss() | ||
self._journalist_clicks_delete_selected_link() | ||
self._journalist_clicks_delete_selected_cancel_on_modal() |
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.
These should be after assert select_count > 0 because this assert verifies there are selected docs to work with. And after self._journalist_clicks_delete_selected_cancel_on_modal() there should be an assert like
assert selected_count == len(self.driver.find_elements_by_name('doc_names_selected'))
to verify no deletion took place.
return $(this).prop('checked'); | ||
}); | ||
if (checked.length > 0) { | ||
return confirm(get_string("collection-multi-delete-confirm-string").supplant({ size: checked.length })); |
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.
All get_string must also be revomved from the securedrop/journalist_templates/js-strings.html
file
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.
Makes sense.
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.
Resolved this.
securedrop/sass/journalist.sass
Outdated
@@ -55,6 +55,58 @@ p.breadcrumbs | |||
&:dir(rtl) | |||
text-align: right | |||
|
|||
.modal-dialog |
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 about moving this to modules/_modal.sass
or a similar name which would then be included in _base.sass
? Do you envision problems if doing that ?
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.
Will check on this.
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.
my comments were addressed, 👍 from me
Separated both the html block and the sass code into different files.
@dachary I have separated out the confirmation modal and tried to write it in a generic way so that even for confirmations other than deletion can use that modal in future. Also separated out the sass code into a module and imported only in journalist.sass because it is being used, for now, only there. Should I move that to _base.sass instead? |
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.
Manually verified to work with the tor browser. 👍 🎉
@toast @SaptakS note that @redshiftzero created a UX category in the forum in case you would like to discuss ambitious plans to improve the SecureDrop UX :-) |
@toast agreed. It also pops up on refresh since I am using anchor Ids and they work that way. Any suggestions from your side what is the best way to deal with it? It can be dealt with javascript but the whole point is not to use javascript, so. |
This page was originally used as a confirmation interstitial when deleting files or messages, but in 1e64f36 (#2946) it was replaced with a CSS-only deletion confirmation on the same page, so users would never hit the separate confirmation page. Remove the tests that were still calling this endpoint, the HTML template and code that was checking for the "confirm_delete" action.
This page was originally used as a confirmation interstitial when deleting files or messages, but in 1e64f36 (#2946) it was replaced with a CSS-only deletion confirmation on the same page, so users would never hit the separate confirmation page. Remove the tests that were still calling this endpoint, the HTML template and code that was checking for the "confirm_delete" action.
Status
Work in progress
Description of Changes
Fixes #295.
Changes proposed in this pull request:
According to the discussions in #295 and #2506, I have implemented a CSS-only modal for confirmation of deletion of collections or documents. In this PR, I have replaced the js confirmation by the CSS confirmation modal for
Testing
How should the reviewer test this PR?
Send a message as a whistleblower, log as a journalist mark the message and press
Delete
. A confirmation modal will appear with options toCancel
orDelete
. You can click onCancel
, close icon or anywhere outside the modal to close the modal. On clickingDelete
, the selection collection(s)/document(s) will get deleted.Checklist
If you made changes to the app code: