avo-hq / avo

Build Ruby on Rails apps 10x faster
https://avohq.io
Other
1.54k stars 258 forks source link

non standalone actions on custom controls #3395

Open pjmuller opened 3 weeks ago

pjmuller commented 3 weeks ago

Describe the bug

related to https://github.com/avo-hq/avo-advanced/pull/50

see https://www.loom.com/share/ee833adc463442ffb462435b77506b3d that demonstrates the problems below

  1. icon + text not grayed out while disabled (so not a clear signal to the user what is available/unavailable)
  2. when no text present seems to still open standalone=false when no records are selected
  3. inconsistent behavior, sometimes (but not always) when unchecking the checkbox, we are able to open the action

feature / code snippet request

FYI: I also ran the same experiments having chrome developer console open + disable cache, so I should have all latest assets

module Avo
  module Resources
    class Tenant < Avo::BaseResource
      self.index_controls = -> do
        action Avo::Actions::Dummy, icon: 'heroicons/outline/envelope', style: :outline, title: 'Stuur Mailsjabloon', label: ''
      end
end

module Avo
  module Actions
    class Dummy < Avo::BaseAction
      self.standalone = false
      self.name = 'Dummy'
      # ...
    end
  end
end

System configuration

Avo version: 3.14

Rails version: 7.2

Are you using Avo monkey patches, overriding views or view components?

Impact

Urgency

github-actions[bot] commented 5 days ago

This issue has been marked as stale because there was no activity for the past 15 days.

Paul-Bob commented 4 days ago

Hi @pjmuller thanks for reporting this.

Could you please verify if point 2. and 3. still an issue on the latest version?

Regarding point 1. I thought about it during the development and since is a custom cntrok where you can set the color even to purple if you want, feels strange to force a default behavior like changing text to black and gray on activation and deactivation.

Maybe some option like active_classes is the way, where you could configure classes to add on activation, same classes would be removed on deactivation... I've done some experimental development on this approach and it seems to work

Paul-Bob commented 3 days ago

WIP branch: https://github.com/avo-hq/avo/tree/fix/standalone_action_disabled_and_enabled_classes