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] Open edit and new forms in dialog with turbo frame #6046

Open
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

tvdeyen
Copy link
Member

@tvdeyen tvdeyen commented Dec 20, 2024

Depends on #6048

Summary

Opens new and edit forms of Admin resources in dialogs with Turbo Frames.
Removing the need of rendering the index table again on the form components.

Also handles the layout toggle for all turbo frame requests.

Includes the ground work from #6045

  • Shipping Categories
  • Adjustment reasons
  • Return reasons
  • Store credit reasons
  • Refund reasons
  • Tax categories
  • User roles
  • Add user store credit
  • Edit Stock items

Closes #5944

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.

@tvdeyen tvdeyen force-pushed the open-modal-content-remotely branch 2 times, most recently from 22f5345 to 5e2c4da Compare December 20, 2024 10:57
3.21.0 introduced a bug with testing view components.
@tvdeyen tvdeyen force-pushed the open-modal-content-remotely branch from 5e2c4da to 909607d Compare December 20, 2024 20:02
@tvdeyen tvdeyen changed the title [Admin] Open Shipping Categories edit and new forms in dialog with turbo frame [Admin] Open edit and new forms in dialog with turbo frame Dec 20, 2024
@tvdeyen tvdeyen marked this pull request as ready for review December 20, 2024 20:05
@tvdeyen tvdeyen requested a review from a team as a code owner December 20, 2024 20:05
@tvdeyen tvdeyen force-pushed the open-modal-content-remotely branch from 909607d to 184c645 Compare December 20, 2024 20:10
If a table has no rowUrl defined we currently redirect to
root path. Which is not preferable. We should do nothing instead.
We do not want to render the whole layout if the request
is a turbo frame request. We just want to render the
component's html.
@tvdeyen tvdeyen force-pushed the open-modal-content-remotely branch from 354c7c2 to a1e9278 Compare December 20, 2024 20:28
Copy link

codecov bot commented Dec 20, 2024

Codecov Report

Attention: Patch coverage is 94.44444% with 5 lines in your changes missing coverage. Please review.

Project coverage is 89.59%. Comparing base (9234436) to head (6b476d4).

Files with missing lines Patch % Lines
...ontrollers/solidus_admin/stock_items_controller.rb 50.00% 2 Missing ⚠️
...rollers/solidus_admin/tax_categories_controller.rb 50.00% 2 Missing ⚠️
...nts/solidus_admin/tax_categories/edit/component.rb 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6046      +/-   ##
==========================================
+ Coverage   87.82%   89.59%   +1.77%     
==========================================
  Files         477      791     +314     
  Lines       11670    18242    +6572     
==========================================
+ Hits        10249    16344    +6095     
- Misses       1421     1898     +477     

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

@tvdeyen tvdeyen force-pushed the open-modal-content-remotely branch from a1e9278 to 162d93c Compare December 20, 2024 20:54
@tvdeyen tvdeyen force-pushed the open-modal-content-remotely branch from 162d93c to ca8ae78 Compare December 20, 2024 21:07
@chaimann
Copy link

@tvdeyen i've checked out your branch and here's the screen recording of the "issues" i mentioned. You can see when I open the edit page in the new tab and click outside, it makes a request to edit url. Also when I click update the modal stays open.

However, I guess I understood it incorrectly what you meant about being able to visit the edit page. In my PR I have done it in a way that the underlying table is still rendered on edit page which I thought was your goal.
So in case we want to have just a modal on the edit page and nothing else, not closing it on all occasions specified above may still be a desired behaviour since we are not rendering anything else other than a modal, so basically there's no need to close it 😄

Screen.Recording.2024-12-20.at.23.38.25.mov

Though there's one more thing I discovered, not related to visiting edit page, but opening a modal with "turbo-framed" link and clicking outside:

Screen.Recording.2024-12-20.at.23.50.35.mov

as you can see it makes a request to index which I'm sure is unnecessary in this circumstance. Probably has something to do with how the clicking outside is implemented, but I have not yet checked how it works so can't tell for sure

href: solidus_admin.new_adjustment_reason_path, data: { turbo_frame: :new_adjustment_reason_modal },
href: solidus_admin.new_adjustment_reason_path, data: {
turbo_frame: :new_adjustment_reason_modal,
turbo_prefetch: false

Choose a reason for hiding this comment

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

btw we probably can turn turbo-prefetch off globally with meta tag

<meta name="turbo-prefetch" content="false">

I can see prefetching is done on almost all the links, but the problem with it is that prefetch is done on each and every hover on the same link, i.e you hover five times over one link and it makes five requests to the same endpoint. It's not really useful without caching and if i'm not mistaken there's no caching set up (but please correct me if i'm wrong!)

@@ -137,11 +137,12 @@
<%= "data-sortable-animation-value=#{@sortable.animation}" if @sortable&.animation %>
>
<% @data.rows.each do |row| %>
<% rowUrl = @data.url&.call(row) %>

Choose a reason for hiding this comment

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

row_url snake case 😉

@tvdeyen tvdeyen force-pushed the open-modal-content-remotely branch from 09dddb7 to 3776427 Compare December 20, 2024 23:32
@tvdeyen tvdeyen force-pushed the open-modal-content-remotely branch from 3776427 to 6b476d4 Compare December 20, 2024 23:47
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.

[Admin] Table component rows do not contain links
2 participants