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

[Admin][Users] Add new admin store credits create flow #6036

Merged

Conversation

MadelineCollier
Copy link
Contributor

Summary

This PR is for issue: #5824

This is the 🎉 last piece 🎉 of the refactored store credits flow! This completes the extraction, migration, and refactoring of the store credits flow from the legacy solidus_backend to the new solidus_admin. This also completes the users admin more generally.

Screenshots

Screen.Recording.2024-12-17.at.10.19.12.AM.mov

Checklist

Check out our PR guidelines for more details.

The following are mandatory for all PRs:

The following are not always needed:

  • 📖 I have updated the README to account for my changes.
  • 📑 I have documented new code with YARD.
  • 🛣️ I have opened a PR to update the guides.
  • ✅ I have added automated tests to cover my changes.
  • 📸 I have attached screenshots to demo visual changes.

@MadelineCollier MadelineCollier changed the title Admin user store credit create [Admin][Users] Add new admin store credits create flow Dec 17, 2024
@MadelineCollier MadelineCollier marked this pull request as ready for review December 17, 2024 12:16
@MadelineCollier MadelineCollier requested a review from a team as a code owner December 17, 2024 12:16
@MadelineCollier
Copy link
Contributor Author

Spec failures are unrelated as the solidus_installer step is failing both on this PR and on main CI runs :(

@tvdeyen
Copy link
Member

tvdeyen commented Dec 17, 2024

Spec failures are unrelated as the solidus_installer step is failing both on this PR and on main CI runs :(

Some naming issue in the paypal extension. Taking a look....

@github-actions github-actions bot added changelog:solidus_legacy_promotions Changes to the solidus_legacy_promotions gem changelog:solidus_promotions Changes to the solidus_promotions gem labels Dec 18, 2024
Copy link

codecov bot commented Dec 18, 2024

Codecov Report

Attention: Patch coverage is 98.27586% with 1 line in your changes missing coverage. Please review.

Project coverage is 89.59%. Comparing base (811f14d) to head (0517f29).
Report is 6 commits behind head on main.

Files with missing lines Patch % Lines
...trollers/solidus_admin/store_credits_controller.rb 97.72% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6036      +/-   ##
==========================================
- Coverage   92.50%   89.59%   -2.91%     
==========================================
  Files         384      791     +407     
  Lines        8362    18269    +9907     
==========================================
+ Hits         7735    16368    +8633     
- Misses        627     1901    +1274     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@MadelineCollier
Copy link
Contributor Author

MadelineCollier commented Dec 18, 2024

Just waiting for #6037 to be merged and then I will remove that last WIP commit which has proven that #6037 fixes the specs for this PR :)

#6037 has been merged and this PR has been rebased! Specs should pass now :)

This was just some leftover WIP code that would have impacted the error
state of the controller. Now the flash messages will display the correct
success and failure states. This wasn't caught by the specs as the old
busted code (now removed) would have just displayed both `flash[:notice]
= t('.success')` (and also) `flash[:error] = t('.failure')`

and this would match on the assertion:
```
expect(response.body).to
include("Something went wrong. Store credit could not be invalidated.")
```

Since they are set using different keys, they didn't overwrite each
other in the flash hash.

Regardless, the old WIP code has been removed and the flow now displays
the expected flash.
Previously these were only used on edit actions which was fine because
the `render_edit_with_errors` method is able to accommodate both the `update_amount` and `invalidate` actions. However, I want to re-use the `ensure_amount` method inside of the new/create flow.

Since new/create flow would need to render a different template (eg.
`render_new_with_errors`) I have altered the ensure method to accept a
block instead of being hard-coded to `render_edit_with_errors`.
@MadelineCollier MadelineCollier force-pushed the admin-user-store-credit-create branch from 9e9e36d to 0517f29 Compare December 18, 2024 11:36
@github-actions github-actions bot removed changelog:solidus_legacy_promotions Changes to the solidus_legacy_promotions gem changelog:solidus_promotions Changes to the solidus_promotions gem labels Dec 18, 2024
@MadelineCollier MadelineCollier merged commit 89730ee into solidusio:main Dec 18, 2024
15 of 16 checks passed
Copy link
Member

@tvdeyen tvdeyen left a comment

Choose a reason for hiding this comment

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

Thanks for finishing this.

I think next step should be to sit back and think about how we want to continue with the new admin.

Most of the code we introduce in every new admin PR introduces lots of code unrelated to the actual feature. It's mostly a copy and paste of the same code over and over again.

With every new admin index component we currently make it harder to refactor the code in the future.

We repeat ourselves a lot currently. Which was fine in the early stages of the admin, but now it starts getting a burden for us.

Could we please now think about introducing a resource CRUD controller (plus a set of reusable components) like we have in the current backend?

I am happy to help and thanks again for your work here.

@tvdeyen
Copy link
Member

tvdeyen commented Dec 18, 2024

@MadelineCollier we usually wait for a second approval before we merge a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants