railsadminteam / rails_admin

RailsAdmin is a Rails engine that provides an easy-to-use interface for managing your data
MIT License
7.9k stars 2.26k forks source link

No more loading indicator on version 3 #3500

Closed jeromedalbert closed 2 years ago

jeromedalbert commented 2 years ago

Describe the bug

When clicking on items in the left navbar, there is no loading indicator any more. There used to be one in the older rails_admin version.

This is especially problematic when loading lists that take many seconds to load. Since there is no indicator, the user is not sure whether the page is loading or if they misclicked. So they might click again (and again, and again), but if they correctly clicked the first time, this may lead to cascading delays.

Reproduction steps

Click on any item in the left navbar that takes a little bit of time to load.

Expected behavior

A loading indicator should be shown. Here is a screenshot of the indicator from the older rails_admin version, showing at the bottom-right of the page:

Screen Shot 2022-03-24 at 7 14 08 PM

Additional context

I am using config.asset_source = :sprockets in config/initializers/rails_admin.rb, but I also tried with config.asset_source = :webpacker to no avail.

Maybe the problem started to happen during the switch to Turbo.

mshibuya commented 2 years ago

Yeah we removed it when we stopped using Pjax. It can be added back, but how important is it? I initially thought that it won't make a noticeable difference...

jeromedalbert commented 2 years ago

It can be useful for older apps that have models with many records and associations, because displaying many associations on list pages (has_many and has_many :through) can take a very long time to load. Like 10+ seconds to load for some of the admin pages in the app I am working on.

A loading indicator may not be important if list pages loaded faster by default, for example by displaying only the X first columns like in previous versions.

As a workaround I have sped up my list pages by manually whitelisting attributes with list do ... end for my ~50 models, which was time consuming but reduced page load times to 1-2 seconds at most.

jeromedalbert commented 2 years ago

Thanks for tackling this @mshibuya. After trying the latest master both with the asset pipeline or with webpacker, I still do not see the loading indicator.

I managed to sort of make it work by doing the following hack:

// app/javascript/packs/rails_admin.js

import "rails_admin/src/rails_admin/base";
import "../stylesheets/rails_admin.scss";

$(document).on("turbo:click", function () {
  return $("#loading").show();
});

Although I shouldn't have to do it since src/rails_admin/ui.js should take care of it. I am wondering if something is wrong with my setup. Also, when I click to go back one page in my browser, the loading indicator still shows.

mshibuya commented 2 years ago

when I click to go back one page in my browser, the loading indicator still shows.

Added the fix for this behavior in https://github.com/railsadminteam/rails_admin/commit/b9ee7f0c202abc7c09726bdaa28536e7ec25127e, thanks!