Skip to content

Commit 6b1d6f7

Browse files
Merge pull request #50571 from nextcloud/backport/50292/stable29
2 parents 4a290b6 + ff39f14 commit 6b1d6f7

File tree

7 files changed

+89
-36
lines changed

7 files changed

+89
-36
lines changed

apps/files/src/components/FilesListVirtual.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ export default defineComponent({
297297
* @param fileId File to open
298298
*/
299299
handleOpenFile(fileId: number|null) {
300-
if (fileId === null || this.openFileId === fileId) {
300+
if (fileId === null) {
301301
return
302302
}
303303

apps/files_sharing/src/services/SharingService.spec.ts

Lines changed: 76 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ describe('SharingService share to Node mapping', () => {
294294
tags: [window.OC.TAG_FAVORITE],
295295
}
296296

297-
const remoteFile = {
297+
const remoteFileAccepted = {
298298
mimetype: 'text/markdown',
299299
mtime: 1688721600,
300300
permissions: 19,
@@ -313,6 +313,25 @@ describe('SharingService share to Node mapping', () => {
313313
accepted: true,
314314
}
315315

316+
const remoteFilePending = {
317+
mimetype: 'text/markdown',
318+
mtime: 1688721600,
319+
permissions: 19,
320+
type: 'file',
321+
file_id: 1234,
322+
id: 4,
323+
share_type: ShareType.User,
324+
parent: null,
325+
remote: 'http://exampe.com',
326+
remote_id: '12345',
327+
share_token: 'share-token',
328+
name: '/test.md',
329+
mountpoint: '/shares/test.md',
330+
owner: 'owner-uid',
331+
user: 'sharee-uid',
332+
accepted: false,
333+
}
334+
316335
test('File', async () => {
317336
jest.spyOn(axios, 'get').mockReturnValueOnce(Promise.resolve({
318337
data: {
@@ -372,33 +391,64 @@ describe('SharingService share to Node mapping', () => {
372391
expect(folder.attributes.favorite).toBe(1)
373392
})
374393

375-
test('Remote file', async () => {
376-
jest.spyOn(axios, 'get').mockReturnValueOnce(Promise.resolve({
377-
data: {
378-
ocs: {
379-
data: [remoteFile],
394+
describe('Remote file', () => {
395+
test('Accepted', async () => {
396+
jest.spyOn(axios, 'get').mockReturnValueOnce(Promise.resolve({
397+
data: {
398+
ocs: {
399+
data: [remoteFileAccepted],
400+
},
380401
},
381-
},
382-
}))
383-
384-
const shares = await getContents(false, true, false, false)
385-
386-
expect(axios.get).toHaveBeenCalledTimes(1)
387-
expect(shares.contents).toHaveLength(1)
402+
}))
403+
404+
const shares = await getContents(false, true, false, false)
405+
406+
expect(axios.get).toHaveBeenCalledTimes(1)
407+
expect(shares.contents).toHaveLength(1)
408+
409+
const file = shares.contents[0] as File
410+
expect(file).toBeInstanceOf(File)
411+
expect(file.fileid).toBe(1234)
412+
expect(file.source).toBe('http://localhost/remote.php/dav/files/test/shares/test.md')
413+
expect(file.owner).toBe('owner-uid')
414+
expect(file.mime).toBe('text/markdown')
415+
expect(file.mtime?.getTime()).toBe(remoteFileAccepted.mtime * 1000)
416+
// not available for remote shares
417+
expect(file.size).toBe(undefined)
418+
expect(file.permissions).toBe(19)
419+
expect(file.root).toBe('/files/test')
420+
expect(file.attributes).toBeInstanceOf(Object)
421+
expect(file.attributes.favorite).toBe(0)
422+
})
388423

389-
const file = shares.contents[0] as File
390-
expect(file).toBeInstanceOf(File)
391-
expect(file.fileid).toBe(1234)
392-
expect(file.source).toBe('http://localhost/remote.php/dav/files/test/shares/test.md')
393-
expect(file.owner).toBe('owner-uid')
394-
expect(file.mime).toBe('text/markdown')
395-
expect(file.mtime?.getTime()).toBe(remoteFile.mtime * 1000)
396-
// not available for remote shares
397-
expect(file.size).toBe(undefined)
398-
expect(file.permissions).toBe(0)
399-
expect(file.root).toBe('/files/test')
400-
expect(file.attributes).toBeInstanceOf(Object)
401-
expect(file.attributes.favorite).toBe(0)
424+
test('Pending', async () => {
425+
jest.spyOn(axios, 'get').mockReturnValueOnce(Promise.resolve({
426+
data: {
427+
ocs: {
428+
data: [remoteFilePending],
429+
},
430+
},
431+
}))
432+
433+
const shares = await getContents(false, true, false, false)
434+
435+
expect(axios.get).toHaveBeenCalledTimes(1)
436+
expect(shares.contents).toHaveLength(1)
437+
438+
const file = shares.contents[0] as File
439+
expect(file).toBeInstanceOf(File)
440+
expect(file.fileid).toBe(1234)
441+
expect(file.source).toBe('http://localhost/remote.php/dav/files/test/shares/test.md')
442+
expect(file.owner).toBe('owner-uid')
443+
expect(file.mime).toBe('text/markdown')
444+
expect(file.mtime?.getTime()).toBe(remoteFilePending.mtime * 1000)
445+
// not available for remote shares
446+
expect(file.size).toBe(undefined)
447+
expect(file.permissions).toBe(0)
448+
expect(file.root).toBe('/files/test')
449+
expect(file.attributes).toBeInstanceOf(Object)
450+
expect(file.attributes.favorite).toBe(0)
451+
})
402452
})
403453

404454
test('Empty', async () => {

apps/files_sharing/src/services/SharingService.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,12 @@ const ocsEntryToNode = async function(ocsEntry: any): Promise<Folder | File | nu
5050
ocsEntry.item_mtime = ocsEntry.mtime
5151
ocsEntry.file_target = ocsEntry.file_target || ocsEntry.mountpoint
5252

53-
// Need to set permissions to NONE for federated shares
54-
ocsEntry.item_permissions = Permission.NONE
55-
ocsEntry.permissions = Permission.NONE
53+
// If the share is not accepted yet we don't know which permissions it will have
54+
if (!ocsEntry.accepted) {
55+
// Need to set permissions to NONE for federated shares
56+
ocsEntry.item_permissions = Permission.NONE
57+
ocsEntry.permissions = Permission.NONE
58+
}
5659

5760
ocsEntry.uid_owner = ocsEntry.owner
5861
// TODO: have the real display name stored somewhere

dist/files-main.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/files-main.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/files_sharing-init.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/files_sharing-init.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)