Allow app web helpers in Backpex extensions - #2170
Open
Flo0807 wants to merge 4 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves how Backpex extension modules (item actions, filters, metrics, and custom fields) access host-application web helpers (Gettext/components/verified routes) while avoiding duplicate Phoenix.Component.Declarative @before_compile hooks that can fail compilation under --warnings-as-errors.
Changes:
- Introduce a
BackpexWeb, :heexentrypoint and update:item_action,:filter, and:metricto importPhoenix.Component(instead ofuse), preventing duplicate declarative hooks when combined withMyAppWeb, :html. - Add a
live_component: {MyAppWeb, :live_component}option toBackpex.Fieldso custom fields can reuse the host LiveComponent setup (and helpers) exactly once. - Add compiler-verification fixtures/tests plus documentation and upgrade notes covering the new usage patterns and required
attr/slotsetup.
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| test/fixtures/web_helpers/extension_modules.fixture | Compile fixture covering both use orders and host helper availability across extensions. |
| test/backpex/web_helpers_test.exs | Test that compiling the fixture produces no compile/runtime diagnostics. |
| lib/backpex/metrics/value.ex | Ensures Backpex’s built-in value metric keeps full Phoenix.Component setup for attr. |
| lib/backpex/filters/select.ex | Ensures built-in select filter keeps full Phoenix.Component setup for attr. |
| lib/backpex/filters/range.ex | Ensures built-in range filter keeps full Phoenix.Component setup for attr. |
| lib/backpex/filters/multi_select.ex | Ensures built-in multi-select filter keeps full Phoenix.Component setup for attr. |
| lib/backpex/filters/boolean.ex | Ensures built-in boolean filter keeps full Phoenix.Component setup for attr. |
| lib/backpex/field.ex | Adds :live_component option handling so custom fields can use host LiveComponent entrypoint. |
| lib/backpex_web.ex | Adds :heex + :field_helpers entrypoints and switches extension entrypoints to use :heex. |
| guides/upgrading/v0.19.md | Upgrade notes explaining the behavior change and required actions for attr/slot. |
| guides/filter/custom-filter.md | Docs for using host :html in custom/built-in filter macros and supported use orders. |
| guides/fields/custom-fields.md | Docs for configuring host LiveComponent entrypoint in custom fields. |
| guides/actions/item-actions.md | Docs for using host :html helpers in item actions (either use order). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
live_component: {MyAppWeb, :live_component}Phoenix.Componentsetup in Backpex's built-in filters and value metric because they declareattruseorders and host helpers under compiler verificationWhy
PR #2055 fixed duplicate
Phoenix.Component.Declarative@before_compilehooks for LiveResources. The same duplicate hook was still introduced byBackpexWeb, :item_action,:filter, and:metricwhen consumers also usedMyAppWeb, :html.Fields need a different path because they are real LiveComponents. The new option lets the host application's standard
:live_componententrypoint perform the LiveComponent setup exactly once while Backpex adds only its field-specific aliases and helpers.User impact
Item actions, custom filters, typed filters, and metrics may now use
MyAppWeb, :htmlin either order to access application helpers. Extensions that declare their ownattrorslotmust explicitly use their application HTML entrypoint orPhoenix.Component.Custom fields can use:
Existing fields without this option keep the current Backpex LiveComponent setup.
Checks
MIX_ENV=test mix lint— 275 tests passed (100 doctests, 175 tests), Credo cleanmix test test/backpex/web_helpers_test.exs— passed with no compile or runtime diagnostics