-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
feat(viewer): drop the bundled viewer app for @nextcloud/viewer #63954
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
skjnldsv
wants to merge
10
commits into
master
Choose a base branch
from
feat/merge-viewer
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,849
−100
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
c7f596f
test(playwright): bring the viewer e2e suite into the server harness
skjnldsv 07f1257
build(deps): add @nextcloud/viewer
skjnldsv de56044
feat(core): report the enabled preview providers as a capability
skjnldsv 7251647
feat(files): load the viewer on every page
skjnldsv 39f118a
fix: open files through the viewer package, not through OCA.Viewer
skjnldsv 52b0da0
chore(viewer): drop the bundled viewer app
skjnldsv 2b36e72
fix(viewer): address review
skjnldsv d0acfa9
fix(viewer): build the viewer entry with the vue 3 frontend
skjnldsv 1bfa328
style: sort the import the fixer wanted elsewhere
skjnldsv 7d3288e
chore(deps): bump @nextcloud/viewer to 2.0.0-beta.7
skjnldsv File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,99 @@ | ||
| /** | ||
| * SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors | ||
| * SPDX-License-Identifier: AGPL-3.0-or-later | ||
| */ | ||
|
|
||
| import type { INode } from '@nextcloud/files' | ||
| import type { Version } from './versions.ts' | ||
|
|
||
| import { File, Permission } from '@nextcloud/files' | ||
| import { beforeEach, describe, expect, it, vi } from 'vitest' | ||
|
|
||
| vi.mock('@nextcloud/auth', async (orig) => { | ||
| // eslint-disable-next-line @typescript-eslint/consistent-type-imports -- vitest importOriginal idiom | ||
| const actual = await orig<typeof import('@nextcloud/auth')>() | ||
| return { | ||
| ...actual, | ||
| getCurrentUser: () => ({ uid: 'alice', displayName: 'Alice', isAdmin: false }), | ||
| } | ||
| }) | ||
|
|
||
| const { versionToNode } = await import('./versions.ts') | ||
|
|
||
| /** | ||
| * Build the file a version belongs to. | ||
| */ | ||
| function makeNode(): INode { | ||
| return new File({ | ||
| id: 42, | ||
| source: 'https://cloud.example.com/remote.php/dav/files/alice/holiday.jpg', | ||
| root: '/files/alice', | ||
| owner: 'alice', | ||
| mime: 'image/jpeg', | ||
| mtime: new Date('2025-01-22T11:20:00Z'), | ||
| }) | ||
| } | ||
|
|
||
| /** | ||
| * Build a version of that file, as fetchVersions returns them. | ||
| * | ||
| * @param overrides - Fields to override on the version | ||
| */ | ||
| function makeVersion(overrides: Partial<Version> = {}): Version { | ||
| return { | ||
| fileId: '42', | ||
| label: '', | ||
| author: 'alice', | ||
| authorName: 'Alice', | ||
| filename: '/versions/alice/versions/42/1737542400', | ||
| basename: '22 January 2025, 11:20:00', | ||
| mime: 'image/jpeg', | ||
| etag: 'abc123', | ||
| size: 1024, | ||
| type: 'file', | ||
| mtime: 1737542400000, | ||
| permissions: 'R', | ||
| previewUrl: 'https://cloud.example.com/apps/files_versions/preview?file=/holiday.jpg&version=1737542400', | ||
| url: '/remote.php/dav/versions/alice/versions/42/1737542400', | ||
| source: 'https://cloud.example.com/remote.php/dav/versions/alice/versions/42/1737542400', | ||
| fileVersion: '1737542400', | ||
| ...overrides, | ||
| } as Version | ||
| } | ||
|
|
||
| describe('versionToNode', () => { | ||
| let node: INode | ||
|
|
||
| beforeEach(() => { | ||
| node = makeNode() | ||
| }) | ||
|
|
||
| it('points at the version content rather than at its thumbnail', () => { | ||
| const version = versionToNode(makeVersion(), node) | ||
|
|
||
| expect(version.source).toBe('https://cloud.example.com/remote.php/dav/versions/alice/versions/42/1737542400') | ||
| // The version preview is a 250px thumbnail meant for the list, so the | ||
| // viewer has to load the version itself | ||
| expect(version.attributes.hasPreview).toBe(false) | ||
| }) | ||
|
|
||
| it('reads as the date it was taken, not as its id on the server', () => { | ||
| const version = versionToNode(makeVersion(), node) | ||
|
|
||
| expect(version.basename).toBe('1737542400') | ||
| expect(version.displayname).toBe('22 January 2025, 11:20:00') | ||
| }) | ||
|
|
||
| it('is read-only, whatever the file it belongs to allows', () => { | ||
| const version = versionToNode(makeVersion(), node) | ||
|
|
||
| expect(version.permissions).toBe(Permission.READ) | ||
| }) | ||
|
|
||
| it('takes the mime of the file when the version reports none', () => { | ||
| // The current version comes back with an empty mime | ||
| const version = versionToNode(makeVersion({ mime: '' }), node) | ||
|
|
||
| expect(version.mime).toBe('image/jpeg') | ||
| }) | ||
| }) |
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.