Micro-apps shared by Plone Aurora and Volto: a core package with a driver, and a thin adapter per app

Open
#380 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 2 days

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
1/100
Issue type
Feature
Clarity
Clearly specified
Activity status
Active

Research direction

This PLIP is explicitly restricted to Plone Team or Developers Team members and spans @plone/helpers, @plone/cmsui, @plone/types, @plone/tooling, @plone/controlpanels, @plone/contents, and Volto. Start with docs/conceptual-guides/packages-for-volto-and-aurora.md and the listed prerequisite content types stack (#271 → #369). Done requires the shared contracts, proxy and adapters, both micro-app migrations, enforcement, and documentation deliverables; this is broad design and implementation work.

Written by the indexing model from the issue text.

Description

03 type: feature (plip)

[!IMPORTANT]
If you are not a member of the Volto Team or Developers Team in the Plone GitHub organization, then do not work on or comment on this issue.

PLIP (Plone Improvement Proposal)

Responsible Persons

Proposer: Victor Fernandez de Alba (@sneridagh)
Seconder:

Abstract

Define one pattern for micro-apps: control panels and other self-contained management UIs, such as @plone/contents, that run unchanged in both Plone Aurora and Volto.

A micro-app is a core package that doesn't depend on either framework. It holds the screens, the domain types, a driver interface with capability flags, a mock driver, a shared plone.restapi driver, its messages and catalogs, its routes as data, and compiled scoped CSS. Each app connects it with a thin adapter for its own host services (routing, translations, notifications, navigation blocking), its transport to plone.restapi, and its route mounting.

The content types control panel (#269, stack #271 → #369, Volto plone/volto#8500) already follows most of this. This PLIP generalizes what is specific to @plone/controlpanels today into shared contracts, so the next micro-app doesn't have to rebuild them, and sets the path for @plone/contents.

Motivation

  • Plone Aurora and Volto will coexist for a long time. Writing every management screen twice, once per frontend, doesn't scale, and the two would drift apart.
  • @plone/controlpanels proved that a package can run as-is in both apps: no framework imports, app services from a provider, backend data from a driver, translations shaped like react-i18next's, and scoped compiled CSS for Volto. The pattern is written down in docs/conceptual-guides/packages-for-volto-and-aurora.md (#353).
  • Much of it is still specific to control panels. A second micro-app would need:
    • a second provider (ControlPanelsProvider, translationFromIntl, useNavigationBlocker, ControlPanelsScope), even though nothing in them is about control panels,
    • a second adapter in each app (ContentTypesProviders in cmsui, another in Volto),
    • in Aurora, two more hand-written files that map each driver method to a URL and back (auroraDriver.ts, 127 lines, and routes/api/contentTypes.tsx, 139 lines).
  • @plone/contents is the opposite case today. It depends on @plone/cmsui, @plone/layout, @plone/components, @plone/client and react-router. Its 12 route modules use React Router actions, and its components call useFetcher and similar hooks about 20 times. It can't run in Volto.

Assumptions

  • plone.restapi is the only backend contract. Micro-apps never call a backend directly.
  • Both apps can run React 18+, React Aria Components, @plone/quanta and @plone/helpers.
  • Volto compiles TypeScript source packages through its Babel includes and the server bundle's allow list in razzle.config.js, as it already does for @plone/controlpanels and @plone/helpers.
  • One @plone/registry per app, used as a peer dependency (#352).

Proposal & Implementation

1. The core package

A micro-app package contains:

  • Screens: page components that take their route params as props.
  • Domain types and a driver interface: <Domain>Driver, a plain object of async methods, with a capabilities object. Optional methods exist only when their capability is on, and NO_CAPABILITIES is the baseline. The screens hide or disable, with an explanation, what the backend can't do yet, so they work with the released plone.restapi and gain features as new services land.
  • Drivers:
    • a mock driver with fixtures from a real site, for Storybook and unit tests,
    • createRestApiDriver(request), the shared translation between the domain and plone.restapi,
    • detectRestApi(request), which finds out which services the backend has.
  • Paths and a route table: the base path, href builders, and the routes as data, for example [{ path: '', page: 'list' }, { path: ':type/:tab?', page: 'type' }].
  • Messages and catalogs: t(key, { defaultValue, ...values }), {{x}} placeholders, ids namespaced by package, catalogs in locales/<lang>/common.json.
  • Compiled CSS for Volto: every rule scoped with :where(.<scope>), without cascade layers.
  • Source, not a build: like the other add-ons.

Allowed dependencies: React, React Aria Components, @plone/quanta, @plone/helpers, @plone/icons, @plone/types, jotai, and @plone/registry as a peer dependency.

2. One shared host contract, in @plone/helpers

Move these from @plone/controlpanels to @plone/helpers, renamed to be generic:

  • ControlPanelsProvider → HostProvider: navigate, useHref, t, notify, useBlocker, each with a default, so screens also run without an app.
  • useTranslate, useNotify, useNavigate, useNavigationBlocker.
  • translationFromIntl(intl), interpolate, defineMessages.
  • ControlPanelsScope → HostScope, the scope element plus React Aria's UNSAFE_PortalProvider, so popovers and dialogs get the scoped styles.

@plone/helpers already runs in both apps, so this adds no package. Each app writes its host adapter once (Aurora in cmsui, Volto in core), and every micro-app reuses it. @plone/plate can adopt it later.

3. A shared transport type

RestApiRequest, a function that calls plone.restapi and rejects with { status, data } like @plone/client and Volto's Api, moves to @plone/helpers. Each app implements it once:

  • Volto: voltoRequest(Api), in the browser.
  • Aurora: on the server, through @plone/client, with the user's credentials.
4. A generic driver proxy in Aurora

Aurora runs drivers on the server. Instead of one hand-written resource route and one client driver per micro-app:

  • One resource route, /@driver/:app/:method: takes the method's arguments as JSON, runs the server driver with the user's credentials, and returns JSON or an error with its status.
  • One client, createProxyDriver<D>(app, capabilities).
  • Server driver factories registered in the registry, for example config.registerUtility({ type: 'driverFactory', name: 'content-types', method: (request) => createRestApiDriver(request) }).

Adding a micro-app to Aurora then needs no API code. Trade-offs:

  • No REST-style, cacheable GET URLs. That's acceptable for management UIs.
  • Methods that send or return a Blob, such as import and export, need a multipart or binary path.

Volto needs no proxy: it runs createRestApiDriver(voltoRequest(Api)) in the browser.

5. Routes as data

The package exports its route table, and each adapter maps it:

  • Aurora: to React Router's routes.ts. Loaders only detect capabilities on the server (detectRestApi, cached).
  • Volto: to routes.js.

Screens load their data through the driver (useDriverData). Server-side rendering of the data can come later as an optional initialData seed from Aurora's loaders.

6. Shared enforcement

dependencies.test.ts and the no-restricted-imports list of @plone/controlpanels become a reusable check in @plone/tooling, so every micro-app gets the same allow list from one place.

7. First adopters
  1. @plone/controlpanels moves onto the shared host contract, transport type and proxy, after the content types stack (#271 → #369) is merged, not inside it.
  2. @plone/contents:
    1. Define a ContentsDriver: listing with batching, sorting and index columns; delete, rename, order, copy and paste, workflow, tags, properties and upload; capabilities.
    2. Move the plone.restapi code from the route actions into its createRestApiDriver.
    3. Switch the components to the driver and the host hooks. Drop the @plone/cmsui, @plone/layout, @plone/components, @plone/client, react-router and react-i18next dependencies. Toasts go through notify, and the clipboard becomes a jotai store inside the package.
    4. Replace the 12 route modules with the generic adapter.
    5. In Volto, offer it as an opt-in route first. Replacing Volto's Folder Contents is a product decision for a later step.

Deliverables

  • @plone/helpers: HostProvider, HostScope, host hooks, translationFromIntl, RestApiRequest, with tests.
  • @plone/cmsui: the Aurora host adapter, /@driver/:app/:method, createProxyDriver, the driver factory registry.
  • @plone/types: typings for the driver factory utility.
  • @plone/tooling: the shared dependencies check and ESLint rule.
  • @plone/controlpanels: moved onto the shared contracts.
  • @plone/contents: refactored as a micro-app.
  • Volto (plone/volto): a host adapter and voltoRequest(Api) in core, shared by @plone/controlpanels and later @plone/contents.
  • Documentation: docs/conceptual-guides/packages-for-volto-and-aurora.md (#353) extended into the micro-app guide, plus a how-to for creating a micro-app. The root and package AGENTS.md files updated.

Risks

  • Breaking changes for @plone/controlpanels: the provider exports move to @plone/helpers. It's still an alpha, and Volto (plone/volto#8500) is the only consumer, so the change happens before its first stable release. The old names can stay as deprecated re-exports for one release.
  • Versions in Volto: Volto must pin @plone/helpers and every micro-app to compatible versions. A micro-app declares the helpers range it needs as a peer dependency.
  • Server-side rendering in Aurora: micro-apps load their data in the browser through the driver, so their screens render on the server without data until initialData exists. For management UIs this is acceptable.
  • Generic proxy: without care, it could expose driver methods to users who shouldn't call them. Every call still runs against plone.restapi with the user's own credentials, so plone.restapi's permission checks apply. The proxy only runs registered factories.
  • @plone/contents refactor: this is a large change to a working package. Acceptance tests must pass before and after each step.
  • Two frontends, one UI: micro-apps look like Quanta in Volto, not Semantic UI. This is already accepted for the content types control panel.

Participants

  • Victor Fernandez de Alba (@sneridagh)
    Assisted-by: Claude Opus 5.5
Dominant language
JavaScript
Stars
10
Forks
9
Avg merge
4d 7h
Merged PRs (30d)
54

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from plone/aurora

All issues in plone/aurora

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.