-
Notifications
You must be signed in to change notification settings - Fork 2
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
FFS-1809: Disable multiple clicking on send invitation button #400
Conversation
app/app/javascript/controllers/caseworker/cbv_flow_invitations/invitation.js
Outdated
Show resolved
Hide resolved
Co-authored-by: Tom Dooner <[email protected]>
Co-Authored-By: Yvette White <[email protected]>
Co-Authored-By: Yvette White <[email protected]>
…/iv-cbv-payroll into yvette/1809-multi-invites
# keep the database connection alive | ||
ActiveRecord::Base.connection.execute("SELECT 1") |
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 interesting. What's this for?
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.
It's an unrelated change that's already on main
. George and I diagnosed the slow performance as lengthy database reconnections: #401
flash.now[:alert_heading] = error_header | ||
flash.now[:alert] = error_messages.html_safe |
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.
Interesting, point on #now https://guides.rubyonrails.org/action_controller_overview.html#the-flash
Wasn't aware! Was the flash not appearing?
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.
Was the flash not appearing?
The opposite, actually, the flash was appearing on this page and whatever next page the user went to.
The form has weird behavior currently: it POSTs to /sandbox/invitations
, which adds the validation errors via flash
, but then doesn't take the user to a subsequent page (rather, it renders :new
view). So it leaves the user on a page they can't refresh (/sandbox/invitations
) with the flash
in the cookie for the next request, e.g. if they hit the back button/refresh.
So by using flash.now
it makes the flash error available to the current view but not afterwards.
turbo_frame_tag(model) do | ||
form_with(model: model, scope: scope, url: url, format: format, **options, &block) | ||
end |
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.
Wonderful, so this lets use keep the turbo feature without breaking forms?
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, Turbo with target="_top"
seems to work pretty well in general, so we could probably use it on all the other pages.
@@ -449,8 +449,6 @@ GEM | |||
connection_pool (>= 2.2.5, < 3) | |||
rack (~> 2.0) | |||
redis (>= 4.5.0, < 5) | |||
skylight (6.0.4) | |||
activesupport (>= 5.2.0) |
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'm not sure why these changes are duplicated on your branch (I think it's because it's branched off an old version of main
?)
# keep the database connection alive | ||
ActiveRecord::Base.connection.execute("SELECT 1") |
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.
It's an unrelated change that's already on main
. George and I diagnosed the slow performance as lengthy database reconnections: #401
flash.now[:alert_heading] = error_header | ||
flash.now[:alert] = error_messages.html_safe |
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.
Was the flash not appearing?
The opposite, actually, the flash was appearing on this page and whatever next page the user went to.
The form has weird behavior currently: it POSTs to /sandbox/invitations
, which adds the validation errors via flash
, but then doesn't take the user to a subsequent page (rather, it renders :new
view). So it leaves the user on a page they can't refresh (/sandbox/invitations
) with the flash
in the cookie for the next request, e.g. if they hit the back button/refresh.
So by using flash.now
it makes the flash error available to the current view but not afterwards.
turbo_frame_tag(model) do | ||
form_with(model: model, scope: scope, url: url, format: format, **options, &block) | ||
end |
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, Turbo with target="_top"
seems to work pretty well in general, so we could probably use it on all the other pages.
Ticket
Resolves FFS-1809.
Changes
Overview of the bug
When a user is presented with the invitation page, if the user clicks on the send button multiple times, then multiple duplicate invitations will be generated and sent to the invitee. The purpose of this fix is to make sure that only one invite is generated.
Summary of changes
Note: This work went through several iterations of approaches. This final approach is deemed most ideal as it maintains the use of the Turbo framework and allows for component reuse.
flash.now
instead offlash
when setting the page's errors. The former will make sure the messages are shown on the page when no redirect occurs. Second, the page returns a 4XX status as opposed to a 2XX status. This fixes the error rendering at the top of the page.Acceptance testing
:alert: Deploy block! @ffs-eng I just merged PR [#123] and will be doing acceptance testing in demo - please don't deploy until I'm finished!
)Screenshots
Validation errors are rendering properly
Screenshot of disabled button
Query of before and after an invitation was generated after the fix
Created an invitation for "Jimmy J". The first query is prior to invitation creation and the second is after.
For context, prior to changes, I was able to generate multiple invitations by continuously clicking the send button