Skip to content

Commit 6c177aa

Browse files
committed
fix: display shared file versions
Instead of checking permissions of the space, check permissions directly on the resource object if it is an incoming share because the space is manually built there without permissions.
1 parent a6b47f0 commit 6c177aa

File tree

6 files changed

+49
-7
lines changed

6 files changed

+49
-7
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Bugfix: Display shared file versions
2+
3+
We've fixed an issue where versions were not displayed in the sidebar for a shared file even when shared with necessary permissions. If a resource is an incoming share, we are now checking permission directly on the resource object instead of space.
4+
5+
https://github.com/owncloud/web/pull/12194
6+
https://github.com/owncloud/web/issues/12168

packages/web-client/src/helpers/share/functions.ts

+1
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ export function buildIncomingShareResource({
162162
canCreate: () => sharePermissions.includes(GraphSharePermission.createChildren),
163163
canBeDeleted: () => sharePermissions.includes(GraphSharePermission.deleteStandard),
164164
canEditTags: () => sharePermissions.includes(GraphSharePermission.createChildren),
165+
canListVersions: () => sharePermissions.includes(GraphSharePermission.readVersions),
165166
isMounted: () => false,
166167
isReceivedShare: () => true,
167168
canShare: () => false,

packages/web-client/src/helpers/share/types.ts

+1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ export interface IncomingShareResource extends ShareResource {
4141
syncEnabled: boolean
4242
shareRoles: UnifiedRoleDefinition[]
4343
sharePermissions: GraphSharePermission[]
44+
canListVersions(): boolean
4445
}
4546

4647
export interface ShareRole extends UnifiedRoleDefinition {

packages/web-pkg/src/composables/resources/useCanListVersions.ts

+12-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
import { useUserStore } from '../piniaStores'
2-
import { isSpaceResource, isTrashResource, Resource, SpaceResource } from '@ownclouders/web-client'
2+
import {
3+
IncomingShareResource,
4+
isSpaceResource,
5+
isTrashResource,
6+
Resource,
7+
SpaceResource
8+
} from '@ownclouders/web-client'
39

410
export const useCanListVersions = () => {
511
const userStore = useUserStore()
@@ -14,6 +20,11 @@ export const useCanListVersions = () => {
1420
if (isTrashResource(resource)) {
1521
return false
1622
}
23+
24+
if (resource.isReceivedShare()) {
25+
return (resource as IncomingShareResource).canListVersions()
26+
}
27+
1728
return space?.canListVersions({ user: userStore.user })
1829
}
1930

packages/web-pkg/tests/unit/components/FilesList/ResourceTable.spec.ts

+8-5
Original file line numberDiff line numberDiff line change
@@ -188,14 +188,14 @@ const resourcesWithAllFields = [
188188
shareTypes: [],
189189
canRename: vi.fn(),
190190
getDomSelector: () => extractDomSelector('documents'),
191-
canDownload: () => true
191+
canDownload: () => true,
192+
canListVersions: () => true
192193
},
193194
{
194195
id: 'another-one==',
195196
driveId: 'another-one==',
196197
name: 'Another one',
197198
path: '/Another one',
198-
indicators,
199199
isFolder: true,
200200
type: 'folder',
201201
size: '237895',
@@ -213,14 +213,14 @@ const resourcesWithAllFields = [
213213
tags: [],
214214
canRename: vi.fn(),
215215
getDomSelector: () => extractDomSelector('another-one=='),
216-
canDownload: () => true
216+
canDownload: () => true,
217+
canListVersions: () => true
217218
},
218219
{
219220
id: 'in-delete-queue==',
220221
driveId: 'another-one==',
221222
name: 'In delete queue',
222223
path: '/In delete queue',
223-
indicators,
224224
isFolder: true,
225225
type: 'folder',
226226
size: '237895',
@@ -238,7 +238,8 @@ const resourcesWithAllFields = [
238238
tags: [],
239239
canRename: vi.fn(),
240240
getDomSelector: () => extractDomSelector('in-delete-queue=='),
241-
canDownload: () => true
241+
canDownload: () => true,
242+
canListVersions: () => true
242243
}
243244
] as IncomingShareResource[]
244245

@@ -270,6 +271,7 @@ const processingResourcesWithAllFields = [
270271
canRename: vi.fn(),
271272
getDomSelector: () => extractDomSelector('forest'),
272273
canDownload: () => true,
274+
canListVersions: () => true,
273275
processing: true
274276
},
275277
{
@@ -296,6 +298,7 @@ const processingResourcesWithAllFields = [
296298
canRename: vi.fn(),
297299
getDomSelector: () => extractDomSelector('notes'),
298300
canDownload: () => true,
301+
canListVersions: () => true,
299302
processing: true
300303
}
301304
] as IncomingShareResource[]

packages/web-pkg/tests/unit/composables/resources/useCanListVersions.spec.ts

+21-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
import { getComposableWrapper } from '@ownclouders/web-test-helpers'
22
import { mock } from 'vitest-mock-extended'
3-
import { Resource, SpaceResource, TrashResource } from '@ownclouders/web-client'
3+
import {
4+
IncomingShareResource,
5+
Resource,
6+
SpaceResource,
7+
TrashResource
8+
} from '@ownclouders/web-client'
49
import { useCanListVersions } from '../../../../src/composables/resources'
510

611
describe('useCanListVersions', () => {
@@ -55,6 +60,21 @@ describe('useCanListVersions', () => {
5560
}
5661
})
5762
})
63+
64+
it('should use resource permissions instead of space permissions for received shares', () => {
65+
getWrapper({
66+
setup: ({ canListVersions }) => {
67+
const space = mock<SpaceResource>({ canListVersions: () => false })
68+
const resource = mock<IncomingShareResource>({
69+
type: 'file',
70+
isReceivedShare: () => true,
71+
canListVersions: () => true
72+
})
73+
const canList = canListVersions({ space, resource })
74+
expect(canList).toBeTruthy()
75+
}
76+
})
77+
})
5878
})
5979
})
6080

0 commit comments

Comments
 (0)