From 1f026ef8870dd29fa7d0a973524b6e0eb5d5146d Mon Sep 17 00:00:00 2001 From: Mauro Mura Date: Wed, 18 Dec 2024 15:22:28 +0100 Subject: [PATCH 01/28] initial commit --- l10n/de.js | 13 +- l10n/de.json | 5 + l10n/de_DE.json | 5 + l10n/en.json | 5 + l10n/en_GB.js | 13 +- l10n/en_GB.json | 5 + .../BeforeTemplateRenderedListener.php | 3 +- src/action.ts | 8 +- src/actions/sharingPopupAction.js | 57 +++ src/actions/sharingStatusAction.js | 9 +- src/components/AddLinkButton.vue | 9 +- src/components/SharingEntryLink.vue | 12 - .../SharingEntryQuickShareSelect.vue | 27 +- src/components/SharingInput.vue | 63 ++- src/files_sharing_popup.js | 70 +++ src/files_sharing_tab.js | 70 ++- src/mixins/ShareDetails.js | 11 + src/views/SharingDetailsTab.vue | 97 ++-- src/views/SharingLinkList.vue | 84 ++-- src/views/SharingLinkListPopup.vue | 174 +++++++ src/views/SharingList.vue | 19 +- src/views/SharingPopup.vue | 432 ++++++++++++++++++ src/views/SharingTab.vue | 31 +- webpack.config.cjs | 3 +- 24 files changed, 1049 insertions(+), 176 deletions(-) create mode 100644 src/actions/sharingPopupAction.js create mode 100755 src/files_sharing_popup.js create mode 100755 src/views/SharingLinkListPopup.vue create mode 100644 src/views/SharingPopup.vue diff --git a/l10n/de.js b/l10n/de.js index 5c77b3c..a03bff4 100644 --- a/l10n/de.js +++ b/l10n/de.js @@ -1,20 +1,25 @@ OC.L10N.register( 'nmcsharing', { - Sharing: 'Teilen', + 'Sharing': 'Teilen', 'Add link': 'Link erstellen', + 'Add new link': 'Neuen Link erstellen', 'Read only': 'Nur lesen', 'Can edit': 'Kann bearbeiten', 'File drop': 'Sammelbox', - User: 'Benutzer', - Permissions: 'Berechtigungen', + 'User': 'Benutzer', + 'Permissions': 'Berechtigungen', 'Read, write and upload': 'Kann bearbeiten', 'Read and write': 'Kann bearbeiten', 'File drop (upload only)': 'Sammelbox', 'With File drop, only uploading is allowed. Only you can see files and folders that have been uploaded.': 'Bei der Sammelbox ist nur das Hochladen erlaubt. Nur Sie sehen Dateien und Ordner die hochgeladen worden sind.', - Advanced: 'Erweiterte', + 'Advanced': 'Erweiterte', 'Set password': 'Passwortschutz', 'Your shares': 'Ihre Freigaben', + 'Manage Access': 'Zugriff verwalten', + 'Links sent per E-mail': 'Links per E-mail versandt', + 'Links to Copy': 'Links zum Kopieren', + 'Shares': 'Geteilte Inhalte', 'No shares created yet.': 'Noch keine Freigaben erstellt.', 'Advanced permissions': 'Erweiterte Berechtigungen', 'Allow resharing': 'Weiterteilen erlauben', diff --git a/l10n/de.json b/l10n/de.json index 437e986..2406edc 100644 --- a/l10n/de.json +++ b/l10n/de.json @@ -2,6 +2,7 @@ "translations": { "Sharing": "Teilen", "Add link": "Link erstellen", + "Add new link": "Neuen Link erstellen", "Read only": "Nur lesen", "Can edit": "Kann bearbeiten", "File drop": "Sammelbox", @@ -14,6 +15,10 @@ "Advanced": "Erweiterte", "Set password": "Passwortschutz", "Your shares": "Ihre Freigaben", + "Manage Access": "Zugriff verwalten", + "Links sent per E-mail": "Links per E-mail versandt", + "Links to Copy": "Links zum Kopieren", + "Shares": "Geteilte Inhalte", "No shares created yet.": "Noch keine Freigaben erstellt.", "Advanced permissions": "Erweiterte Berechtigungen", "Allow resharing": "Weiterteilen erlauben", diff --git a/l10n/de_DE.json b/l10n/de_DE.json index 437e986..2406edc 100644 --- a/l10n/de_DE.json +++ b/l10n/de_DE.json @@ -2,6 +2,7 @@ "translations": { "Sharing": "Teilen", "Add link": "Link erstellen", + "Add new link": "Neuen Link erstellen", "Read only": "Nur lesen", "Can edit": "Kann bearbeiten", "File drop": "Sammelbox", @@ -14,6 +15,10 @@ "Advanced": "Erweiterte", "Set password": "Passwortschutz", "Your shares": "Ihre Freigaben", + "Manage Access": "Zugriff verwalten", + "Links sent per E-mail": "Links per E-mail versandt", + "Links to Copy": "Links zum Kopieren", + "Shares": "Geteilte Inhalte", "No shares created yet.": "Noch keine Freigaben erstellt.", "Advanced permissions": "Erweiterte Berechtigungen", "Allow resharing": "Weiterteilen erlauben", diff --git a/l10n/en.json b/l10n/en.json index d914374..938c939 100644 --- a/l10n/en.json +++ b/l10n/en.json @@ -2,6 +2,7 @@ "translations": { "Sharing": "Sharing", "Add link": "Add link", + "Add new link": "Add new link", "Read only": "Read only", "Can edit": "Can edit", "File drop": "File drop", @@ -14,6 +15,10 @@ "Advanced": "Advanced", "Set password": "Set password", "Your shares": "Your shares", + "Manage Access": "Manage Access", + "Links sent per E-mail": "Links sent per E-mail", + "Links to Copy": "Links to Copy", + "Shares": "Shares", "No shares created yet.": "No shares created yet.", "Advanced permissions": "Advanced permissions", "Allow resharing": "Allow resharing", diff --git a/l10n/en_GB.js b/l10n/en_GB.js index 21eaf07..361d518 100644 --- a/l10n/en_GB.js +++ b/l10n/en_GB.js @@ -1,20 +1,25 @@ OC.L10N.register( 'nmcsharing', { - Sharing: 'Sharing', + 'Sharing': 'Sharing', 'Add link': 'Add link', + 'Add new link': 'Add new link', 'Read only': 'Read only', 'Can edit': 'Can edit', 'File drop': 'File drop', - User: 'User', - Permissions: 'Permissions', + 'User': 'User', + 'Permissions': 'Permissions', 'Read, write and upload': 'Read, write and upload', 'Read and write': 'Read and write', 'File drop (upload only)': 'File drop (upload only)', 'With File drop, only uploading is allowed. Only you can see files and folders that have been uploaded.': 'With File drop, only uploading is allowed. Only you can see files and folders that have been uploaded.', - Advanced: 'Advanced', + 'Advanced': 'Advanced', 'Set password': 'Set password', 'Your shares': 'Your shares', + 'Manage Access': 'Manage Access', + 'Links sent per E-mail': 'Links sent per E-mail', + 'Links to Copy': 'Links to Copy', + 'Shares': 'Shares', 'No shares created yet.': 'No shares created yet.', 'Advanced permissions': 'Advanced permissions', 'Allow resharing': 'Allow resharing', diff --git a/l10n/en_GB.json b/l10n/en_GB.json index d914374..938c939 100644 --- a/l10n/en_GB.json +++ b/l10n/en_GB.json @@ -2,6 +2,7 @@ "translations": { "Sharing": "Sharing", "Add link": "Add link", + "Add new link": "Add new link", "Read only": "Read only", "Can edit": "Can edit", "File drop": "File drop", @@ -14,6 +15,10 @@ "Advanced": "Advanced", "Set password": "Set password", "Your shares": "Your shares", + "Manage Access": "Manage Access", + "Links sent per E-mail": "Links sent per E-mail", + "Links to Copy": "Links to Copy", + "Shares": "Shares", "No shares created yet.": "No shares created yet.", "Advanced permissions": "Advanced permissions", "Allow resharing": "Allow resharing", diff --git a/lib/Listener/BeforeTemplateRenderedListener.php b/lib/Listener/BeforeTemplateRenderedListener.php index 9c20560..16f6bc3 100644 --- a/lib/Listener/BeforeTemplateRenderedListener.php +++ b/lib/Listener/BeforeTemplateRenderedListener.php @@ -41,7 +41,8 @@ public function handle(Event $event): void { // you can add additional styles, links and scripts before rendering // keep src for future use: \OCP\Util::addScript("nmctheme", "../dist/l10nappender"); - \OCP\Util::addScript("nmcsharing", "nmcsharing-sharing"); + \OCP\Util::addScript("nmcsharing", "nmcsharing-tab"); + // \OCP\Util::addScript("nmcsharing", "nmcsharing-popup"); \OCP\Util::addScript("nmcsharing", "nmcsharing-action"); } } diff --git a/src/action.ts b/src/action.ts index c7d2d1f..6f1c8ca 100644 --- a/src/action.ts +++ b/src/action.ts @@ -1,4 +1,6 @@ -import { registerFileAction } from '@nextcloud/files' -import { action } from './actions/sharingStatusAction' +import { registerFileAction, getFileActions } from '@nextcloud/files' +import { action as statusAtion } from './actions/sharingStatusAction' +import { action as popupAction } from './actions/sharingPopupAction' -registerFileAction(action) +//registerFileAction(statusAtion) +registerFileAction(popupAction) diff --git a/src/actions/sharingPopupAction.js b/src/actions/sharingPopupAction.js new file mode 100644 index 0000000..dc27cb6 --- /dev/null +++ b/src/actions/sharingPopupAction.js @@ -0,0 +1,57 @@ +import { FileAction, Permission } from '@nextcloud/files' +import { translate as t } from '@nextcloud/l10n' + +import { action as sidebarAction } from './sidebarAction.js' + +export const action = new FileAction({ + id: 'sharing-popup-magentacloud', + displayName(nodes) { + /* + const node = nodes[0] + const shareTypes = Object.values(node?.attributes?.['share-types'] || {}).flat() + + if (shareTypes.length > 0) { + return t('files_sharing', 'Shared') + } + */ + return 'Sharing Popup' + }, + + title(nodes) { + const node = nodes[0] + + if (Array.isArray(node.attributes?.['share-types'])) { + return t('files_sharing', 'Shared multiple times with different people') + } + + return t('files_sharing', 'Show sharing options') + }, + + iconSvgInline() { + return '' + }, + + enabled(nodes) { + if (nodes.length !== 1) { + return false + } + + const node = nodes[0] + const isMixed = Array.isArray(node.attributes?.['share-types']) + + if (isMixed) { + return true + } + + return (node.permissions & Permission.SHARE) !== 0 + }, + + async exec(node, view, dir) { + if ((node.permissions & Permission.READ) !== 0) { + OCA.Files.Sidebar.setActiveTab('sharing-popup') + return sidebarAction.exec(node, view, dir) + } + return null + }, + +}) diff --git a/src/actions/sharingStatusAction.js b/src/actions/sharingStatusAction.js index aaf14a5..6630766 100644 --- a/src/actions/sharingStatusAction.js +++ b/src/actions/sharingStatusAction.js @@ -6,14 +6,15 @@ import { action as sidebarAction } from './sidebarAction.js' export const action = new FileAction({ id: 'sharing-status-magentacloud', displayName(nodes) { + /* const node = nodes[0] const shareTypes = Object.values(node?.attributes?.['share-types'] || {}).flat() if (shareTypes.length > 0) { return t('files_sharing', 'Shared') } - - return '' + */ + return 'Sharing Tab' }, title(nodes) { @@ -47,12 +48,10 @@ export const action = new FileAction({ async exec(node, view, dir) { if ((node.permissions & Permission.READ) !== 0) { - window.OCA?.Files?.Sidebar?.setActiveTab?.('sharing') + OCA.Files.Sidebar.setActiveTab('sharing-tab') return sidebarAction.exec(node, view, dir) } return null }, - inline: () => true, - }) diff --git a/src/components/AddLinkButton.vue b/src/components/AddLinkButton.vue index 2e23562..40d8274 100644 --- a/src/components/AddLinkButton.vue +++ b/src/components/AddLinkButton.vue @@ -1,7 +1,7 @@ @@ -68,10 +68,3 @@ export default { }, } - - diff --git a/src/components/SharingEntryLink.vue b/src/components/SharingEntryLink.vue index 798e020..772c8e5 100755 --- a/src/components/SharingEntryLink.vue +++ b/src/components/SharingEntryLink.vue @@ -22,16 +22,6 @@