Skip to content
Open
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
4 changes: 3 additions & 1 deletion apps/files_sharing/src/public/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,13 @@ if (fileId !== null) {
// The router lands its first navigation, to the URL the page was opened
// with, asynchronously: a push made before it finishes is overwritten by it,
// and the shared file is never opened
const currentOpenFile = window.OCP.Files.Router.query.openfile
const openfile = currentOpenFile !== undefined && currentOpenFile.toLowerCase() === 'false' ? 'false' : 'true'
router.isReady()
.then(() => window.OCP.Files.Router.goToRoute(
'filelist',
{ ...window.OCP.Files.Router.params, token, fileid: String(fileId) },
{ ...window.OCP.Files.Router.query, openfile: 'true' },
{ ...window.OCP.Files.Router.query, openfile },
))
.catch((error) => logger.error('Could not open the shared file', { error }))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,16 @@ test.describe('files_sharing: Public share - downloading a shared file', () => {
expect(download.suggestedFilename()).toBe('file.txt')
expect(await readDownloadText(download)).toBe('<content>foo</content>')
})

test('respects openfile=false parameter for shared file without opening viewer', async ({ page, user, ownerRequest, publicShare, filesListPage }) => {
const fileId = await uploadContent(ownerRequest, user, '<content>foo</content>', 'text/plain', '/file.txt')
const share = await createLinkShare(ownerRequest, '/file.txt')
await publicShare.open(`${share.url}?openfile=false`)

const row = filesListPage.getRowForFileId(Number(fileId))
await expect(row).toBeVisible()
await expect(page.getByRole('dialog', { name: 'file.txt' })).toHaveCount(0)
})
})

test.describe('files_sharing: Public share - downloading from a shared folder', () => {
Expand Down