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
9 changes: 8 additions & 1 deletion apps/files_sharing/src/mixins/SharesMixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ import { ShareType } from '@nextcloud/sharing'
import debounce from 'debounce'
import PQueue from 'p-queue'
import { markRaw } from 'vue'
import { getBundledPermissions } from '../lib/SharePermissionsToolBox.js'
import {
ATOMIC_PERMISSIONS,
getBundledPermissions,
} from '../lib/SharePermissionsToolBox.js'
import Share from '../models/Share.ts'
import Config from '../services/ConfigService.ts'
import logger from '../services/logger.ts'
Expand Down Expand Up @@ -143,7 +146,11 @@ export default {
basePermissions.READ_ONLY,
basePermissions.FILE_DROP,
]
// READ_ONLY and FILE_DROP never carry SHARE, so a link share created with it still matches.
const permissionsWithoutShare = this.share.permissions & ~ATOMIC_PERMISSIONS.SHARE
return !bundledPermissions.includes(this.share.permissions)
&& permissionsWithoutShare !== basePermissions.READ_ONLY
&& permissionsWithoutShare !== basePermissions.FILE_DROP
},
maxExpirationDateEnforced() {
if (this.isExpiryDateEnforced) {
Expand Down
21 changes: 21 additions & 0 deletions apps/files_sharing/src/mixins/SharesMixin.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,24 @@ describe('SharesMixin.data', () => {
await expect(state.updateQueue.add(async () => 'done')).resolves.toBe('done')
})
})

describe('SharesMixin.hasCustomPermissions', () => {
function check(permissions: number) {
const ctx = { share: { permissions }, config: { excludeReshareFromEdit: false } }
return (SharesMixin.computed.hasCustomPermissions as () => boolean).call(ctx)
}

it('treats a new link share (read and share) as view only', () => {
expect(check(17)).toBe(false)
})

it('treats read only and file drop as bundles', () => {
expect(check(1)).toBe(false)
expect(check(4)).toBe(false)
})

it('keeps other combinations custom', () => {
expect(check(3)).toBe(true)
expect(check(21)).toBe(true)
})
})
5 changes: 4 additions & 1 deletion apps/files_sharing/src/views/SharingDetailsTab.vue
Original file line number Diff line number Diff line change
Expand Up @@ -1133,7 +1133,10 @@ export default {
this.advancedSectionAccordionExpanded = true
this.setCustomPermissions = true
} else if (this.share.permissions) {
this.sharingPermission = this.share.permissions.toString()
const permissionsWithoutShare = this.share.permissions & ~ATOMIC_PERMISSIONS.SHARE
const isViewOnlyOrDrop = permissionsWithoutShare === this.bundledPermissions.READ_ONLY
|| permissionsWithoutShare === this.bundledPermissions.FILE_DROP
this.sharingPermission = (isViewOnlyOrDrop ? permissionsWithoutShare : this.share.permissions).toString()
}
},

Expand Down