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

1492: Synchronizations follow up #303

Merged
merged 11 commits into from
Oct 3, 2024
Merged

1492: Synchronizations follow up #303

merged 11 commits into from
Oct 3, 2024

Conversation

allthesignals
Copy link
Contributor

@allthesignals allthesignals commented Oct 2, 2024

Ticket

https://jiraent.cms.gov/browse/FFS-1492

Changes

Switches to Turbo Streams for indicator views. Shows job statuses

Context for reviewers

Test manually with https://docs.pinwheelapi.com/public/docs/sandbox#income-and-employment-job-errors

Testing

image image

Comment on lines 1 to 12
<% if status == :in_progress %>
<div class="grid-row in-progress">
<svg class="in-progress usa-icon border-05 rotate border-base-light radius-pill padding-1 usa-icon--size-5" aria-hidden="true" focusable="false" role="img">
<use
xlink:href="<%= asset_path("@uswds/uswds/dist/img/sprite.svg#autorenew") %>"
></use>
</svg>
</div>
<div class="grid-row in-progress">
<span class="margin-top-05 text-thin"><%= label %></span>
</div>
<% end %>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

These could probably be turned into partials but eh

Copy link
Contributor

@tdooner tdooner left a comment

Choose a reason for hiding this comment

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

Looks good. Some ideas for refactoring that you can take if you agree that they would be simpler.

@@ -1,6 +1,10 @@
class PinwheelAccount < ApplicationRecord
belongs_to :cbv_flow

after_update_commit {
broadcast_replace target: self, partial: "cbv/synchronizations/indicators", locals: { pinwheel_account: self }
Copy link
Contributor

Choose a reason for hiding this comment

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

This is probably rendering in the default locale because there's no connection to the locale the current user is using.

You may be able to get the partial to render in the right locale by surrounding this in:

I18n.with_locale(cbv_flow.cbv_flow_invitation.language) do
  broadcast_replace # ...
end

but that won't take into account any locale change during the flow. We could store the locale on the Cbv Flow as well (updating it every time it changes), which would be more resilient to this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll try that!

Someone has a PR up that should fix it. Is there anything in there we could use? I assume we infer the current locale through params /es/some-path, right?

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

@allthesignals allthesignals Oct 3, 2024

Choose a reason for hiding this comment

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

Yeah, the problem with that is it's set on the controller action, and these view updates are streamed through websockets, which I believe aren't flowing through controller logic...

I'm still surprised turbo doesn't support this!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The manual fix here works fine except in cases when locale is switched during the session. Then the user will see flashes of translated content in some other locale.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Here's a branch showing how the PR linked above fixes the issue: https://github.com/DSACMS/iv-cbv-payroll/tree/wmg/try-turbo-locale-patch

app/app/models/pinwheel_account.rb Outdated Show resolved Hide resolved
app/app/models/pinwheel_account.rb Outdated Show resolved Hide resolved
app/app/helpers/application_helper.rb Show resolved Hide resolved
app/spec/models/pinwheel_account_spec.rb Show resolved Hide resolved
allthesignals and others added 3 commits October 3, 2024 10:31
# Conflicts:
#	app/config/locales/en.yml
#	app/config/locales/es.yml
@allthesignals allthesignals merged commit 852e044 into main Oct 3, 2024
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants