diff options
author | fenn-cs <fenn25.fn@gmail.com> | 2023-09-11 21:06:23 +0100 |
---|---|---|
committer | fenn-cs <fenn25.fn@gmail.com> | 2023-09-13 10:18:08 +0100 |
commit | 51ad9cfcc8c7ceefbe33b9f3d96cd6ef75ddf9ec (patch) | |
tree | 5777e316ce58b1895cdce9a0f48136744bb48d8c /apps/files_sharing | |
parent | cec466ed3bdd35a7143a159eb5f46af013f87cff (diff) | |
download | nextcloud-server-51ad9cfcc8c7ceefbe33b9f3d96cd6ef75ddf9ec.tar.gz nextcloud-server-51ad9cfcc8c7ceefbe33b9f3d96cd6ef75ddf9ec.zip |
Enfore allowPublicShares admin setting
Use the the modern intial-state library to pass data about
`allowPublicUploads` to the sharing frontend.
Signed-off-by: fenn-cs <fenn25.fn@gmail.com>
Diffstat (limited to 'apps/files_sharing')
4 files changed, 30 insertions, 6 deletions
diff --git a/apps/files_sharing/lib/Listener/LoadSidebarListener.php b/apps/files_sharing/lib/Listener/LoadSidebarListener.php index cb5ebf8a792..c6a3c4c2683 100644 --- a/apps/files_sharing/lib/Listener/LoadSidebarListener.php +++ b/apps/files_sharing/lib/Listener/LoadSidebarListener.php @@ -23,6 +23,7 @@ declare(strict_types=1); * along with this program. If not, see <http://www.gnu.org/licenses/>. * */ + namespace OCA\Files_Sharing\Listener; use OCA\Files_Sharing\AppInfo\Application; @@ -30,13 +31,31 @@ use OCA\Files\Event\LoadSidebar; use OCP\EventDispatcher\Event; use OCP\EventDispatcher\IEventListener; use OCP\Util; +use OCP\AppFramework\Services\IInitialState; +use OCP\Share\IManager; + +/** + * @template-implements IEventListener<Event> + */ +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 a83ef503048..b89574a2fca 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 e3cd6ad8d46..39062d64846 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 edb0e31e379..89bdd2d528c 100644 --- a/apps/files_sharing/src/views/SharingDetailsTab.vue +++ b/apps/files_sharing/src/views/SharingDetailsTab.vue @@ -448,7 +448,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 } |