aboutsummaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorfenn-cs <fenn25.fn@gmail.com>2024-01-22 14:49:57 +0100
committerfenn-cs <fenn25.fn@gmail.com>2024-02-01 17:53:36 +0100
commitd9a2a7839224505195e65c05b794c523d9384c7a (patch)
treeb20278f38fd11ea91d493527d29ca1247cdc3f2f /apps
parent937a6a84fe9fbdbd8e3494f25d92a4e0fbc76376 (diff)
downloadnextcloud-server-d9a2a7839224505195e65c05b794c523d9384c7a.tar.gz
nextcloud-server-d9a2a7839224505195e65c05b794c523d9384c7a.zip
Consider admin defaults when creating shares
The current share logic always uses the default `BUNDLED_PERMISSIONS.ALL` which includes everything. This commit updates share creation logic to use `defaultPermissions` if set by admin for the creation of new shares. Signed-off-by: fenn-cs <fenn25.fn@gmail.com>
Diffstat (limited to 'apps')
-rw-r--r--apps/files_sharing/lib/Listener/LoadSidebarListener.php1
-rw-r--r--apps/files_sharing/src/services/ConfigService.js11
-rw-r--r--apps/files_sharing/src/views/SharingDetailsTab.vue34
3 files changed, 34 insertions, 12 deletions
diff --git a/apps/files_sharing/lib/Listener/LoadSidebarListener.php b/apps/files_sharing/lib/Listener/LoadSidebarListener.php
index 8e12e551183..7787a348d3a 100644
--- a/apps/files_sharing/lib/Listener/LoadSidebarListener.php
+++ b/apps/files_sharing/lib/Listener/LoadSidebarListener.php
@@ -51,6 +51,7 @@ class LoadSidebarListener implements IEventListener {
$shareConfig = [
'allowPublicUploads' => $this->shareManager->shareApiLinkAllowPublicUpload(),
+ 'defaultPermissions' => $this->shareManager->shareApiDefaultPermissions(),
];
$this->initialState->provideInitialState('shareConfig', $shareConfig);
diff --git a/apps/files_sharing/src/services/ConfigService.js b/apps/files_sharing/src/services/ConfigService.js
index d1d99e7be7a..8afa41e80e5 100644
--- a/apps/files_sharing/src/services/ConfigService.js
+++ b/apps/files_sharing/src/services/ConfigService.js
@@ -32,6 +32,17 @@ export default class Config {
}
/**
+ * Get default share permissions, if any
+ *
+ * @return {boolean}
+ * @readonly
+ * @memberof Config
+ */
+ get defaultPermissions() {
+ return this._shareConfig.defaultPermissions
+ }
+
+ /**
* Is public upload allowed on link shares ?
*
* @return {boolean}
diff --git a/apps/files_sharing/src/views/SharingDetailsTab.vue b/apps/files_sharing/src/views/SharingDetailsTab.vue
index 8893ee984a3..ef7f4964a84 100644
--- a/apps/files_sharing/src/views/SharingDetailsTab.vue
+++ b/apps/files_sharing/src/views/SharingDetailsTab.vue
@@ -16,8 +16,7 @@
</span>
</div>
<div class="sharingTabDetailsView__wrapper">
- <div ref="quickPermissions"
- class="sharingTabDetailsView__quick-permissions">
+ <div ref="quickPermissions" class="sharingTabDetailsView__quick-permissions">
<div>
<NcCheckboxRadioSwitch :button-variant="true"
:checked.sync="sharingPermission"
@@ -743,7 +742,7 @@ export default {
}
},
- initializePermissions() {
+ handleShareType() {
if (this.share.share_type) {
this.share.type = this.share.share_type
}
@@ -752,23 +751,34 @@ export default {
if ('shareType' in this.share) {
this.share.type = this.share.shareType
}
+ },
+ handleDefaultPermissions() {
if (this.isNewShare) {
- if (this.isPublicShare) {
- this.sharingPermission = BUNDLED_PERMISSIONS.READ_ONLY.toString()
+ const defaultPermissions = this.config.defaultPermissions
+ if (defaultPermissions === BUNDLED_PERMISSIONS.READ_ONLY || defaultPermissions === BUNDLED_PERMISSIONS.ALL) {
+ this.sharingPermission = defaultPermissions.toString()
} else {
- this.sharingPermission = BUNDLED_PERMISSIONS.ALL.toString()
- }
-
- } else {
- if (this.hasCustomPermissions || this.share.setCustomPermissions) {
this.sharingPermission = 'custom'
+ this.share.permissions = defaultPermissions
this.advancedSectionAccordionExpanded = true
this.setCustomPermissions = true
- } else {
- this.sharingPermission = this.share.permissions.toString()
}
}
},
+ handleCustomPermissions() {
+ if (!this.isNewShare && (this.hasCustomPermissions || this.share.setCustomPermissions)) {
+ this.sharingPermission = 'custom'
+ this.advancedSectionAccordionExpanded = true
+ this.setCustomPermissions = true
+ } else {
+ this.sharingPermission = this.share.permissions.toString()
+ }
+ },
+ initializePermissions() {
+ this.handleShareType()
+ this.handleDefaultPermissions()
+ this.handleCustomPermissions()
+ },
async saveShare() {
const permissionsAndAttributes = ['permissions', 'attributes', 'note', 'expireDate']
const publicShareAttributes = ['label', 'password', 'hideDownload']