-
-
Notifications
You must be signed in to change notification settings - Fork 730
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
[Reports] Disable GO button once clicked #12619
[Reports] Disable GO button once clicked #12619
Conversation
It is disabled both on client side and server side, so even if the server takes a while to respond the button is disabled
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.
Nicely done 👍
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, thanks I think this could make a big difference.
I think we could simplify it, but this is good 👍
selector: "#report-go", | ||
html: helpers.button(t(:go), "report__submit-btn", "submit", disabled: 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.
I don't think that this is actually needed because we do it client-side. But it doesn't hurt either.
spec/support/reports_helper.rb
Outdated
go_button = find("button.report__submit-btn") | ||
expect(go_button).to be_disabled |
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 do something like expect(page).to have_button "Go", disabled: 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.
Looks good 👍
Hi @rioug, I have tested this and I can confirm:
I noticed one little thing, which isn't a blocker. Immediately after clicking, the label of the button turns from GO to TRUE. It returns to GO very quickly after. Is it possible to change that? Kazam_screencast_00002.webmKazam_screencast_00003.webmAnyway, I did not notice any regression, so this one is ready to go! 🥳 |
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.
@rioug I think this is a quick fix, would you be able to try it out?
.actions.filter-actions | ||
= button t(:go), "report__submit-btn" | ||
#report-go.actions.filter-actions{ data: { controller: "scoped-channel", "scoped-channel-id-value": request.uuid } } | ||
= button t(:go), "report__submit-btn", "submit", "data-disable-with": 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.
Oh, I didn't pick up on this before. The data-disable-with
attribute is used to replace the button text.
Usually, rails magic JS will auto-populate this, but I guess you found that you had to manually include it.
I think we can simply include the go text here:
= button t(:go), "report__submit-btn", "submit", "data-disable-with": true | |
= button t(:go), "report__submit-btn", "submit", "data-disable-with": t(:go) |
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.
look like I miss read the documentation it should have been :
= button t(:go), "report__submit-btn", "submit", "data-disable-with": true | |
= button t(:go), "report__submit-btn", "submit", "data-disable": true |
I'll fix that quickly
What? Why?
The main issue was that report where slow to generate, but because we did not disable the Go button, users were able to spam the server adding unnecessary to load. This PR address disabling the button to prevent such spamming.
The button is disabled client side and server side, so even if the server is slow to respond or the websocket connection drops the button will still be disabled. It will be re enabled once the report is rendered.
What should we test?
As an enterprise user
-> Notice the button being disabled *, and clicking doesn't do anything
-> Notice the button being enabled ** again
*
**
Release notes
Changelog Category (reviewers may add a label for the release notes):
The title of the pull request will be included in the release notes.
Dependencies
Documentation updates