From 1260c8552a8ac37df6ba3df7f5165e5a40401119 Mon Sep 17 00:00:00 2001 From: Christopher Ng Date: Wed, 28 Feb 2024 18:59:05 -0800 Subject: [PATCH 1/2] feat: Allow registration of advanced external share actions Signed-off-by: Christopher Ng --- .../src/components/SharingEntryLink.vue | 4 +-- .../src/services/ExternalShareActions.js | 8 ++++- .../src/views/SharingDetailsTab.vue | 34 +++++++++++++++++++ 3 files changed, 43 insertions(+), 3 deletions(-) diff --git a/apps/files_sharing/src/components/SharingEntryLink.vue b/apps/files_sharing/src/components/SharingEntryLink.vue index bf9e0203f9efb..041a9b16ad68d 100644 --- a/apps/files_sharing/src/components/SharingEntryLink.vue +++ b/apps/files_sharing/src/components/SharingEntryLink.vue @@ -525,10 +525,10 @@ export default { * @return {Array} */ externalLinkActions() { + const filterValidAction = (action) => (action.shareType.includes(ShareTypes.SHARE_TYPE_LINK) || action.shareType.includes(ShareTypes.SHARE_TYPE_EMAIL)) && !action.advanced // filter only the registered actions for said link return this.ExternalShareActions.actions - .filter(action => action.shareType.includes(ShareTypes.SHARE_TYPE_LINK) - || action.shareType.includes(ShareTypes.SHARE_TYPE_EMAIL)) + .filter(filterValidAction) }, isPasswordPolicyEnabled() { diff --git a/apps/files_sharing/src/services/ExternalShareActions.js b/apps/files_sharing/src/services/ExternalShareActions.js index 6167346699e0d..89a46e7e692fc 100644 --- a/apps/files_sharing/src/services/ExternalShareActions.js +++ b/apps/files_sharing/src/services/ExternalShareActions.js @@ -44,13 +44,19 @@ export default class ExternalShareActions { return this._state } + /** + * @typedef ExternalShareActionData + * @property {import('vue').Component} is Vue component to render, for advanced actions the `async onSave` method of the component will be called when saved + */ + /** * Register a new option/entry for the a given share type * * @param {object} action new action component to register * @param {string} action.id unique action id - * @param {Function} action.data data to bind the component to + * @param {(data: any) => ExternalShareActionData & Record} action.data data to bind the component to * @param {Array} action.shareType list of \@nextcloud/sharing.Types.SHARE_XXX to be mounted on + * @param {boolean} action.advanced `true` if the action entry should be rendered within advanced settings * @param {object} action.handlers list of listeners * @return {boolean} */ diff --git a/apps/files_sharing/src/views/SharingDetailsTab.vue b/apps/files_sharing/src/views/SharingDetailsTab.vue index 83e3dc3706fc7..b7d87a88b0e26 100644 --- a/apps/files_sharing/src/views/SharingDetailsTab.vue +++ b/apps/files_sharing/src/views/SharingDetailsTab.vue @@ -164,6 +164,13 @@