Add optional view link to InlineCRUD field rows#1856
Merged
Conversation
When a live_resource option is provided on an InlineCRUD field, each row in the read-only table view gets an eye icon link that navigates to the associated resource's show page. This mirrors the existing pattern used by BelongsTo and HasMany fields. The link includes a tooltip and respects authorization via can?/3. When live_resource is not set, no action column is rendered, keeping the feature fully backwards-compatible.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds an optional view (eye icon) link to each row in the InlineCRUD field's read-only table view. When the new live_resource configuration option is provided, an additional "Actions" column is rendered with a link navigating to the associated resource's show page, mirroring patterns used by BelongsTo and HasMany fields. The feature respects authorization via can?/3 and is fully backward-compatible.
Changes:
- Added a new optional
live_resourceconfig option to theInlineCRUDfield schema, with aget_link/2helper that checks authorization and generates show page URLs - Added an "Actions" column header (with sr-only label) and eye icon link in each table row, with empty cell fallback when authorization is denied
- Added a demo usage example in
ProductLivefor theshort_linksfield
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
lib/backpex/fields/inline_crud.ex |
Added live_resource config option, Router alias, actions column header, eye icon link with tooltip/aria-label in each row, and get_link/2 helper function |
demo/lib/demo_web/live/product_live.ex |
Added live_resource: DemoWeb.ShortLinkLive to the short_links InlineCRUD field config |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
closes #1857
When a live_resource option is provided on an InlineCRUD field, each row in the read-only table view gets an eye icon link that navigates to the associated resource's show page. This mirrors the existing pattern used by BelongsTo and HasMany fields.
The link includes a tooltip and respects authorization via can?/3. When live_resource is not set, no action column is rendered, keeping the feature fully backwards-compatible.