Add extendTable support to relation-style admin pages#2457
Open
tazzytazzy wants to merge 2 commits into
Open
Conversation
Mirror Lunar's existing resource and relation-manager table extension pattern on relation-style resource pages by adding a table seam to BaseManageRelatedRecords. This introduces a shared ExtendsTables concern that routes the public table(Table $table) entrypoint through getDefaultTable() and the existing Lunar hook dispatcher via extendTable. The affected BaseManageRelatedRecords pages move their current table definitions into getDefaultTable() so packages can alter columns, filters, actions, and query behavior without replacing the whole page. RelationPageExtension now exposes a typed extendTable(Table $table): Table method for discoverability and consistency. To preserve compatibility for downstream code that may expect concrete pages to still expose a public table() method, the touched pages keep a thin public wrapper that delegates to the base implementation. Adds focused feature coverage using ManageCollectionProducts to verify: - the concrete page still exposes a public table() method - default table behavior is unchanged with no extension registered - a RelationPageExtension can extend the page table
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.
This PR implements Ask 1 from #2448 by adding an
extendTableseam to relation-style resource pages in Lunar admin.Today, packages can extend resource tables and relation-manager tables through narrow hooks, but relation-style pages built on
BaseManageRelatedRecordsdo not expose the same seam. That forces packages to replace an entire page just to adjust one column, action, filter, or query clause.This change brings those pages in line with Lunar's existing extension pattern.
What changed
New base table seam for relation-style pages
BaseManageRelatedRecordsnow uses a newExtendsTablesconcern.That concern provides the same shape Lunar already uses elsewhere:
Typed hook on
RelationPageExtensionRelationPageExtensionnow exposes:This makes the relation-page table seam discoverable and consistent with the existing resource and relation-manager extension APIs.
Existing page table definitions moved behind
getDefaultTable()Each
BaseManageRelatedRecordssubclass that previously owned its own table definition now moves that table-building logic intogetDefaultTable().The touched pages are:
ManageUrlsRelatedRecordsManageCollectionProductsManageCollectionChildrenManageProductVariantsManageProductCollectionsManageProductAssociationsManageVariantMediaManageBrandProductsManageBrandCollectionsCompatibility note
The touched pages keep a thin public
table()wrapper that delegates to the new base implementation:Behaviorally, this is redundant, but it preserves the concrete-class
table()method shape for any downstream code that may reflect on those page classes directly, such as other add-ons.Why this approach
This keeps the change narrow and upstream-safe:
Tests
Added focused coverage around a real relation-style page,
ManageCollectionProducts, to verify:table()methodRelationPageExtensioncan extend the table by adding a columnVerification
Ran:
vendor/bin/pint --dirty --format agentvendor/bin/pest tests/admin/Feature/Support/Extending/RelationPageExtensionTest.phpNotes
ManageProductVariantsalso had an unreachable dead block in its oldtable()method after an earlyreturn $table;. That dead code was removed as part of moving togetDefaultTable(), with no intended behavior change.