Skip to content

Add History route (#30)#120

Draft
mliebischer wants to merge 13 commits into
mainfrom
30-cmsui-history-route
Draft

Add History route (#30)#120
mliebischer wants to merge 13 commits into
mainfrom
30-cmsui-history-route

Conversation

@mliebischer

@mliebischer mliebischer commented Jun 10, 2026

Copy link
Copy Markdown

Adds the CMSUI History route (/@@history/<path>)

Current state, open points, and follow-up issues are tracked in one place: #30 (comment).

Closes #30

Register an @@history route in cmsui that lists content revisions via the
plone.restapi @history endpoint and supports reverting to a previous
version. Add a History toolbar button in publicui linking to the route,
plus en/de/it locale strings and towncrier news fragments.
Extract the route's inline list into a prop-driven HistoryView component
styled like the @@contents view (Quanta table, breadcrumb with home icon,
status dots, relative timestamps). Replace the immediate revert submit
with a confirmation dialog and style the revert menu action as
destructive (red). Keep the dialog text stable during the close
animation, and hide the History toolbar button on the Plone Site root,
which has no history, matching Volto's behavior.
@mliebischer mliebischer linked an issue Jun 10, 2026 that may be closed by this pull request
Cover the view with vitest unit tests (status dot and relative-time
helpers, rendering, revert confirmation flow, axe accessibility check)
and Playwright acceptance tests (listing, revert with confirmation,
History toolbar button hidden on the site root). The axe check surfaced
an empty actions column header, now labelled via VisuallyHidden text.
Two bugs hid each other: the content middleware never read the ?version
query parameter, and getContent dropped the expand parameter whenever a
version was requested. The middleware now passes the version through
(including the anonymous retry), and getContent applies expand to the
@history endpoint as well. Covered by client integration tests,
a middleware test, and acceptance tests including that anonymous
visitors cannot access old revisions.
Number(formData.get('version')) turned a missing field into 0 and
garbage into NaN, both passed unchecked to revertHistory, and a failing
backend call threw into the error boundary. The action now rejects
invalid versions with a 400 data response and reports backend failures
as a 502 data response so the UI can react.
The dialog used to close right after submitting, so a failing revert
went unnoticed. It now stays open while the request is in flight with
the confirm button disabled, closes itself only on success, and shows
an inline error message otherwise (new locale strings in en/de/it).
The acceptance test now also asserts that the restored title is shown
after a successful revert.
An unparsable entry date crashed the whole route with a RangeError from
the date formatter; the raw value is now shown instead and each entry
date is parsed only once. Rows use stable entry-based keys instead of
array indexes, so identities survive loader revalidations after a
revert. Intl.RelativeTimeFormat instances are cached per locale instead
of being constructed per row.
Use t('cmsui.history.label') instead of a hardcoded aria-label.
Cover the anonymous login redirect, back-button navigation, empty
histories, the absolute-date tooltip, and the revert action's input
validation and error responses.
The site root is delivered as a content object with @type 'Plone Site',
but the Content union did not include it, so comparisons like
content['@type'] !== 'Plone Site' failed the TypeScript check.
Workflow rows now read like Volto: 'Publish (Private → Published)',
using the backend-translated state titles. Unlike Volto, no literal
'undefined' is shown when no previous state is known (e.g. creation);
those entries read 'Create (Private)'. This is an interim display until
the final action-label wording from the design is decided.
# Conflicts:
#	packages/cmsui/locales/de/common.json
#	packages/cmsui/locales/en/common.json
#	packages/cmsui/locales/it/common.json
#	packages/publicui/routes/index.tsx
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[CMSUI] - History route

1 participant