From 5ac9da1e195687ca348a8662f00a6f70a8b9a9a0 Mon Sep 17 00:00:00 2001 From: Ferdinand Thiessen Date: Tue, 2 Sep 2025 01:40:22 +0200 Subject: [PATCH] feat(files_sharing): provide web-components based sidebar API This fixes apps providing vue components, which is invalid and does not always work - and never work with Vue 3. Signed-off-by: Ferdinand Thiessen --- .../src/components/SharingEntryLink.vue | 32 +++++++-- .../SidebarTabExternalAction.vue | 71 +++++++++++++++++++ .../SidebarTabExternalActionLegacy.vue} | 8 +-- .../SidebarTabExternalSection.vue | 33 +++++++++ .../SidebarTabExternalSectionLegacy.vue | 33 +++++++++ .../src/services/ExternalLinkActions.js | 8 ++- .../src/services/ExternalShareActions.js | 10 ++- .../src/views/SharingDetailsTab.vue | 44 ++++++++++-- apps/files_sharing/src/views/SharingTab.vue | 47 +++++++++--- 9 files changed, 257 insertions(+), 29 deletions(-) create mode 100644 apps/files_sharing/src/components/SidebarTabExternal/SidebarTabExternalAction.vue rename apps/files_sharing/src/components/{ExternalShareAction.vue => SidebarTabExternal/SidebarTabExternalActionLegacy.vue} (82%) create mode 100644 apps/files_sharing/src/components/SidebarTabExternal/SidebarTabExternalSection.vue create mode 100644 apps/files_sharing/src/components/SidebarTabExternal/SidebarTabExternalSectionLegacy.vue diff --git a/apps/files_sharing/src/components/SharingEntryLink.vue b/apps/files_sharing/src/components/SharingEntryLink.vue index 8f2e48f5dea..c41f36dd6d4 100644 --- a/apps/files_sharing/src/components/SharingEntryLink.vue +++ b/apps/files_sharing/src/components/SharingEntryLink.vue @@ -154,7 +154,16 @@ - + + {{ action.label(share, fileInfo.node) }} + + + (action.shareType.includes(ShareType.Link) || action.shareType.includes(ShareType.Email)) && !action.advanced // filter only the registered actions for said link + console.error('external legacy', this.ExternalShareActions, this.ExternalShareActions.actions.filter(filterValidAction)) return this.ExternalShareActions.actions .filter(filterValidAction) }, + /** + * Additional actions for the menu + * + * @return {import('@nextcloud/sharing/ui').ISidebarInlineAction[]} + */ + sortedExternalShareActions() { + return this.externalShareActions + .filter((action) => action.enabled(toRaw(this.share), toRaw(this.fileInfo.node))) + .sort((a, b) => a.order - b.order) + }, + isPasswordPolicyEnabled() { return typeof this.config.passwordPolicy === 'object' }, diff --git a/apps/files_sharing/src/components/SidebarTabExternal/SidebarTabExternalAction.vue b/apps/files_sharing/src/components/SidebarTabExternal/SidebarTabExternalAction.vue new file mode 100644 index 00000000000..ef399d90e4f --- /dev/null +++ b/apps/files_sharing/src/components/SidebarTabExternal/SidebarTabExternalAction.vue @@ -0,0 +1,71 @@ + + + + + diff --git a/apps/files_sharing/src/components/ExternalShareAction.vue b/apps/files_sharing/src/components/SidebarTabExternal/SidebarTabExternalActionLegacy.vue similarity index 82% rename from apps/files_sharing/src/components/ExternalShareAction.vue rename to apps/files_sharing/src/components/SidebarTabExternal/SidebarTabExternalActionLegacy.vue index c2c86cc8679..9a6f05f8385 100644 --- a/apps/files_sharing/src/components/ExternalShareAction.vue +++ b/apps/files_sharing/src/components/SidebarTabExternal/SidebarTabExternalActionLegacy.vue @@ -4,18 +4,18 @@ --> diff --git a/apps/files_sharing/src/components/SidebarTabExternal/SidebarTabExternalSectionLegacy.vue b/apps/files_sharing/src/components/SidebarTabExternal/SidebarTabExternalSectionLegacy.vue new file mode 100644 index 00000000000..2b07673f598 --- /dev/null +++ b/apps/files_sharing/src/components/SidebarTabExternal/SidebarTabExternalSectionLegacy.vue @@ -0,0 +1,33 @@ + + + + + + + diff --git a/apps/files_sharing/src/services/ExternalLinkActions.js b/apps/files_sharing/src/services/ExternalLinkActions.js index fe5130fbb49..caf652a2ec9 100644 --- a/apps/files_sharing/src/services/ExternalLinkActions.js +++ b/apps/files_sharing/src/services/ExternalLinkActions.js @@ -3,6 +3,8 @@ * SPDX-License-Identifier: AGPL-3.0-or-later */ +import logger from './logger.ts' + export default class ExternalLinkActions { _state @@ -13,7 +15,7 @@ export default class ExternalLinkActions { // init default values this._state.actions = [] - console.debug('OCA.Sharing.ExternalLinkActions initialized') + logger.debug('OCA.Sharing.ExternalLinkActions initialized') } /** @@ -35,13 +37,13 @@ export default class ExternalLinkActions { * @return {boolean} */ registerAction(action) { - OC.debug && console.warn('OCA.Sharing.ExternalLinkActions is deprecated, use OCA.Sharing.ExternalShareAction instead') + logger.warn('OCA.Sharing.ExternalLinkActions is deprecated, use `registerSidebarAction` from `@nextcloud/sharing` instead') if (typeof action === 'object' && action.icon && action.name && action.url) { this._state.actions.push(action) return true } - console.error('Invalid action provided', action) + logger.error('Invalid action provided', action) return false } diff --git a/apps/files_sharing/src/services/ExternalShareActions.js b/apps/files_sharing/src/services/ExternalShareActions.js index 6ffd7014fe2..3d287121bb7 100644 --- a/apps/files_sharing/src/services/ExternalShareActions.js +++ b/apps/files_sharing/src/services/ExternalShareActions.js @@ -3,6 +3,8 @@ * SPDX-License-Identifier: AGPL-3.0-or-later */ +import logger from './logger.ts' + export default class ExternalShareActions { _state @@ -13,7 +15,7 @@ export default class ExternalShareActions { // init default values this._state.actions = [] - console.debug('OCA.Sharing.ExternalShareActions initialized') + logger.debug('OCA.Sharing.ExternalShareActions initialized') } /** @@ -44,6 +46,8 @@ export default class ExternalShareActions { * @return {boolean} */ registerAction(action) { + logger.warn('OCA.Sharing.ExternalShareActions is deprecated, use `registerSidebarAction` from `@nextcloud/sharing` instead') + // Validate action if (typeof action !== 'object' || typeof action.id !== 'string' @@ -51,14 +55,14 @@ export default class ExternalShareActions { || !Array.isArray(action.shareType) // [\@nextcloud/sharing.Types.Link, ...] || typeof action.handlers !== 'object' // {click: () => {}, ...} || !Object.values(action.handlers).every(handler => typeof handler === 'function')) { - console.error('Invalid action provided', action) + logger.error('Invalid action provided', action) return false } // Check duplicates const hasDuplicate = this._state.actions.findIndex(check => check.id === action.id) > -1 if (hasDuplicate) { - console.error(`An action with the same id ${action.id} already exists`, action) + logger.error(`An action with the same id ${action.id} already exists`, action) return false } diff --git a/apps/files_sharing/src/views/SharingDetailsTab.vue b/apps/files_sharing/src/views/SharingDetailsTab.vue index c9f3d1edf74..669c5fcf439 100644 --- a/apps/files_sharing/src/views/SharingDetailsTab.vue +++ b/apps/files_sharing/src/views/SharingDetailsTab.vue @@ -187,13 +187,21 @@ :checked.sync="showInGridView"> {{ t('files_sharing', 'Show files in grid view') }} - + + {{ t('files_sharing', 'Custom permissions') }} @@ -264,11 +272,13 @@