Skip to content

Migrate to nextcloud-viewer v2 - #2854

Merged
mejo- merged 16 commits into
mainfrom
migrate/viewer_v2
Oct 14, 2026
Merged

mejo- merged 16 commits into
mainfrom
migrate/viewer_v2

Conversation

@mejo-

@mejo- mejo- commented Oct 13, 2026 •

Copy link
Copy Markdown
Member

📝 Summary

Migrates Collectives from the Viewer app's global OCA.Viewer API to the bundled @nextcloud/viewer v2 library, while keeping the old Viewer app working on Nextcloud 33–35.

Viewer migration

  • Attachments, templates and the version comparison fallback use the v2 library (getViewer().open(), canView(), canCompare(), getViewer().compare()).
  • registerDefaultHandlers() registers image/audio/video handlers on Nextcloud < 36, where the server doesn't provide them yet.
  • The viewer's "Open sidebar" button opens the page sidebar on the attachments tab.

Compatibility with Nextcloud 33–35

  • On these versions, Text and the PDF viewer register their handlers only with the old Viewer app, which the v2 library can't see. Collectives therefore dispatches LoadViewer again where the Viewer app exists, and falls back to OCA.Viewer for files the library can't open (PDF/Markdown attachments, templates) and for version comparison.
  • Files the library can handle (e.g. images) use the v2 viewer on all versions.

Fixes

  • Attachments in public shares open in the viewer again (the node was built from relative download URL). Attachment WebDAV URLs are now derived from the page's WebDAV URL, which also works for page shares.

Tests and CI

  • Migrated the Cypress attachment tests to Playwright and added tests for reopening the page sidebar from the viewer and for opening attachments in collective and page shares.
  • CI no longer pins Text to a fixed commit; master runs against Text main. Tests adjusted to current Text: session route with file type (Nextcloud 35+), link bubble on hover (click on Nextcloud 33), comparison tab markup, image locator.
  • Toasts are located by role, as @nextcloud/dialogs 7.5 uses hashed CSS classes.
  • The Viewer app is installed in CI only for stable33–35.

🏁 Checklist

  • Code is properly formatted (npm run lint / npm run stylelint / composer run cs:check)
  • Sign-off message is added to all commits
  • Tests (unit, integration and/or end-to-end) passing and the changes are covered with tests

🤖 AI (if applicable)

  • The content of this PR was partly or fully generated using AI tools
  • The AI-generated content was reviewed, comprehended and tested by a human

@mejo- mejo- self-assigned this Oct 13, 2026
@github-project-automation github-project-automation Bot moved this to 🧭 Planning evaluation (don't pick) in 📝 Productivity team Oct 13, 2026
@mejo- mejo- moved this from 🧭 Planning evaluation (don't pick) to 👀 In review in 📝 Productivity team Oct 13, 2026
@mejo-
mejo- force-pushed the migrate/viewer_v2 branch 2 times, most recently from bacbfb9 to 62930d3 Compare October 14, 2026 13:14
@mejo-
mejo- requested a review from skjnldsv October 14, 2026 14:41
Comment thread src/util/viewer.ts
Comment on lines +59 to +70
export function versionNode(version: VersionInfo): File {
const isVersion = version.filename?.startsWith('/versions/')
return fileNode({
id: version.fileId,
source: version.source,
mime: version.mime,
root: isVersion ? `/versions/${getCurrentUser()?.uid}` : getRootPath(),
size: version.size,
mtime: new Date(version.mtime),
etag: version.etag,
})
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like someone would benefit from nextcloud/server#65395

nextcloud/server#65397

@max-nextcloud max-nextcloud left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Some tests still failing though it seems.

Comment thread cypress/e2e/page-details.spec.js Outdated
Comment thread cypress/e2e/page-details.spec.js Outdated
Comment thread AGENTS.md

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A lot of this seems useful for humans as well. I wonder if we could have all the generic useful stuff in our development docs and then point there from AGENTS.md to avoid duplication.
(As a follow up / separate from this PR)

@mejo-
mejo- force-pushed the migrate/viewer_v2 branch 2 times, most recently from 236161d to 7de80b0 Compare October 14, 2026 16:12
mejo- added 14 commits October 14, 2026 18:26
Signed-off-by: Jonas <jonas@freesources.org>
Fixes: #2766

Signed-off-by: Jonas <jonas@freesources.org>
Assisted-by: ClaudeCode:claude-opus-5-5
Also disable sidebar in templates view as we don't have a useful sidebar
there. The files sidebar is not available in Collectives.

Signed-off-by: Jonas <jonas@freesources.org>
Assisted-by: ClaudeCode:claude-opus-5-5
Nowadays Text doesn't open the link pill on click but only on hover.

Signed-off-by: Jonas <jonas@freesources.org>
Assisted-by: ClaudeCode:claude-opus-5-5
Signed-off-by: Jonas <jonas@freesources.org>
Assisted-by: ClaudeCode:claude-opus-5-5
Signed-off-by: Jonas <jonas@freesources.org>
Assisted-by: ClaudeCode:claude-opus-5-5
Signed-off-by: Jonas <jonas@freesources.org>
Assisted-by: ClaudeCode:claude-opus-5-5
Signed-off-by: Jonas <jonas@freesources.org>
Assisted-by: ClaudeCode:claude-opus-5-5
On public shares, the viewer node was built from the share download
link, which is a relative URL. `@nextcloud/files` rejects that, so
clicking an attachment fell through to the download link instead of
opening the viewer.

Build the attachment's WebDAV URL from the page's WebDAV URL instead.
Attachments are stored next to the page file, and the page URL already
points into the user's files or into the share. This also covers page
shares, where the share root is the page folder and not the collective
root.

Add a Playwright test for collective and page shares, and a
`createShare()` helper for page shares to the `CollectivePage` fixture.

Signed-off-by: Jonas <jonas@freesources.org>
Assisted-by: ClaudeCode:claude-opus-5-5
Signed-off-by: Jonas <jonas@freesources.org>
Assisted-by: ClaudeCode:claude-opus-5-5
While the new @nextcloud/viewer v2 also works on older Nextcloud
releases, no handlers are registered there by other apps, so we still
need to use the older OCA.Viewer way there.

Signed-off-by: Jonas <jonas@freesources.org>
Assisted-by: ClaudeCode:claude-opus-5-5
Signed-off-by: Jonas <jonas@freesources.org>
Assisted-by: ClaudeCode:claude-opus-5-5
Signed-off-by: Jonas <jonas@freesources.org>
Assisted-by: ClaudeCode:claude-opus-5-5
Signed-off-by: Jonas <jonas@freesources.org>
Assisted-by: ClaudeCode:claude-opus-5-5
mejo- added 2 commits October 14, 2026 18:26
Signed-off-by: Jonas <jonas@freesources.org>
Assisted-by: ClaudeCode:claude-opus-5-5
Signed-off-by: Jonas <jonas@freesources.org>
Assisted-by: ClaudeCode:claude-opus-5-5
@mejo-
mejo- force-pushed the migrate/viewer_v2 branch from 7de80b0 to 5b8769b Compare October 14, 2026 16:26
@mejo-

mejo- commented Oct 14, 2026

Copy link
Copy Markdown
Member Author

The failing Playwright test is unrelated (whiteboard app not migrated to viewer v2 yet).

@mejo-
mejo- merged commit 7ef046d into main Oct 14, 2026
60 of 64 checks passed
@mejo-
mejo- deleted the migrate/viewer_v2 branch October 14, 2026 16:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

Migrate off the OCA.Viewer global before Nextcloud 36

3 participants