From effdfa9149afdfcae39fb3e9a91870253b8146d8 Mon Sep 17 00:00:00 2001 From: Ferdinand Thiessen Date: Fri, 28 Jun 2024 17:13:30 +0200 Subject: [PATCH] fix(files_sharing): Bring back "custom disclaimer" feature for public file drops Signed-off-by: Ferdinand Thiessen --- .../DefaultPublicShareTemplateProvider.php | 3 ++ .../src/files_views/publicFileDrop.ts | 35 +++++++++++--- .../views/FilesViewFileDropEmptyContent.vue | 46 +++++++++++++++++++ 3 files changed, 77 insertions(+), 7 deletions(-) create mode 100644 apps/files_sharing/src/views/FilesViewFileDropEmptyContent.vue diff --git a/apps/files_sharing/lib/DefaultPublicShareTemplateProvider.php b/apps/files_sharing/lib/DefaultPublicShareTemplateProvider.php index e16c40ab548c1..30255716dbe6b 100644 --- a/apps/files_sharing/lib/DefaultPublicShareTemplateProvider.php +++ b/apps/files_sharing/lib/DefaultPublicShareTemplateProvider.php @@ -75,10 +75,13 @@ public function renderPage(IShare $share, string $token, string $path): Template } else if (($share->getPermissions() & \OCP\Constants::PERMISSION_CREATE) && !($share->getPermissions() & \OCP\Constants::PERMISSION_READ)) { // share is a folder with create but no read permissions -> file drop only $view = 'public-file-drop'; + // Only needed for file drops + $this->initialState->provideInitialState('disclaimer', $this->config->getAppValue('core', 'shareapi_public_link_disclaimertext', '')); } // Set up initial state $this->initialState->provideInitialState('isPublic', true); $this->initialState->provideInitialState('sharingToken', $token); + $this->initialState->provideInitialState('filename', $shareNode->getName()); $this->initialState->provideInitialState('view', $view); // Load scripts and styles for UI diff --git a/apps/files_sharing/src/files_views/publicFileDrop.ts b/apps/files_sharing/src/files_views/publicFileDrop.ts index c6bdbe6960df7..0d782d48fc794 100644 --- a/apps/files_sharing/src/files_views/publicFileDrop.ts +++ b/apps/files_sharing/src/files_views/publicFileDrop.ts @@ -2,22 +2,43 @@ * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors * SPDX-License-Identifier: AGPL-3.0-or-later */ +import type { VueConstructor } from 'vue' + import { Folder, Permission, View, davRemoteURL, davRootPath, getNavigation } from '@nextcloud/files' +import { loadState } from '@nextcloud/initial-state' import { translate as t } from '@nextcloud/l10n' -import LinkSvg from '@mdi/svg/svg/link.svg?raw' +import svgCloudUpload from '@mdi/svg/svg/cloud-upload.svg?raw' +import Vue from 'vue' export default () => { + const foldername = loadState('files_sharing', 'filename') + + let FilesViewFileDropEmptyContent: VueConstructor + let fileDropEmptyContentInstance: Vue + const view = new View({ id: 'public-file-drop', name: t('files_sharing', 'File drop'), - caption: t('files_sharing', 'Upload your files to share.'), - - emptyTitle: t('files_sharing', 'File drop'), - emptyCaption: t('files_sharing', 'You can upload your files to share'), - - icon: LinkSvg, + caption: t('files_sharing', 'Upload files to {foldername}', { foldername }), + icon: svgCloudUpload, order: 1, + emptyView: async (div: HTMLDivElement) => { + if (FilesViewFileDropEmptyContent === undefined) { + const { default: component } = await import('../views/FilesViewFileDropEmptyContent.vue') + FilesViewFileDropEmptyContent = Vue.extend(component) + } + if (fileDropEmptyContentInstance) { + fileDropEmptyContentInstance.$destroy() + } + fileDropEmptyContentInstance = new FilesViewFileDropEmptyContent({ + propsData: { + foldername, + }, + }) + fileDropEmptyContentInstance.$mount(div) + }, + getContents: async () => { return { contents: [], diff --git a/apps/files_sharing/src/views/FilesViewFileDropEmptyContent.vue b/apps/files_sharing/src/views/FilesViewFileDropEmptyContent.vue new file mode 100644 index 0000000000000..8d703c39f41a0 --- /dev/null +++ b/apps/files_sharing/src/views/FilesViewFileDropEmptyContent.vue @@ -0,0 +1,46 @@ + + + + +