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

Anonymous declarations on Actions, Cards, Scopes, etc.. #3702

Open
Paul-Bob opened this issue Feb 28, 2025 · 2 comments
Open

Anonymous declarations on Actions, Cards, Scopes, etc.. #3702

Paul-Bob opened this issue Feb 28, 2025 · 2 comments

Comments

@Paul-Bob
Copy link
Contributor

Feature

Currently when we want to register an action, card, filter, scope, etc.. we need to create a new class first.

Let's make it possible to register them anonymously, directly in the resource file.

Something like this:

class Avo::Resources::User < Avo::BaseResource
  def actions
    action title: "Toggle inactive",
      icon: "heroicons/outline/globe",
      visible: -> { record.active? },
      handler: -> { records.update_all(active: !record.active) }
  end
end

This will register an action with the given options and make it available in the resource.

Something similar can be done for cards, filters, scopes, etc..

class Avo::Resources::User < Avo::BaseResource
  def scopes
    scope name: "Even", description: "Only even numbers", query: -> { ... }
    scope name: "Odd", description: "Only odd numbers", query: -> { ... }
  end
end

This will register two scopes with the given options and make them available in the resource.

Approach

To be explored

@zhephyn
Copy link
Contributor

zhephyn commented Mar 1, 2025

@Paul-Bob. Taking this up for assignment

@Paul-Bob
Copy link
Contributor Author

Paul-Bob commented Mar 3, 2025

Hi @zhephyn, thanks for your interest in this one!

Unfortunately, this issue doesn’t have a clear approach yet and involves access to private repositories.

In the meantime, there are some issues labeled "Help wanted" and "Good first issue". Let us know if you’d like to pick one up!

Thanks!

@adrianthedev adrianthedev moved this from To Do to Backlog in Issues Mar 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Backlog
Development

No branches or pull requests

2 participants