Frontend: Render the DataView block on public pages#73
Merged
Conversation
Whenever a page is published in the Cortext editor, any collections rendered within will also be marked as published. The Rows REST endpoint now allows unauthenticated requests to read such collections. Adds a `render_callback` to Cortext's DataView block that renders a mount site for a DataViews React island. The island then fetches rows and fields data via the REST API. Rendering and fetching is mediated by new helpers like PublicDataView, usePublicRows, etc. Supports interactions such as filtering data and reordering fields. Tech debt: CSS, which ignores WP conventions around alignwide, etc. Right now, Cortext pages have their content's width fixed to 650px, except for DataView blocks, which take up the full width. Likely tech debt: duplication of field configurations around `publicFieldMapping`, etc.
The DataViews view-settings popover needs the wp-components stylesheet for its background. Add wp-components as a style dependency in both Assets.php and the render callback. Also document tech-debt.md#43: the DataView block should provision its own script/style handles instead of sharing cortext-frontend with page chrome. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Resolve two conflicts: - includes/Plugin.php: page-cover/page-icon blocks were renamed to document-cover/document-icon on main. Keep the renames and add the new Block\DataView import + registration from this branch. - docs/tech-debt.md: both sides added entries starting at 42. Keep main's 42–47 in place; renumber this branch's two entries to 48 and 49. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
PHPCS disallows short ternaries. Use the full form so the meta options default falls back to null when get_post_meta returns an empty value. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- PublicDataView.js, frontend.js: prettier reformatting to match the repo style. - publicFieldMapping.js: align the @param block by padding type and name columns to the widest entry. - PublishToggle.js: add the missing @param doc for getCollectionIds. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
dc05bc7 to
860209f
Compare
Member
Author
|
@priethor: I refreshed this PR. It's a mouthful and it has a bunch of imperfections, but I think we should just iterate. Feel free to revert, but I'm going to merge :) |
Collaborator
|
Nice, let's go and iterate! I'll give it a spin 🙂 |
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
Part of #154
includes/Block/DataView.php) with a render callback that outputs a hydration container for the DataView block on public pages/cortext/v1/rowsREST endpoint to anonymous reads viacontext=viewwhen the parent collection is published; field definitions now includeoptionsfor select/multiselect chip renderingPublicDataView,usePublicRows,publicFieldMapping) — no editor dependencies (core-data, dnd-kit, block-editor)PublishToggleTest plan
crtxt_pagecontaining acortext/data-viewblock — verify the collection status transitions topublishcontext=viewnpm run buildproduces no errors; frontend bundle excludes core-data and dnd-kit🤖 Generated with Claude Code