Skip to content

listing block - #107

Open
nileshgulia1 wants to merge 67 commits into
mainfrom
seven-listing-block
Open

nileshgulia1 wants to merge 67 commits into
mainfrom
seven-listing-block

Conversation

@nileshgulia1

@nileshgulia1 nileshgulia1 commented Jun 8, 2026 •

Copy link
Copy Markdown
Member

Cloned from Original branch on seven: plone/volto#8252

Listing block: edit, live preview, server rendering, pagination

Adds the editing side of the Listing block and makes its results work.

@plone/blocks

  • Listing/index.tsx, Listing/schema.tsx: register the edit component, the schema (headline and the querystring widget), the icon and the default block width.
  • Listing/ListingBlockEdit.tsx:
    • Without criteria, shows a full-width placeholder.
    • With criteria, shows a live preview through the querystringResults utility that @plone/cmsui registers. Like the teaser getting its object browser with config.getWidget, the block doesn't fetch data or depend on react-router or @plone/cmsui (packages/blocks/AGENTS.md).
    • The preview shows the first page at the listing's page size.
  • Listing/ListingBlockView.tsx: renders only the items it's given; it never fetches.
    • Item links use the registry's Link, so they navigate within the app. In the editor they're plain text, so a click doesn't leave the edit form.
    • Adds the page navigation: ‹ › arrows and page numbers, as links that work without JavaScript, keep the other URL parameters, and scroll to the listing with a #listing-<id> anchor. In the editor the page numbers aren't links.
    • Uses only contract class names (block-listing__pagination, block-listing__page…). The arrows are inline SVGs because the Icon component adds classes outside the contract.
  • Listing/pagination.ts: helpers shared by the view and the loader:
    • the page size: "Paginate every", else settings.defaultPageSize, else 25;
    • Volto's URL key: page, or page_<block id> when the page has several listings;
    • the current page, the page links, and which page numbers to show.
  • Listing/loadListings.ts, config/server.ts: the server-side loading of the results, registered as a rootContentSubRequest utility in the blocks' server configuration (loaded by the registry, like @plone/cmsui/config/server.ts). It replaces the loader on main in @plone/aurora's server.server.ts, which only handled top-level listings. It:
    • finds listings inside the editor's main region, or at the top level of content saved before Aurora;
    • loads the page in the URL;
    • searches from the page itself, so the page isn't in its own listing, as in Volto;
    • turns item URLs into app paths;
    • empties a listing whose query fails instead of failing the page;
    • skips CMS views (@@edit, …), whose forms share this content and would otherwise save the results.
  • index.ts: sets config.settings.defaultPageSize ??= 25 (Volto's default) for listings without "Paginate every". Before this, listings silently stopped at Plone's default batch of 25 items.
  • styles/content.css: the layout of the page navigation.
  • locales/*/common.json: labels for the navigation (en, de, it).
  • package.json: depends on @plone/plate, for the main region's key. It already did so through @plone/layout, so there's no cycle.
  • Tests: Listing/*.test.ts(x) and config/server.test.ts are new or extended. index.test.ts and docs.test.ts only add settings: {} to their fake configs, because the install now sets defaultPageSize.

@plone/cmsui

  • components/QuerystringWidget/QuerystringWidget.tsx, QuerystringWidgetContext.tsx:
    • The value control follows each operator's widget from Plone. "Matches any of" / "Matches all of" (MultipleSelectionWidget) use Quanta's MultiSelect and store a list, as Volto does. Before, a single select showed one value of a list saved by Volto and replaced the whole list on any change.
    • Single-value operators keep a select; a value saved as a string still shows.
    • The search moved out of the widget's context, so the widget only edits the query.
  • components/QuerystringWidget/useQuerystringResults.ts, config/widgets.ts: the preview hook, registered as the default querystringResults utility. It searches in the edited page, so the preview matches the published page, and passes depth and the search options.
  • routes/querystringSearch.tsx: (the route itself was registered on main in Register the @querystringSearch route #267)
    • takes the whole querystring value (criteria and options);
    • keeps only well-formed criteria and the known options, so callers can't set e.g. fullobjects;
    • sends the search to Plone as a POST;
    • no longer decodes the parameter twice, which broke values containing %.
  • components/QuerystringWidget/QuerystringWidget.stories.tsx: the stories use the operators and widgets of Plone 6's @querystring, which they didn't before. A new "Saved by Volto" story shows list values.
  • Tests:
    • QuerystringWidget.test.tsx is new.
    • acceptance/tests/querystring-search.test.ts (Register the @querystringSearch route #267's) sends the whole querystring value, as its notes anticipated, and checks that the search options apply.
    • acceptance/tests/listing-block.test.ts covers:
      • the editor preview;
      • server rendering, and that results aren't saved;
      • item clicks in the editor;
      • content saved by Volto, with several types and a depth;
      • pagination.

@plone/client

  • validation/querystring-search.ts, restapi/querystring-search/get.ts:
    • sends the search options;
    • accepts the numbers and the boolean sort_order that blocks and Volto store;
    • adds path, to search in a content object;
    • applies depth to path criteria as path::depth, as Volto does, so a depth set in Volto lists the same content in Aurora.
  • Tests: querystring-search.test.ts.

@plone/aurora

  • app/config/server.server.ts: the listing loader moved to @plone/blocks, so this file only loses it.
  • app/config/server/migrations.server.ts: when content saved by Volto is converted for the editor, each Plone block keeps its id. This keeps Volto's per-listing page key (page_<block id>) working, and keeps the ids stable after the first save in Aurora. Before, converted blocks had no id. The test (content-migrations.server.test.ts) is updated.

@plone/types (.d.ts, types only)

  • services/querystring-search.d.ts: QuerystringParameter accepts what blocks store: numbers, a boolean sort_order, depth.
  • config/Utilities.d.ts: QuerystringResultsUtility, so the querystringResults utility is typed.
  • blocks/index.d.ts: ListingBlockFormData.pagination and ListingPagination.

Other

  • news/*: changelog entries for blocks, cmsui, client, aurora and types.
  • pnpm-lock.yaml: @plone/plate as a dependency of @plone/blocks.

📚 Documentation preview 📚: https://plone-aurora--107.org.readthedocs.build/

@nileshgulia1

Copy link
Copy Markdown
Member Author

@nileshgulia1 I fixed the defaultBlockWidth for the listing block (a ploneBlock) see the new docs about blocks width, we adjusted the story around lately.

I tried it out, and looks promising!! However, I could not make it work (criteria "Type" then type "Page"). Why does the type is not a dropdown? (Like the one in Volto).

I guess you are still on it! Keep in touch!

Thanks for the fix @sneridagh . I did a few more fixes in the latest commits. Now the type field looks fine, along with other metadata fields(sort_on, limit, b_size) that are supplied along with the main query.

# Conflicts:
#	packages/blocks/Listing/ListingBlockView.tsx
#	pnpm-lock.yaml
The listing block view fetched its own results from the CMS UI's
@querystringSearch route, so published pages rendered "No results" on
the server and showed items only after the client fetched them. The
server loader only looked for top-level listing blocks, and listings
now live inside the block editor's value.

- The server fills in the items of listing blocks at any depth, searches
  in the page so it isn't in its own listing, and empties a listing
  whose query fails instead of failing the page. It leaves the CMS UI
  views alone, so the edit form doesn't save the items.
- The view renders the items it gets, like the other blocks.
- The edit component previews the query with the `querystringResults`
  utility, which the CMS UI registers, so @plone/blocks no longer
  depends on react-router, usehooks-ts or CMS UI paths. The preview
  searches in the edited page too.
- @plone/client accepts the numbers and the boolean sort order that
  blocks store, and searches in a content object with `path`.
@read-the-docs-community

Copy link
Copy Markdown

The listing block's preview sends its whole querystring value: the
criteria and the search options. The route keeps the well-formed
criteria and the known options, so callers can't set others like
`fullobjects`, and searches with POST, as before.

It no longer decodes the parameter twice, which broke values with `%`.
The acceptance tests from #267 send the querystring value, as its notes
anticipated, and check that the options apply.
# Conflicts:
#	packages/aurora/src/app/config/server.server.ts
#	packages/cmsui/routes/querystringSearch.tsx
- Criterion values follow their operator: "Matches any of" takes several
  values with a multi-select and stores them as a list, as Volto does.
  The single select showed only one value of a list saved by Volto and
  replaced the list on any change. A value saved as a string still
  shows.
- @plone/client applies the `depth` of path criteria as `path::depth`,
  as Volto does, so the server and the editor preview list the same
  content as Volto. The route and the preview pass it on.
- The listing view links its items with the app's `Link`, and renders
  no links in the editor, like the teaser block, so a click doesn't
  leave the edit form.
The stories' indexes had made-up operators, like `is` with a single
`SelectionWidget` for Type, so they never showed the "Matches any of"
multi-select that Plone sites get. They now use the operations, titles
and widgets of Plone 6's `@querystring`, with `sortable_title` for
sorting, and a new story shows a query saved by Volto, whose values are
lists.
The placeholder shrank to the width of its text, because the block
container's `justify-items: start` applies to block layout in current
browsers.
@nileshgulia1

Copy link
Copy Markdown
Member Author

@sneridagh This is ready for another review. Would be great if you can look at this during the sprint. Thank you.

nileshgulia1 and others added 6 commits December 3, 2026 00:20
The listing showed the first 25 results only, the default batch of
Plone, without a way to see the others.

- The server loads the page in the URL, with the "Paginate every" of the
  block, or the new `defaultPageSize` setting (25, as in Volto). The page
  is in `page`, or `page_<block id>` when the page has several listings,
  the same parameters as Volto, so links keep working. It only loads the
  region the page renders.
- The view links to the other pages under the items, with contract
  classnames, keeping the other parameters and scrolling to the listing.
  They're links, so they work without JavaScript, and the server renders
  each page. The editor previews the first page, without links.
- The blocks migrated from Volto keep their id, which the page parameter
  uses.
The chevrons of @plone/icons, inline, since the Icon component adds
classes outside the content's classname contract. They keep "Previous
page" and "Next page" as their accessible names.
The loader of the listing blocks' results was in the app configuration
of @plone/aurora, which then had to import the listing's pagination
helpers from @plone/blocks. It's listing logic, so it now lives with
the block: @plone/blocks registers it as a `rootContentSubRequest`
utility in its `config/server.ts`, which the registry loads on the
server like @plone/cmsui's. The app configuration is back to main's,
without the loader.

The loader is unchanged. It types the arguments it uses with
@plone/types, as packages can't import from @plone/aurora, and
@plone/blocks depends on @plone/plate for the `main` region's key.
Resolves the conflicts with #539, which fixed listing blocks saved by
Volto on main. The listing loader of this branch, in `@plone/blocks`,
replaces the one #539 added to `@plone/aurora`. From #539 it keeps the
`metadata_fields` option of `querystringSearch`, the image guard of the
summary variation and the acceptance test for pages saved by Volto, and
`loadListings` now reads the query of blocks saved before Volto had block
schemas.

Assisted-by: Claude Opus 5.5
# Conflicts:
#	packages/blocks/package.json
@nileshgulia1 nileshgulia1 added the 24 status: ready for a PR it means, tests passing, merge me asap label Dec 3, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

24 status: ready for a PR it means, tests passing, merge me asap

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants