diff --git a/apps/files_sharing/lib/Listener/LoadSidebarListener.php b/apps/files_sharing/lib/Listener/LoadSidebarListener.php
index cb5ebf8a792d8..c6a3c4c2683f6 100644
--- a/apps/files_sharing/lib/Listener/LoadSidebarListener.php
+++ b/apps/files_sharing/lib/Listener/LoadSidebarListener.php
@@ -23,6 +23,7 @@
* along with this program. If not, see .
*
*/
+
namespace OCA\Files_Sharing\Listener;
use OCA\Files_Sharing\AppInfo\Application;
@@ -30,13 +31,31 @@
use OCP\EventDispatcher\Event;
use OCP\EventDispatcher\IEventListener;
use OCP\Util;
+use OCP\AppFramework\Services\IInitialState;
+use OCP\Share\IManager;
+
+/**
+ * @template-implements IEventListener
+ */
+class LoadSidebarListener implements IEventListener
+{
-class LoadSidebarListener implements IEventListener {
- public function handle(Event $event): void {
+ public function __construct(private IInitialState $initialState, private IManager $shareManager)
+ {
+ }
+
+ public function handle(Event $event): void
+ {
if (!($event instanceof LoadSidebar)) {
return;
}
Util::addScript(Application::APP_ID, 'files_sharing_tab', 'files');
+
+ $shareConfig = [
+ 'allowPublicUploads' => $this->shareManager->shareApiLinkAllowPublicUpload(),
+ ];
+
+ $this->initialState->provideInitialState('shareConfig', $shareConfig);
}
}
diff --git a/apps/files_sharing/src/components/SharingEntryQuickShareSelect.vue b/apps/files_sharing/src/components/SharingEntryQuickShareSelect.vue
index a83ef50304848..b89574a2fca57 100644
--- a/apps/files_sharing/src/components/SharingEntryQuickShareSelect.vue
+++ b/apps/files_sharing/src/components/SharingEntryQuickShareSelect.vue
@@ -100,7 +100,7 @@ export default {
return options
},
supportsFileDrop() {
- if (this.isFolder) {
+ if (this.isFolder && this.config.isPublicUploadEnabled) {
const shareType = this.share.type ?? this.share.shareType
return [this.SHARE_TYPES.SHARE_TYPE_LINK, this.SHARE_TYPES.SHARE_TYPE_EMAIL].includes(shareType)
}
diff --git a/apps/files_sharing/src/services/ConfigService.js b/apps/files_sharing/src/services/ConfigService.js
index e3cd6ad8d46c8..39062d648468e 100644
--- a/apps/files_sharing/src/services/ConfigService.js
+++ b/apps/files_sharing/src/services/ConfigService.js
@@ -22,8 +22,14 @@
*
*/
+import { loadState } from '@nextcloud/initial-state'
+
export default class Config {
+ constructor() {
+ this._shareConfig = loadState('files_sharing', 'shareConfig', {})
+ }
+
/**
* Is public upload allowed on link shares ?
*
@@ -32,8 +38,7 @@ export default class Config {
* @memberof Config
*/
get isPublicUploadEnabled() {
- return document.getElementsByClassName('files-filestable')[0]
- && document.getElementsByClassName('files-filestable')[0].dataset.allowPublicUpload === 'yes'
+ return this._shareConfig.allowPublicUploads
}
/**
diff --git a/apps/files_sharing/src/views/SharingDetailsTab.vue b/apps/files_sharing/src/views/SharingDetailsTab.vue
index d77688df2d7ac..6246bdb65e31e 100644
--- a/apps/files_sharing/src/views/SharingDetailsTab.vue
+++ b/apps/files_sharing/src/views/SharingDetailsTab.vue
@@ -453,7 +453,7 @@ export default {
return this.share.id === null || this.share.id === undefined
},
allowsFileDrop() {
- if (this.isFolder) {
+ if (this.isFolder && this.config.isPublicUploadEnabled) {
if (this.share.type === this.SHARE_TYPES.SHARE_TYPE_LINK || this.share.type === this.SHARE_TYPES.SHARE_TYPE_EMAIL) {
return true
}