Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
# SPDX-License-Identifier: AGPL-3.0-or-later
engine-strict=false

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion css/viewer-main.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
/* extracted by css-entry-points-plugin */
@import './main-labEDf3j.chunk.css';
@import './main-DlOIBv-C.chunk.css';
@import './previewUtils-CU5qdRbf.chunk.css';
2 changes: 1 addition & 1 deletion js/viewer-main.mjs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/viewer-main.mjs.map

Large diffs are not rendered by default.

80 changes: 80 additions & 0 deletions playwright/e2e/sharing/delete-share.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/**
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

import type { Page } from '@playwright/test'

import { createRandomUser, expect, test, type User } from '../../support/fixtures.ts'
import { getRowForFile, openFile } from '../../support/filesUtils.ts'
import { visitPublicShare } from '../../support/shareUtils.ts'
import {
expectViewerLoaded,
getMenuItem,
getViewer,
openHeaderMenu,
} from '../../support/viewerUtils.ts'
import {
createFolder,
createShare,
Permission,
ShareType,
uploadFile,
} from '../../support/webdav.ts'

const fileName = 'image1.jpg'

test.describe.serial(`Delete ${fileName} in viewer in link share`, () => {
let page: Page
let user: User

test.beforeAll(async ({ browser }) => {
page = await browser.newPage()
user = await createRandomUser()
await createFolder(user, '/Photos')
await uploadFile(user, 'image1.jpg', 'image/jpeg', '/Photos/image1.jpg')
})

test.afterAll(async () => {
await page.close()
})

test('See the shared file in the list', async () => {
// Delete from the viewer is only offered with the delete permission.
const token = await createShare(user, '/Photos', {
shareType: ShareType.Link,
permissions: Permission.READ | Permission.UPDATE | Permission.CREATE | Permission.DELETE,
})
if (!token) {
throw new Error('createShare: no token returned for /Photos')
}
await visitPublicShare(page, token)
await expect(getRowForFile(page, fileName)).toContainText('image1 .jpg')
})

test('Open the viewer on file click', async () => {
await openFile(page, fileName)
await expect(getViewer(page)).toBeVisible()
})

test('Does not see a loading animation', async () => {
await expectViewerLoaded(page)
})

test('See the delete entry in the menu', async () => {
await openHeaderMenu(page)
await expect(getMenuItem(page, 'Delete')).toBeVisible()
})

test('Delete the image and close the viewer', async () => {
await getMenuItem(page, 'Delete').click()
})

test('Does not see the viewer anymore', async () => {
await expect(getViewer(page)).toHaveCount(0)
})

test('Does not see the image in the list anymore', async () => {
await expect(getRowForFile(page, fileName)).toHaveCount(0)
})
})
8 changes: 7 additions & 1 deletion playwright/support/webdav.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,13 @@ export const fixturePath = (fixture: string): string => resolve(FIXTURES_DIR, fi
// Share constants, mirrored from @nextcloud/sharing (ShareType) and
// @nextcloud/files (Permission) to avoid pulling browser-only deps into Node.
export const ShareType = { User: 0, Link: 3 } as const
export const Permission = { READ: 1 } as const
export const Permission = {
READ: 1,
UPDATE: 2,
CREATE: 4,
DELETE: 8,
SHARE: 16,
} as const

export interface ShareOptions {
shareType: number
Expand Down
5 changes: 4 additions & 1 deletion src/views/Viewer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -1241,7 +1241,10 @@ export default defineComponent({
try {
const fileid = this.currentFile.fileid
const url = this.currentFile.source ?? this.currentFile.davPath
const isDavResource = url.includes('remote.php/dav')
// Public shares are served over the public.php dav endpoint
// (public.php/dav for the web UI, public.php/webdav for legacy clients),
// so they are dav resources as well and need a root path.
const isDavResource = /(remote|public)\.php\/(web)?dav/i.test(url)

// Fake node to emit the event until Viewer is migrated to the new Node API.
// The node source must stay un-encoded (like the nodes built elsewhere in
Expand Down
Loading