Skip to content

Commit cccdaf9

Browse files
committed
feat(files_sharing): Hide external shares for users in excluded groups
- Added frontend check to hide link shares if, public sharing is disabled. Signed-off-by: nfebe <fenn25.fn@gmail.com>
1 parent 6f2fbef commit cccdaf9

1 file changed

Lines changed: 25 additions & 2 deletions

File tree

apps/files_sharing/src/views/SharingTab.vue

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@
100100
:file-info="fileInfo"
101101
@open-sharing-details="toggleShareDetailsView" />
102102
<!-- link shares list -->
103-
<SharingLinkList v-if="!loading"
103+
<SharingLinkList v-if="!loading && isLinkSharingAllowed"
104104
ref="linkShareList"
105105
:can-reshare="canReshare"
106106
:file-info="fileInfo"
@@ -157,6 +157,7 @@
157157

158158
<script>
159159
import { getCurrentUser } from '@nextcloud/auth'
160+
import { getCapabilities } from '@nextcloud/capabilities'
160161
import { orderBy } from '@nextcloud/files'
161162
import { loadState } from '@nextcloud/initial-state'
162163
import { generateOcsUrl } from '@nextcloud/router'
@@ -242,7 +243,25 @@ export default {
242243
* @return {boolean}
243244
*/
244245
isSharedWithMe() {
245-
return Object.keys(this.sharedWithMe).length > 0
246+
return this.sharedWithMe !== null
247+
&& this.sharedWithMe !== undefined
248+
},
249+
250+
/**
251+
* Is link sharing allowed for the current user?
252+
* This checks if the user is in a group that is excluded from link sharing
253+
*
254+
* @return {boolean}
255+
*/
256+
isLinkSharingAllowed() {
257+
const currentUser = getCurrentUser()
258+
if (!currentUser) {
259+
return false
260+
}
261+
262+
const capabilities = getCapabilities()
263+
const publicSharing = capabilities.files_sharing?.public || {}
264+
return publicSharing.enabled === true
246265
},
247266
248267
canReshare() {
@@ -264,6 +283,10 @@ export default {
264283
},
265284
266285
methods: {
286+
/**
287+
* Fetch the current user's groups
288+
*/
289+
267290
/**
268291
* Update current fileInfo and fetch new data
269292
*

0 commit comments

Comments
 (0)