diff --git a/packages/web-client/src/helpers/share/functions.ts b/packages/web-client/src/helpers/share/functions.ts index c3d31a4920e..ae30205803e 100644 --- a/packages/web-client/src/helpers/share/functions.ts +++ b/packages/web-client/src/helpers/share/functions.ts @@ -174,7 +174,7 @@ export function buildSharedResource( ] resource.sharedWith = share.sharedWith || [] resource.status = parseInt(share.state) - resource.hidden = share.hide === 'true' || share.hide === true + resource.hidden = share.hidden === 'true' || share.hidden === true resource.name = path.basename(share.file_target) if (hasShareJail) { // FIXME, HACK 1: path needs to be '/' because the share has it's own webdav endpoint (we access it's root). should ideally be removed backend side. diff --git a/packages/web-pkg/src/composables/actions/files/useFileActionsAcceptShare.ts b/packages/web-pkg/src/composables/actions/files/useFileActionsAcceptShare.ts index 341efb3d849..197f5e055c0 100644 --- a/packages/web-pkg/src/composables/actions/files/useFileActionsAcceptShare.ts +++ b/packages/web-pkg/src/composables/actions/files/useFileActionsAcceptShare.ts @@ -36,7 +36,6 @@ export const useFileActionsAcceptShare = ({ store }: { store?: Store } = {} const share = await triggerShareAction({ resource, status: ShareStatus.accepted, - // Set hidden false here? hasResharing: unref(hasResharing), hasShareJail: unref(hasShareJail), client: clientService.owncloudSdk, diff --git a/packages/web-pkg/src/composables/actions/files/useFileActionsDeclineShare.ts b/packages/web-pkg/src/composables/actions/files/useFileActionsDeclineShare.ts index 4e7ca3d290f..d7da492c7d7 100644 --- a/packages/web-pkg/src/composables/actions/files/useFileActionsDeclineShare.ts +++ b/packages/web-pkg/src/composables/actions/files/useFileActionsDeclineShare.ts @@ -39,7 +39,6 @@ export const useFileActionsDeclineShare = ({ store }: { store?: Store } = { const share = await triggerShareAction({ resource, status: ShareStatus.declined, - // TODO: Hidden implications here? hasResharing: unref(hasResharing), hasShareJail: unref(hasShareJail), client: clientService.owncloudSdk, diff --git a/packages/web-pkg/src/composables/actions/files/useFileActionsToggleHideShare.ts b/packages/web-pkg/src/composables/actions/files/useFileActionsToggleHideShare.ts index 6563c1f4179..8abb0d0d463 100644 --- a/packages/web-pkg/src/composables/actions/files/useFileActionsToggleHideShare.ts +++ b/packages/web-pkg/src/composables/actions/files/useFileActionsToggleHideShare.ts @@ -12,7 +12,6 @@ import { useStore } from '../../store' import { computed, unref } from 'vue' import { useGettext } from 'vue3-gettext' import { FileAction, FileActionOptions } from '../../actions' -import { Resource } from '@ownclouders/web-client' export const useFileActionsToggleHideShare = ({ store }: { store?: Store } = {}) => { store = store || useStore() @@ -25,13 +24,11 @@ export const useFileActionsToggleHideShare = ({ store }: { store?: Store } const loadingService = useLoadingService() const configurationManager = useConfigurationManager() - const highlightedFile = computed(() => store.getters['Files/highlightedFile']) - const handler = async ({ resources }: FileActionOptions) => { const errors = [] const triggerPromises = [] const triggerQueue = new PQueue({ concurrency: 4 }) - const hide = !resources[0].hidden + const hidden = !resources[0].hidden resources.forEach((resource) => { triggerPromises.push( @@ -40,7 +37,7 @@ export const useFileActionsToggleHideShare = ({ store }: { store?: Store } const share = await triggerShareAction({ resource, status: resource.status, - hide, + hidden, hasResharing: unref(hasResharing), hasShareJail: unref(hasShareJail), client: clientService.owncloudSdk, @@ -63,7 +60,7 @@ export const useFileActionsToggleHideShare = ({ store }: { store?: Store } if (errors.length === 0) { store.dispatch('Files/resetFileSelection') store.dispatch('showMessage', { - title: hide + title: hidden ? $gettext('The share was hidden successfully') : $gettext('The share was unhidden successfully') }) @@ -72,7 +69,9 @@ export const useFileActionsToggleHideShare = ({ store }: { store?: Store } } store.dispatch('showErrorMessage', { - title: hide ? $gettext('Failed to hide the share') : $gettext('Failed to unhide share share'), + title: hidden + ? $gettext('Failed to hide the share') + : $gettext('Failed to unhide share share'), errors }) } diff --git a/packages/web-pkg/src/helpers/share/triggerShareAction.ts b/packages/web-pkg/src/helpers/share/triggerShareAction.ts index d6337fb16a4..b397c30f465 100644 --- a/packages/web-pkg/src/helpers/share/triggerShareAction.ts +++ b/packages/web-pkg/src/helpers/share/triggerShareAction.ts @@ -6,23 +6,23 @@ import { OwnCloudSdk } from '@ownclouders/web-client/src/types' export async function triggerShareAction({ resource, status, - hide = false, hasResharing, hasShareJail, client, + hidden = undefined, spaces = [], fullShareOwnerPaths = false }: { resource: Resource status: ShareStatus - hide?: boolean hasResharing: boolean hasShareJail: boolean client: OwnCloudSdk + hidden?: boolean spaces?: SpaceResource[] fullShareOwnerPaths?: boolean }) { - const method = _getRequestMethod(status) + const method = _getRequestMethod(status, hidden) if (!method) { throw new Error('invalid new share status') } @@ -30,7 +30,7 @@ export async function triggerShareAction({ // exec share action let response = await client.requests.ocs({ service: 'apps/files_sharing', - action: `api/v1/shares/pending/${resource.share.id}?hide=${hide ? 'true' : 'false'}`, + action: `api/v1/shares/pending/${resource.share.id}?hidden=${hidden ? 'true' : 'false'}`, method }) @@ -58,7 +58,11 @@ export async function triggerShareAction({ return null } -function _getRequestMethod(status) { +function _getRequestMethod(status: ShareStatus, hidden: boolean) { + if (hidden !== undefined) { + // setting the hidden state is always done via PUT + return 'PUT' + } switch (status) { case ShareStatus.accepted: return 'POST'