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

feature: add action icon #2628

Merged
merged 16 commits into from Apr 3, 2024
Merged

feature: add action icon #2628

merged 16 commits into from Apr 3, 2024

Conversation

gabrielgiroe1
Copy link
Collaborator

@gabrielgiroe1 gabrielgiroe1 commented Mar 22, 2024

Description

Add action icon and action divider for better organization and clarity.

Fixes #2592

class Avo::Resources::User < Avo::BaseResource
  # ...

  def actions
    action Avo::Actions::ToggleInactive, icon: "heroicons/outline/globe"
    action Avo::Actions::ToggleAdmin
    divider
    action Avo::Actions::Sub::DummyAction
    action Avo::Actions::DownloadFile, icon: "heroicons/outline/arrow-left"
    divider
    action Avo::Actions::Test::NoConfirmationRedirect
    action Avo::Actions::Test::CloseModal
  end

  # ...
end

image

Checklist:

@gabrielgiroe1 gabrielgiroe1 marked this pull request as draft March 22, 2024 13:56
Copy link

codeclimate bot commented Mar 22, 2024

Code Climate has analyzed commit 8293d25 and detected 0 issues on this pull request.

View more on Code Climate.

@gabrielgiroe1 gabrielgiroe1 marked this pull request as ready for review March 26, 2024 10:36
Copy link
Contributor

@Paul-Bob Paul-Bob left a comment

Choose a reason for hiding this comment

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

Lets make "play" as action's default icon

lib/avo/base_action.rb Outdated Show resolved Hide resolved
app/components/avo/actions_component.rb Outdated Show resolved Hide resolved
Copy link
Contributor

@Paul-Bob Paul-Bob left a comment

Choose a reason for hiding this comment

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

Let's purge next_action since we're not using it anymore

app/components/avo/actions_component.html.erb Outdated Show resolved Hide resolved
app/components/avo/actions_component.rb Outdated Show resolved Hide resolved
app/components/avo/actions_component.rb Outdated Show resolved Hide resolved
app/components/avo/actions_component.rb Outdated Show resolved Hide resolved
@Paul-Bob
Copy link
Contributor

@gabrielgiroe1 I let some comments for some last tweaks, otherwise the PR looks great, thank you! This is a cool improvement!

Copy link
Collaborator

@adrianthedev adrianthedev 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! I haven't tested it.

I left one suggestions and one question.

GJ! I wanted this for such a long time!

lib/avo/base_action.rb Outdated Show resolved Hide resolved
@@ -310,8 +314,8 @@ def fetch_cards
end

# def action / def filter / def scope
define_method entity do |entity_class, arguments: {}|
entity_loader(entity).use({class: entity_class, arguments: arguments})
define_method entity do |entity_class, arguments: {}, icon: "play"|
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we need to specify a default here as well? Wouldn't the initializer default take precedence?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, we must specify a default value. I tried as below and it won't get a default icon value.👇

define_method entity do |entity_class, arguments: {}, icon: nil|

@adrianthedev
Copy link
Collaborator

Also, let's see the docs.
Let's add the option as we have other options but also code examples on how users can do it in show_controls (and others) and in def actions.

@Paul-Bob Paul-Bob changed the title Add action icon feature: add action icon Apr 3, 2024
@Paul-Bob Paul-Bob merged commit 44d4bb6 into main Apr 3, 2024
18 of 20 checks passed
@Paul-Bob Paul-Bob deleted the action_icon branch April 3, 2024 16:41
Copy link
Contributor

github-actions bot commented Apr 3, 2024

This PR has been merged into main. The functionality will be available in the next release.

Please check the release guide for more information.

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.

add action icon & action divider
3 participants