Replies: 10 comments 8 replies
-
|
Hi, I am new to elixir and was liking the UI of Backpex and also the facilities ash provides, in its current state how complicated would it be to add support to ash? would you be open to a PR? |
Beta Was this translation helpful? Give feedback.
-
|
Maybe some documentation around using Backpex with Ash in its current form you be a work around for now. I'm probably gonna have to take the plunge soon, so I'm atleast gonna give it a shot. 🙂 |
Beta Was this translation helpful? Give feedback.
-
|
Hello hello! Over the weekend I started working on an Ash integration for my app. I read the adapter warnings etc, but this still seemed like a better business decision than any other way of building the admin I needed. I used the current Ash adapter as a starting point. https://github.com/enoonan/ash_backpex At the moment, this repo is intended as an example to follow, not a dependency for other folks' projects. It doesn't even have a mix.exs file. I'd be happy to generalize it and take the lead on Backpex+Ash integration, provided that I can be in the loop with y'all about future changes, and offer input about pain points. Thanks for an incredible library! 🎉 |
Beta Was this translation helpful? Give feedback.
-
|
I made a lot more progress on my Ash+Backpex implementation, with some assists from Zach Daniel in the Ash Discord. It now uses a Spark DSL and can derive sensible defaults for most fields. It's very incomplete, but I'm enjoying the heck out of this: # myapp_web/live/admin/post_live.ex
defmodule MyAppWeb.Live.Admin.PostLive do
use AshBackpex.LiveResource
backpex do
resource MyApp.Blog.Post
load [:author]
layout({MyAppWeb.Layouts, :admin})
fields do
field :title
field :published_at
field :author do
display_field(:name)
live_resource(MyAppWeb.Live.Admin.AuthorLive)
end
end
filters do
filter :state do
module MyAppWeb.Live.Admin.Filters.PostStateFilter
end
end
end
end |
Beta Was this translation helpful? Give feedback.
-
|
Here I'm going to create a sort of to-do list of places where we'd need the Adapter Behavior CallbacksAssuming the following type exists ... @type assigns() :: map()Then these (link)... @callback insert(struct(), module()) :: {:ok, struct()} | {:error, term()}
@callback update(struct(), module()) :: {:ok, struct()} | {:error, term()}
@callback update_all(list(struct()), keyword(), module()) :: {:ok, non_neg_integer()}
@callback delete_all(list(struct()), module()) :: {:ok, term()} | {:error, term()}Would need to be more like this: @callback insert(struct(), assigns(), module()) :: {:ok, struct()} | {:error, term()}
@callback update(struct(), assigns(), module()) :: {:ok, struct()} | {:error, term()}
@callback update_all(list(struct()), keyword(), assigns(), module()) :: {:ok, non_neg_integer()}
@callback delete_all(list(struct()), assigns(), module()) :: {:ok, term()} | {:error, term()}Basically I just added It doesn't seem like there are too many places where this will affect Backpex itself, but unfortunately it will probably cause BC issues in user apps. Places Where Those Functions are Called
backpex/lib/backpex/resource.ex Line 103 in 8cd40f3
backpex/lib/backpex/resource.ex Line 124 in 8cd40f3
It seems like this function is only meant to be invoked inside of user-defined bulk actions, like the soft-deletes example in the demo.
It's referenced in item_actions/delete.ex I am happy to try to take a crack at making these updates unless you'd rather make them yourselves. I'm mostly just not sure how you'd want to handle the BC issues. |
Beta Was this translation helpful? Give feedback.
-
|
Hi folks, I am sorry for being late to the Ash party, but I just wanted to share with you that I had implemented almost full Ash support for Backpex just before Ash support was dropped in v0.17.0 (see #1675). I was planning to test it more and I still have some work to finish (e.g. passing around the author, context, scope), but unfortunately I've been very busy lately. However it's already pretty much fully functional and well integrated into Backpex (sorting, filters, forms, policies, etc all work). If interested, you can find my implementation in this branch: Please refer to the Any observations are welcome! I wonder whether I should keep this custom branch or switch to Cheers! |
Beta Was this translation helpful? Give feedback.
-
|
Hello! @gmazzamuto Let's consolidate our efforts! Definitely check out AshBackpex and if there's anything you've built that's currently missing, let's see if we can get it in. |
Beta Was this translation helpful? Give feedback.
-
|
@Flo0807 really excited to see you are now recommending AshBackpex! Banner day for us! 🎉 Quick question about the 0.17 release. The release notes in the tagged release look like there aren't any breaking changes we need to worry about on our side. We don't support the InlineCRUD field yet so we should be good there. But then the Upgrade guide says "Add Translations." So I just want to double check: adding translations is fully opt-in and is in no way breaking? |
Beta Was this translation helpful? Give feedback.
-
|
@enoonan I've taken a look at AshBackpex. First of all, as I said congrats for the great work with Spark! I bet that wasn't easy... That said, at the moment I can't fully port my Additionally, in a project one might have Ecto resources alongside Ash resources, and I would like to use the same API to handle all the Backpex-related stuff. Wouldn't it be better to have just an adapter, leaving everything else as is? like this: defmodule DemoWeb.TicketLive do
use Backpex.LiveResource,
adapter: AshBackpex.Adapter, # <------------ Here
adapter_config: [
resource: Demo.Helpdesk.Ticket
],
layout: {DemoWeb.Layouts, :admin}
@impl Backpex.LiveResource
def fields do
[
subject: %{
module: Backpex.Fields.Text,
label: "Subject",
orderable: true,
searchable: true
},
body: %{
module: Backpex.Fields.Textarea,
label: "Body",
orderable: false,
except: [:index]
}
]
end
endOn the other hand, I must admit that my implementation isn't limited to just the Ash adapter, it also touches other areas in the Backpex codebase (especially because I take advantage of ash_phoenix for forms). Which I also don't like, but maybe is easier to maintain? Or maybe the internal adapter interface in Backpex can be further refined in the future so that the adapter functionality can be extracted in a separate module, fully outside the Backpex codebase. From the developer perspective however, the Backpex API stays exactly the same for both Ecto and Ash resources. |
Beta Was this translation helpful? Give feedback.
-
|
Hey! First, thank you so much for your effort on Ash support 🎉
@gmazzamuto this is wonderful! As @enoonan mentioned, we should continue working on From now on, most Ash-related features should be implemented in |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Support Ash framework. Users should easily be able to create Backpex LiveResources for Ash resources. We probably need to implement an abstraction layer between data and UI so we can support multiple data sources.
At the start, we could support ash resources and plain Ecto schemas. In the future, other sources may be supported.
Beta Was this translation helpful? Give feedback.
All reactions