From 192158d17ebef97e24759aa46974995afd2093c3 Mon Sep 17 00:00:00 2001 From: Pascal Wengerter Date: Wed, 27 Sep 2023 22:08:06 +0200 Subject: [PATCH 01/13] Next iteration of share show/hide --- .../components/Shares/SharedWithMeSection.vue | 54 +++--- .../src/services/folder/loaderSharedWithMe.ts | 3 +- .../src/views/shares/SharedWithMe.vue | 157 ++++++++---------- .../web-client/src/helpers/resource/types.ts | 1 + .../web-client/src/helpers/share/functions.ts | 1 + .../src/composables/actions/files/index.ts | 1 + .../actions/files/useFileActions.ts | 5 + .../files/useFileActionsAcceptShare.ts | 1 + .../files/useFileActionsDeclineShare.ts | 1 + .../actions/files/useFileActionsHideShare.ts | 126 ++++++++++++++ .../src/helpers/share/triggerShareAction.ts | 6 +- 11 files changed, 242 insertions(+), 114 deletions(-) create mode 100644 packages/web-pkg/src/composables/actions/files/useFileActionsHideShare.ts diff --git a/packages/web-app-files/src/components/Shares/SharedWithMeSection.vue b/packages/web-app-files/src/components/Shares/SharedWithMeSection.vue index 6e643e2c5c0..88bcf19b9a0 100644 --- a/packages/web-app-files/src/components/Shares/SharedWithMeSection.vue +++ b/packages/web-app-files/src/components/Shares/SharedWithMeSection.vue @@ -1,6 +1,6 @@ + diff --git a/packages/web-client/src/helpers/resource/types.ts b/packages/web-client/src/helpers/resource/types.ts index 54b77b950fb..6b49e91f477 100644 --- a/packages/web-client/src/helpers/resource/types.ts +++ b/packages/web-client/src/helpers/resource/types.ts @@ -115,6 +115,7 @@ export interface Resource { sharedWith?: string shareOwner?: string shareOwnerDisplayname?: string + hide?: string extension?: string share?: any diff --git a/packages/web-client/src/helpers/share/functions.ts b/packages/web-client/src/helpers/share/functions.ts index ff31dfba668..7b6476347ab 100644 --- a/packages/web-client/src/helpers/share/functions.ts +++ b/packages/web-client/src/helpers/share/functions.ts @@ -174,6 +174,7 @@ export function buildSharedResource( ] resource.sharedWith = share.sharedWith || [] resource.status = parseInt(share.state) + resource.hide = share.hide || 'false' 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/index.ts b/packages/web-pkg/src/composables/actions/files/index.ts index fe428e68736..f3d0a4c9fbc 100644 --- a/packages/web-pkg/src/composables/actions/files/index.ts +++ b/packages/web-pkg/src/composables/actions/files/index.ts @@ -1,6 +1,7 @@ export * from './useFileActions' export * from './useFileActionsSetReadme' export * from './useFileActionsAcceptShare' +export * from './useFileActionsHideShare' export * from './useFileActionsCopy' export * from './useFileActionsCreateQuicklink' export * from './useFileActionsDeclineShare' diff --git a/packages/web-pkg/src/composables/actions/files/useFileActions.ts b/packages/web-pkg/src/composables/actions/files/useFileActions.ts index b7d770c953b..cf6fcb8f9c2 100644 --- a/packages/web-pkg/src/composables/actions/files/useFileActions.ts +++ b/packages/web-pkg/src/composables/actions/files/useFileActions.ts @@ -20,6 +20,7 @@ import { import { useFileActionsAcceptShare, + useFileActionsHideShare, useFileActionsCopy, useFileActionsDeclineShare, useFileActionsDelete, @@ -54,6 +55,7 @@ export const useFileActions = ({ store }: { store?: Store } = {}) => { const { openUrl } = useWindowOpen() const { actions: acceptShareActions } = useFileActionsAcceptShare({ store }) + const { actions: hideShareActions } = useFileActionsHideShare({ store }) const { actions: copyActions } = useFileActionsCopy({ store }) const { actions: deleteActions } = useFileActionsDelete({ store }) const { actions: declineShareActions } = useFileActionsDeclineShare({ store }) @@ -78,6 +80,7 @@ export const useFileActions = ({ store }: { store?: Store } = {}) => { ...unref(showEditTagsActions), ...unref(restoreActions), ...unref(acceptShareActions), + ...unref(hideShareActions), ...unref(declineShareActions), ...unref(favoriteActions), ...unref(navigateActions) @@ -211,6 +214,8 @@ export const useFileActions = ({ store }: { store?: Store } = {}) => { } const triggerAction = (name: string, options: FileActionOptions) => { + console.log(getAllAvailableActions(options)) + const action = getAllAvailableActions(options).filter((action) => action.name === name)[0] if (!action) { throw new Error(`Action not found: '${name}'`) diff --git a/packages/web-pkg/src/composables/actions/files/useFileActionsAcceptShare.ts b/packages/web-pkg/src/composables/actions/files/useFileActionsAcceptShare.ts index d856e979825..7a83fb8ae72 100644 --- a/packages/web-pkg/src/composables/actions/files/useFileActionsAcceptShare.ts +++ b/packages/web-pkg/src/composables/actions/files/useFileActionsAcceptShare.ts @@ -36,6 +36,7 @@ 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 1bdc7b87ba7..625b8c7ccfd 100644 --- a/packages/web-pkg/src/composables/actions/files/useFileActionsDeclineShare.ts +++ b/packages/web-pkg/src/composables/actions/files/useFileActionsDeclineShare.ts @@ -39,6 +39,7 @@ 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/useFileActionsHideShare.ts b/packages/web-pkg/src/composables/actions/files/useFileActionsHideShare.ts new file mode 100644 index 00000000000..a5f85aa878e --- /dev/null +++ b/packages/web-pkg/src/composables/actions/files/useFileActionsHideShare.ts @@ -0,0 +1,126 @@ +import { triggerShareAction } from '../../../helpers/share/triggerShareAction' + +import { Store } from 'vuex' +import PQueue from 'p-queue' +import { ShareStatus } from 'web-client/src/helpers/share' +import { isLocationSharesActive, isLocationSpacesActive } from '../../../router' +import { + useCapabilityFilesSharingResharing, + useCapabilityShareJailEnabled, + useClientService, + useConfigurationManager, + useLoadingService, + useRouter, + useStore +} from 'web-pkg/src/composables' +import { computed, unref } from 'vue' +import { useGettext } from 'vue3-gettext' +import { FileAction, FileActionOptions } from 'web-pkg/src/composables/actions/types' + +// TODO: Replace all "accept" copy leftovers +export const useFileActionsHideShare = ({ store }: { store?: Store } = {}) => { + store = store || useStore() + const router = useRouter() + const { $ngettext } = useGettext() + + const hasResharing = useCapabilityFilesSharingResharing() + const hasShareJail = useCapabilityShareJailEnabled() + const clientService = useClientService() + const loadingService = useLoadingService() + const configurationManager = useConfigurationManager() + + const handler = async ({ resources }: FileActionOptions) => { + const errors = [] + const triggerPromises = [] + const triggerQueue = new PQueue({ concurrency: 4 }) + resources.forEach((resource) => { + triggerPromises.push( + triggerQueue.add(async () => { + try { + const share = await triggerShareAction({ + resource, + status: ShareStatus.pending, + // visibility: 'public', + hasResharing: unref(hasResharing), + hasShareJail: unref(hasShareJail), + client: clientService.owncloudSdk, + spaces: store.getters['runtime/spaces/spaces'], + fullShareOwnerPaths: configurationManager.options.routing.fullShareOwnerPaths + }) + if (share) { + store.commit('Files/UPDATE_RESOURCE', share) + } + } catch (error) { + console.error(error) + errors.push(error) + } + }) + ) + }) + await Promise.all(triggerPromises) + console.log(errors) + if (errors.length === 0) { + store.dispatch('Files/resetFileSelection') + + if (isLocationSpacesActive(router, 'files-spaces-generic')) { + store.dispatch('showMessage', { + title: $ngettext( + 'The selected share was accepted successfully', + 'The selected shares were accepted successfully', + resources.length + ) + }) + } + + return + } + + store.dispatch('showErrorMessage', { + title: $ngettext( + 'Failed to accept the selected share.', + 'Failed to accept selected shares.', + resources.length + ), + errors + }) + } + + const actions = computed((): FileAction[] => [ + { + name: 'hide-share', + icon: 'check', + handler: (args) => loadingService.addTask(() => handler(args)), + label: ({ resources }) => $ngettext('Accept share', 'Accept shares', resources.length), + isEnabled: ({ space, resources }) => { + if ( + !isLocationSharesActive(router, 'files-shares-with-me') && + !isLocationSpacesActive(router, 'files-spaces-generic') + ) { + return false + } + if (resources.length === 0) { + return false + } + + if ( + isLocationSpacesActive(router, 'files-spaces-generic') && + (unref(space)?.driveType !== 'share' || resources.length > 1 || resources[0].path !== '/') + ) { + return false + } + + return true + // const acceptDisabled = resources.some((resource) => { + // return resource.status === ShareStatus.accepted + // }) + // return !acceptDisabled + }, + componentType: 'button', + class: 'oc-files-actions-hide-share-trigger' + } + ]) + + return { + actions + } +} diff --git a/packages/web-pkg/src/helpers/share/triggerShareAction.ts b/packages/web-pkg/src/helpers/share/triggerShareAction.ts index fb4639c37e8..706fbac89ca 100644 --- a/packages/web-pkg/src/helpers/share/triggerShareAction.ts +++ b/packages/web-pkg/src/helpers/share/triggerShareAction.ts @@ -6,6 +6,7 @@ import { OwnCloudSdk } from '@ownclouders/web-client/src/types' export async function triggerShareAction({ resource, status, + hide = 'false', hasResharing, hasShareJail, client, @@ -14,6 +15,7 @@ export async function triggerShareAction({ }: { resource: Resource status: ShareStatus + hide?: 'false' | 'true' hasResharing: boolean hasShareJail: boolean client: OwnCloudSdk @@ -28,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}`, + action: `api/v1/shares/pending/${resource.share.id}?hide=${hide}`, method }) @@ -62,6 +64,8 @@ function _getRequestMethod(status) { return 'POST' case ShareStatus.declined: return 'DELETE' + case ShareStatus.pending: + return 'POST' default: return null } From 9ca4d4d377c25b972b53f76226517a96ed9c0180 Mon Sep 17 00:00:00 2001 From: Pascal Wengerter Date: Thu, 5 Oct 2023 21:28:56 +0200 Subject: [PATCH 02/13] Rebase and add changelog item --- .../unreleased/enhancement-show-hide-shares | 9 +++++++++ .../components/Shares/SharedWithMeSection.vue | 2 +- .../src/views/shares/SharedWithMe.vue | 4 ++-- .../actions/files/useFileActionsHideShare.ts | 19 ++++++++----------- packages/web-runtime/package.json | 2 +- 5 files changed, 21 insertions(+), 15 deletions(-) create mode 100644 changelog/unreleased/enhancement-show-hide-shares diff --git a/changelog/unreleased/enhancement-show-hide-shares b/changelog/unreleased/enhancement-show-hide-shares new file mode 100644 index 00000000000..2e18942ba07 --- /dev/null +++ b/changelog/unreleased/enhancement-show-hide-shares @@ -0,0 +1,9 @@ +Enhancement: Personal shares can be shown and hidden + +On the shared-with-me page, there is no distinction between pending, accepted and rejected shares anymore. +Instead, the user can toggle to display either shown or hidden shares. + +Furthermore, accepting and rejecting shares has been renamed to "enable sync"/"disable sync" to better reflect what's happening on the server and on other devices. + +https://github.com/owncloud/web/issues/9531 +https://github.com/owncloud/web/pull/9718 diff --git a/packages/web-app-files/src/components/Shares/SharedWithMeSection.vue b/packages/web-app-files/src/components/Shares/SharedWithMeSection.vue index 88bcf19b9a0..4cdeca44be5 100644 --- a/packages/web-app-files/src/components/Shares/SharedWithMeSection.vue +++ b/packages/web-app-files/src/components/Shares/SharedWithMeSection.vue @@ -59,7 +59,7 @@ @click.stop="triggerAction('accept-share', { space: null, resources: [resource] })" > - Accept + Enable sync } = {}) => { diff --git a/packages/web-runtime/package.json b/packages/web-runtime/package.json index 16bdb63be9e..e1d31ca13a7 100644 --- a/packages/web-runtime/package.json +++ b/packages/web-runtime/package.json @@ -26,7 +26,7 @@ "luxon": "^2.4.0", "marked": "^4.0.12", "oidc-client-ts": "^2.1.0", - "owncloud-sdk": "3.1.0-alpha.9", + "owncloud-sdk": "file:./../../../owncloud-sdk", "p-queue": "^6.6.2", "pinia": "^2.1.3", "portal-vue": "3.0.0", From 78959f1559ab4dfe839818657327444a579f62cd Mon Sep 17 00:00:00 2001 From: Jannik Stehle Date: Wed, 18 Oct 2023 17:36:05 +0200 Subject: [PATCH 03/13] put remaining parts together to make it work --- .../src/components/OcButton/OcButton.vue | 1 - .../components/Shares/SharedWithMeSection.vue | 53 ++++--- .../src/views/shares/SharedWithMe.vue | 130 +++++++----------- .../unit/views/shares/SharedWithMe.spec.ts | 65 +++------ .../web-client/src/helpers/resource/types.ts | 2 +- .../web-client/src/helpers/share/functions.ts | 2 +- .../web-pkg/src/components/AppBar/AppBar.vue | 11 +- .../components/FilesList/ContextActions.vue | 8 +- .../components/Filters/ItemFilterInline.vue | 107 ++++++++++++++ .../web-pkg/src/components/Filters/index.ts | 2 + .../web-pkg/src/components/Filters/types.ts | 4 + packages/web-pkg/src/components/index.ts | 1 + .../src/composables/actions/files/index.ts | 6 +- .../actions/files/useFileActions.ts | 14 +- ...eptShare.ts => useFileActionsSyncShare.ts} | 18 +-- ...re.ts => useFileActionsToggleHideShare.ts} | 68 ++++----- ...eShare.ts => useFileActionsUnsyncShare.ts} | 20 ++- .../src/helpers/share/triggerShareAction.ts | 6 +- .../FilesList/ContextActions.spec.ts | 4 +- .../Filters/ItemFilterInline.spec.ts | 70 ++++++++++ ...pec.ts => useFileActionsSyncShare.spec.ts} | 6 +- .../helpers/share/triggerShareAction.spec.ts | 2 +- pnpm-lock.yaml | 51 +++---- .../FilesPageElement/fileActionsMenu.js | 4 +- .../pageObjects/sharedWithMePage.js | 2 +- .../objects/app-files/share/actions.ts | 2 +- 26 files changed, 383 insertions(+), 276 deletions(-) create mode 100644 packages/web-pkg/src/components/Filters/ItemFilterInline.vue create mode 100644 packages/web-pkg/src/components/Filters/index.ts create mode 100644 packages/web-pkg/src/components/Filters/types.ts rename packages/web-pkg/src/composables/actions/files/{useFileActionsAcceptShare.ts => useFileActionsSyncShare.ts} (87%) rename packages/web-pkg/src/composables/actions/files/{useFileActionsHideShare.ts => useFileActionsToggleHideShare.ts} (58%) rename packages/web-pkg/src/composables/actions/files/{useFileActionsDeclineShare.ts => useFileActionsUnsyncShare.ts} (86%) create mode 100644 packages/web-pkg/tests/unit/components/Filters/ItemFilterInline.spec.ts rename packages/web-pkg/tests/unit/composables/actions/files/{useFileActionsAcceptShare.spec.ts => useFileActionsSyncShare.spec.ts} (90%) diff --git a/packages/design-system/src/components/OcButton/OcButton.vue b/packages/design-system/src/components/OcButton/OcButton.vue index 99fd847e290..d51668ae0da 100644 --- a/packages/design-system/src/components/OcButton/OcButton.vue +++ b/packages/design-system/src/components/OcButton/OcButton.vue @@ -221,7 +221,6 @@ export default defineComponent({ &-raw-inverse { background-color: transparent; border-style: none; - font-size: var(--oc-font-size-medium); font-weight: normal; min-height: 0; padding: 0; diff --git a/packages/web-app-files/src/components/Shares/SharedWithMeSection.vue b/packages/web-app-files/src/components/Shares/SharedWithMeSection.vue index 4cdeca44be5..ccebeca1b1a 100644 --- a/packages/web-app-files/src/components/Shares/SharedWithMeSection.vue +++ b/packages/web-app-files/src/components/Shares/SharedWithMeSection.vue @@ -39,7 +39,11 @@ :key="resource.getDomSelector() + resource.status" class="oc-text-nowrap oc-flex oc-flex-middle oc-flex-right" > - + diff --git a/packages/web-app-files/tests/unit/views/shares/SharedWithMe.spec.ts b/packages/web-app-files/tests/unit/views/shares/SharedWithMe.spec.ts index 18fc146fa40..5493bcb37b2 100644 --- a/packages/web-app-files/tests/unit/views/shares/SharedWithMe.spec.ts +++ b/packages/web-app-files/tests/unit/views/shares/SharedWithMe.spec.ts @@ -1,13 +1,11 @@ import SharedWithMe from '../../../../src/views/shares/SharedWithMe.vue' import { useResourcesViewDefaults } from 'web-app-files/src/composables' -import { useSort } from '@ownclouders/web-pkg' +import { InlineFilterOption, useSort } from '@ownclouders/web-pkg' import { useResourcesViewDefaultsMock } from 'web-app-files/tests/mocks/useResourcesViewDefaultsMock' -import { ShareStatus } from '@ownclouders/web-client/src/helpers/share' import { ref } from 'vue' import { defaultStubs, RouteLocation } from 'web-test-helpers' import { useSortMock } from 'web-app-files/tests/mocks/useSortMock' -import { mock, mockDeep } from 'jest-mock-extended' -import { Resource } from '@ownclouders/web-client' +import { mock } from 'jest-mock-extended' import { createStore, defaultPlugins, @@ -41,48 +39,27 @@ describe('SharedWithMe view', () => { expect(wrapper.find('oc-spinner-stub').exists()).toBeFalsy() }) }) - describe('sections', () => { - it('always shows the "accepted"- and "declined"-sections', () => { + describe('filter', () => { + it('shows the share visibility filter', () => { const { wrapper } = getMountedWrapper() - expect(wrapper.find('#files-shared-with-me-accepted-section').exists()).toBeTruthy() - expect(wrapper.find('#files-shared-with-me-declined-section').exists()).toBeTruthy() + expect(wrapper.find('.share-visibility-filter').exists()).toBeTruthy() + expect(wrapper.find('item-filter-inline-stub').exists()).toBeTruthy() }) - describe('pending', () => { - it('shows when a share is pending', () => { - const { wrapper } = getMountedWrapper({ - files: [mockDeep({ status: ShareStatus.pending })] - }) - expect(wrapper.find('#files-shared-with-me-pending-section').exists()).toBeTruthy() - }) - it('does not show when no share is pending', () => { - const { wrapper } = getMountedWrapper({ - files: [mockDeep({ status: ShareStatus.accepted })] - }) - expect(wrapper.find('#files-shared-with-me-pending-section').exists()).toBeFalsy() - }) - }) - describe('accepted', () => { - it('shows an accepted share', () => { - const { wrapper } = getMountedWrapper({ - files: [mockDeep({ status: ShareStatus.accepted })] - }) - expect(wrapper.find('#files-shared-with-me-accepted-section').exists()).toBeTruthy() - expect( - wrapper.findComponent('#files-shared-with-me-accepted-section').props().items.length - ).toEqual(1) - }) + it('shows all visible shares', () => { + const { wrapper } = getMountedWrapper() + expect(wrapper.findAll('shared-with-me-section-stub').length).toBe(1) + expect(wrapper.findComponent('shared-with-me-section-stub').props('title')).toEqual( + 'Shares' + ) }) - describe('declined', () => { - it('shows a declined share', async () => { - const { wrapper } = getMountedWrapper({ - files: [mockDeep({ status: ShareStatus.declined })] - }) - await wrapper.vm.loadResourcesTask.last - expect(wrapper.find('#files-shared-with-me-declined-section').exists()).toBeTruthy() - expect( - wrapper.findComponent('#files-shared-with-me-declined-section').props().items.length - ).toEqual(1) - }) + it('shows all hidden shares', async () => { + const { wrapper } = getMountedWrapper() + wrapper.vm.setAreHiddenFilesShown(mock({ name: 'hidden' })) + await wrapper.vm.$nextTick() + expect(wrapper.findAll('shared-with-me-section-stub').length).toBe(1) + expect(wrapper.findComponent('shared-with-me-section-stub').props('title')).toEqual( + 'Hidden Shares' + ) }) }) }) @@ -110,7 +87,7 @@ function getMountedWrapper({ mocks = {}, loading = false, files = [] } = {}) { global: { plugins: [...defaultPlugins(), store], mocks: defaultMocks, - stubs: defaultStubs + stubs: { ...defaultStubs, itemFilterInline: true } } }) } diff --git a/packages/web-client/src/helpers/resource/types.ts b/packages/web-client/src/helpers/resource/types.ts index 6b49e91f477..ad075bf4364 100644 --- a/packages/web-client/src/helpers/resource/types.ts +++ b/packages/web-client/src/helpers/resource/types.ts @@ -115,7 +115,7 @@ export interface Resource { sharedWith?: string shareOwner?: string shareOwnerDisplayname?: string - hide?: string + hidden?: boolean extension?: string share?: any diff --git a/packages/web-client/src/helpers/share/functions.ts b/packages/web-client/src/helpers/share/functions.ts index 7b6476347ab..c3d31a4920e 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.hide = share.hide || 'false' + resource.hidden = share.hide === 'true' || share.hide === 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/components/AppBar/AppBar.vue b/packages/web-pkg/src/components/AppBar/AppBar.vue index d456338351f..84192c08922 100644 --- a/packages/web-pkg/src/components/AppBar/AppBar.vue +++ b/packages/web-pkg/src/components/AppBar/AppBar.vue @@ -89,9 +89,9 @@ import ContextActions from '../FilesList/ContextActions.vue' import SidebarToggle from './SidebarToggle.vue' import { ViewMode } from '../../ui/types' import { - useFileActionsAcceptShare, + useFileActionsSyncShare, useFileActionsCopy, - useFileActionsDeclineShare, + useFileActionsUnsyncShare, useFileActionsDelete, useFileActionsDownloadArchive, useFileActionsDownloadFile, @@ -101,6 +101,7 @@ import { } from '../../composables/actions' import { useCapabilitySpacesMaxQuota, + useFileActionsToggleHideShare, useRouteMeta, useStore, ViewModeConstants @@ -165,9 +166,10 @@ export default defineComponent({ const store = useStore() const { $gettext } = useGettext() - const { actions: acceptShareActions } = useFileActionsAcceptShare({ store }) + const { actions: acceptShareActions } = useFileActionsSyncShare({ store }) + const { actions: hideShareActions } = useFileActionsToggleHideShare({ store }) const { actions: copyActions } = useFileActionsCopy({ store }) - const { actions: declineShareActions } = useFileActionsDeclineShare({ store }) + const { actions: declineShareActions } = useFileActionsUnsyncShare({ store }) const { actions: deleteActions } = useFileActionsDelete({ store }) const { actions: downloadArchiveActions } = useFileActionsDownloadArchive({ store }) const { actions: downloadFileActions } = useFileActionsDownloadFile() @@ -190,6 +192,7 @@ export default defineComponent({ const batchActions = computed(() => { let actions = [ + ...unref(hideShareActions), ...unref(acceptShareActions), ...unref(declineShareActions), ...unref(downloadArchiveActions), diff --git a/packages/web-pkg/src/components/FilesList/ContextActions.vue b/packages/web-pkg/src/components/FilesList/ContextActions.vue index 58123b10b8e..c8dc683ef0f 100644 --- a/packages/web-pkg/src/components/FilesList/ContextActions.vue +++ b/packages/web-pkg/src/components/FilesList/ContextActions.vue @@ -13,9 +13,9 @@ import { useFileActionsPaste, useFileActionsShowDetails, useFileActionsShowShares, - useFileActionsAcceptShare, + useFileActionsSyncShare, useFileActionsCopy, - useFileActionsDeclineShare, + useFileActionsUnsyncShare, useFileActionsDelete, useFileActionsDownloadArchive, useFileActionsEmptyTrashBin, @@ -48,10 +48,10 @@ export default defineComponent({ const { editorActions, loadExternalAppActions } = useFileActions() - const { actions: acceptShareActions } = useFileActionsAcceptShare({ store }) + const { actions: acceptShareActions } = useFileActionsSyncShare({ store }) const { actions: copyActions } = useFileActionsCopy({ store }) const { actions: createQuickLinkActions } = useFileActionsCreateQuickLink({ store }) - const { actions: declineShareActions } = useFileActionsDeclineShare({ store }) + const { actions: declineShareActions } = useFileActionsUnsyncShare({ store }) const { actions: deleteActions } = useFileActionsDelete({ store }) const { actions: downloadArchiveActions } = useFileActionsDownloadArchive({ store }) const { actions: downloadFileActions } = useFileActionsDownloadFile() diff --git a/packages/web-pkg/src/components/Filters/ItemFilterInline.vue b/packages/web-pkg/src/components/Filters/ItemFilterInline.vue new file mode 100644 index 00000000000..ad20badd8e7 --- /dev/null +++ b/packages/web-pkg/src/components/Filters/ItemFilterInline.vue @@ -0,0 +1,107 @@ + + + + diff --git a/packages/web-pkg/src/components/Filters/index.ts b/packages/web-pkg/src/components/Filters/index.ts new file mode 100644 index 00000000000..4784d7a7733 --- /dev/null +++ b/packages/web-pkg/src/components/Filters/index.ts @@ -0,0 +1,2 @@ +export { default as ItemFilterInline } from './ItemFilterInline.vue' +export * from './types' diff --git a/packages/web-pkg/src/components/Filters/types.ts b/packages/web-pkg/src/components/Filters/types.ts new file mode 100644 index 00000000000..c24e302dbe7 --- /dev/null +++ b/packages/web-pkg/src/components/Filters/types.ts @@ -0,0 +1,4 @@ +export type InlineFilterOption = { + name: string + label: string +} diff --git a/packages/web-pkg/src/components/index.ts b/packages/web-pkg/src/components/index.ts index 4460b13cff5..806502c1ca1 100644 --- a/packages/web-pkg/src/components/index.ts +++ b/packages/web-pkg/src/components/index.ts @@ -2,6 +2,7 @@ export * from './AppBar' export * from './AppTemplates' export * from './ContextActions' export * from './FilesList' +export * from './Filters' export * from './SideBar' export * from './Search' export * from './Spaces' diff --git a/packages/web-pkg/src/composables/actions/files/index.ts b/packages/web-pkg/src/composables/actions/files/index.ts index f3d0a4c9fbc..d6cbb6ee1e1 100644 --- a/packages/web-pkg/src/composables/actions/files/index.ts +++ b/packages/web-pkg/src/composables/actions/files/index.ts @@ -1,10 +1,10 @@ export * from './useFileActions' export * from './useFileActionsSetReadme' -export * from './useFileActionsAcceptShare' -export * from './useFileActionsHideShare' +export * from './useFileActionsSyncShare' +export * from './useFileActionsToggleHideShare' export * from './useFileActionsCopy' export * from './useFileActionsCreateQuicklink' -export * from './useFileActionsDeclineShare' +export * from './useFileActionsUnsyncShare' export * from './useFileActionsDelete' export * from './useFileActionsDownloadArchive' export * from './useFileActionsDownloadFile' diff --git a/packages/web-pkg/src/composables/actions/files/useFileActions.ts b/packages/web-pkg/src/composables/actions/files/useFileActions.ts index cf6fcb8f9c2..87691e82b93 100644 --- a/packages/web-pkg/src/composables/actions/files/useFileActions.ts +++ b/packages/web-pkg/src/composables/actions/files/useFileActions.ts @@ -19,10 +19,10 @@ import { } from '../../actions' import { - useFileActionsAcceptShare, - useFileActionsHideShare, + useFileActionsSyncShare, + useFileActionsToggleHideShare, useFileActionsCopy, - useFileActionsDeclineShare, + useFileActionsUnsyncShare, useFileActionsDelete, useFileActionsDownloadArchive, useFileActionsDownloadFile, @@ -54,11 +54,11 @@ export const useFileActions = ({ store }: { store?: Store } = {}) => { const { openUrl } = useWindowOpen() - const { actions: acceptShareActions } = useFileActionsAcceptShare({ store }) - const { actions: hideShareActions } = useFileActionsHideShare({ store }) + const { actions: acceptShareActions } = useFileActionsSyncShare({ store }) + const { actions: hideShareActions } = useFileActionsToggleHideShare({ store }) const { actions: copyActions } = useFileActionsCopy({ store }) const { actions: deleteActions } = useFileActionsDelete({ store }) - const { actions: declineShareActions } = useFileActionsDeclineShare({ store }) + const { actions: declineShareActions } = useFileActionsUnsyncShare({ store }) const { actions: downloadArchiveActions } = useFileActionsDownloadArchive({ store }) const { actions: downloadFileActions } = useFileActionsDownloadFile() const { actions: favoriteActions } = useFileActionsFavorite({ store }) @@ -214,8 +214,6 @@ export const useFileActions = ({ store }: { store?: Store } = {}) => { } const triggerAction = (name: string, options: FileActionOptions) => { - console.log(getAllAvailableActions(options)) - const action = getAllAvailableActions(options).filter((action) => action.name === name)[0] if (!action) { throw new Error(`Action not found: '${name}'`) diff --git a/packages/web-pkg/src/composables/actions/files/useFileActionsAcceptShare.ts b/packages/web-pkg/src/composables/actions/files/useFileActionsSyncShare.ts similarity index 87% rename from packages/web-pkg/src/composables/actions/files/useFileActionsAcceptShare.ts rename to packages/web-pkg/src/composables/actions/files/useFileActionsSyncShare.ts index 7a83fb8ae72..e7795d95f74 100644 --- a/packages/web-pkg/src/composables/actions/files/useFileActionsAcceptShare.ts +++ b/packages/web-pkg/src/composables/actions/files/useFileActionsSyncShare.ts @@ -14,10 +14,10 @@ import { computed, unref } from 'vue' import { useGettext } from 'vue3-gettext' import { FileAction, FileActionOptions } from '../../actions' -export const useFileActionsAcceptShare = ({ store }: { store?: Store } = {}) => { +export const useFileActionsSyncShare = ({ store }: { store?: Store } = {}) => { store = store || useStore() const router = useRouter() - const { $ngettext } = useGettext() + const { $gettext, $ngettext } = useGettext() const hasResharing = useCapabilityFilesSharingResharing() const hasShareJail = useCapabilityShareJailEnabled() @@ -61,8 +61,8 @@ export const useFileActionsAcceptShare = ({ store }: { store?: Store } = {} if (isLocationSpacesActive(router, 'files-spaces-generic')) { store.dispatch('showMessage', { title: $ngettext( - 'The selected share was accepted successfully', - 'The selected shares were accepted successfully', + 'Sync for the selected share was enabled successfully', + 'Sync for the selected shares was enabled successfully', resources.length ) }) @@ -73,8 +73,8 @@ export const useFileActionsAcceptShare = ({ store }: { store?: Store } = {} store.dispatch('showErrorMessage', { title: $ngettext( - 'Failed to accept the selected share.', - 'Failed to accept selected shares.', + 'Failed to enable sync for the the selected share', + 'Failed to enable sync for the selected shares', resources.length ), errors @@ -83,10 +83,10 @@ export const useFileActionsAcceptShare = ({ store }: { store?: Store } = {} const actions = computed((): FileAction[] => [ { - name: 'accept-share', + name: 'sync-share', icon: 'check', handler: (args) => loadingService.addTask(() => handler(args)), - label: ({ resources }) => $ngettext('Accept share', 'Accept shares', resources.length), + label: () => $gettext('Enable sync'), isEnabled: ({ space, resources }) => { if ( !isLocationSharesActive(router, 'files-shares-with-me') && @@ -111,7 +111,7 @@ export const useFileActionsAcceptShare = ({ store }: { store?: Store } = {} return !acceptDisabled }, componentType: 'button', - class: 'oc-files-actions-accept-share-trigger' + class: 'oc-files-actions-sync-share-trigger' } ]) diff --git a/packages/web-pkg/src/composables/actions/files/useFileActionsHideShare.ts b/packages/web-pkg/src/composables/actions/files/useFileActionsToggleHideShare.ts similarity index 58% rename from packages/web-pkg/src/composables/actions/files/useFileActionsHideShare.ts rename to packages/web-pkg/src/composables/actions/files/useFileActionsToggleHideShare.ts index 6d44a82c0aa..6563c1f4179 100644 --- a/packages/web-pkg/src/composables/actions/files/useFileActionsHideShare.ts +++ b/packages/web-pkg/src/composables/actions/files/useFileActionsToggleHideShare.ts @@ -2,8 +2,7 @@ import { triggerShareAction } from '../../../helpers/share/triggerShareAction' import { Store } from 'vuex' import PQueue from 'p-queue' -import { ShareStatus } from '@ownclouders/web-client/src/helpers/share' -import { isLocationSharesActive, isLocationSpacesActive } from '../../../router' +import { isLocationSharesActive } from '../../../router' import { useCapabilityFilesSharingResharing, useCapabilityShareJailEnabled } from '../../capability' import { useClientService } from '../../clientService' import { useConfigurationManager } from '../../configuration' @@ -13,12 +12,12 @@ 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' -// TODO: Replace all "accept" copy leftovers -export const useFileActionsHideShare = ({ store }: { store?: Store } = {}) => { +export const useFileActionsToggleHideShare = ({ store }: { store?: Store } = {}) => { store = store || useStore() const router = useRouter() - const { $ngettext } = useGettext() + const { $gettext } = useGettext() const hasResharing = useCapabilityFilesSharingResharing() const hasShareJail = useCapabilityShareJailEnabled() @@ -26,18 +25,22 @@ export const useFileActionsHideShare = ({ 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 + resources.forEach((resource) => { triggerPromises.push( triggerQueue.add(async () => { try { const share = await triggerShareAction({ resource, - status: ShareStatus.pending, - // visibility: 'public', + status: resource.status, + hide, hasResharing: unref(hasResharing), hasShareJail: unref(hasShareJail), client: clientService.owncloudSdk, @@ -54,63 +57,38 @@ export const useFileActionsHideShare = ({ store }: { store?: Store } = {}) }) ) }) + await Promise.all(triggerPromises) - console.log(errors) + if (errors.length === 0) { store.dispatch('Files/resetFileSelection') - - if (isLocationSpacesActive(router, 'files-spaces-generic')) { - store.dispatch('showMessage', { - title: $ngettext( - 'The selected share was accepted successfully', - 'The selected shares were accepted successfully', - resources.length - ) - }) - } + store.dispatch('showMessage', { + title: hide + ? $gettext('The share was hidden successfully') + : $gettext('The share was unhidden successfully') + }) return } store.dispatch('showErrorMessage', { - title: $ngettext( - 'Failed to accept the selected share.', - 'Failed to accept selected shares.', - resources.length - ), + title: hide ? $gettext('Failed to hide the share') : $gettext('Failed to unhide share share'), errors }) } const actions = computed((): FileAction[] => [ { - name: 'hide-share', - icon: 'check', + name: 'toggle-hide-share', + icon: 'eye-off', // FIXME: change icon based on hidden status handler: (args) => loadingService.addTask(() => handler(args)), - label: ({ resources }) => $ngettext('Accept share', 'Accept shares', resources.length), - isEnabled: ({ space, resources }) => { - if ( - !isLocationSharesActive(router, 'files-shares-with-me') && - !isLocationSpacesActive(router, 'files-spaces-generic') - ) { - return false - } + label: ({ resources }) => (resources[0].hidden ? $gettext('Unhide') : $gettext('Hide')), + isEnabled: ({ resources }) => { if (resources.length === 0) { return false } - if ( - isLocationSpacesActive(router, 'files-spaces-generic') && - (unref(space)?.driveType !== 'share' || resources.length > 1 || resources[0].path !== '/') - ) { - return false - } - - return true - // const acceptDisabled = resources.some((resource) => { - // return resource.status === ShareStatus.accepted - // }) - // return !acceptDisabled + return isLocationSharesActive(router, 'files-shares-with-me') }, componentType: 'button', class: 'oc-files-actions-hide-share-trigger' diff --git a/packages/web-pkg/src/composables/actions/files/useFileActionsDeclineShare.ts b/packages/web-pkg/src/composables/actions/files/useFileActionsUnsyncShare.ts similarity index 86% rename from packages/web-pkg/src/composables/actions/files/useFileActionsDeclineShare.ts rename to packages/web-pkg/src/composables/actions/files/useFileActionsUnsyncShare.ts index 625b8c7ccfd..b59354f4ac6 100644 --- a/packages/web-pkg/src/composables/actions/files/useFileActionsDeclineShare.ts +++ b/packages/web-pkg/src/composables/actions/files/useFileActionsUnsyncShare.ts @@ -17,10 +17,10 @@ import { computed, unref } from 'vue' import { useGettext } from 'vue3-gettext' import { FileAction, FileActionOptions } from '../types' -export const useFileActionsDeclineShare = ({ store }: { store?: Store } = {}) => { +export const useFileActionsUnsyncShare = ({ store }: { store?: Store } = {}) => { store = store || useStore() const router = useRouter() - const { $ngettext } = useGettext() + const { $gettext, $ngettext } = useGettext() const hasResharing = useCapabilityFilesSharingResharing() const hasShareJail = useCapabilityShareJailEnabled() @@ -59,13 +59,11 @@ export const useFileActionsDeclineShare = ({ store }: { store?: Store } = { await Promise.all(triggerPromises) if (errors.length === 0) { - store.dispatch('Files/resetFileSelection') - if (isLocationSpacesActive(router, 'files-spaces-generic')) { store.dispatch('showMessage', { title: $ngettext( - 'The selected share was declined successfully', - 'The selected shares were declined successfully', + 'Sync for the selected share was disabled successfully', + 'Sync for the selected shares was disabled successfully', resources.length ) }) @@ -77,8 +75,8 @@ export const useFileActionsDeclineShare = ({ store }: { store?: Store } = { store.dispatch('showErrorMessage', { title: $ngettext( - 'Failed to decline the selected share', - 'Failed to decline selected shares', + 'Failed to disable sync for the the selected share', + 'Failed to disable sync for the selected shares', resources.length ), errors @@ -87,10 +85,10 @@ export const useFileActionsDeclineShare = ({ store }: { store?: Store } = { const actions = computed((): FileAction[] => [ { - name: 'decline-share', + name: 'unsync-share', icon: 'spam-3', handler: (args) => loadingService.addTask(() => handler(args)), - label: ({ resources }) => $ngettext('Decline share', 'Decline shares', resources.length), + label: () => $gettext('Disable sync'), isEnabled: ({ space, resources }) => { if ( !isLocationSharesActive(router, 'files-shares-with-me') && @@ -115,7 +113,7 @@ export const useFileActionsDeclineShare = ({ store }: { store?: Store } = { return !declineDisabled }, componentType: 'button', - class: 'oc-files-actions-decline-share-trigger' + class: 'oc-files-actions-unsync-share-trigger' } ]) diff --git a/packages/web-pkg/src/helpers/share/triggerShareAction.ts b/packages/web-pkg/src/helpers/share/triggerShareAction.ts index 706fbac89ca..d6337fb16a4 100644 --- a/packages/web-pkg/src/helpers/share/triggerShareAction.ts +++ b/packages/web-pkg/src/helpers/share/triggerShareAction.ts @@ -6,7 +6,7 @@ import { OwnCloudSdk } from '@ownclouders/web-client/src/types' export async function triggerShareAction({ resource, status, - hide = 'false', + hide = false, hasResharing, hasShareJail, client, @@ -15,7 +15,7 @@ export async function triggerShareAction({ }: { resource: Resource status: ShareStatus - hide?: 'false' | 'true' + hide?: boolean hasResharing: boolean hasShareJail: boolean client: OwnCloudSdk @@ -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}`, + action: `api/v1/shares/pending/${resource.share.id}?hide=${hide ? 'true' : 'false'}`, method }) diff --git a/packages/web-pkg/tests/unit/components/FilesList/ContextActions.spec.ts b/packages/web-pkg/tests/unit/components/FilesList/ContextActions.spec.ts index 8f0d74f6e9a..c4d0ac64bcf 100644 --- a/packages/web-pkg/tests/unit/components/FilesList/ContextActions.spec.ts +++ b/packages/web-pkg/tests/unit/components/FilesList/ContextActions.spec.ts @@ -11,7 +11,7 @@ import { Resource, SpaceResource } from '@ownclouders/web-client/src/helpers' import ContextActions from '../../../../src/components/FilesList/ContextActions.vue' import { - useFileActionsAcceptShare, + useFileActionsSyncShare, useFileActionsCreateQuickLink, useFileActionsRename, useFileActionsCopy @@ -46,7 +46,7 @@ describe.skip('ContextActions', () => { it('render enabled actions', () => { const enabledComposables = [ - useFileActionsAcceptShare, + useFileActionsSyncShare, useFileActionsCreateQuickLink, useFileActionsRename, useFileActionsCopy diff --git a/packages/web-pkg/tests/unit/components/Filters/ItemFilterInline.spec.ts b/packages/web-pkg/tests/unit/components/Filters/ItemFilterInline.spec.ts new file mode 100644 index 00000000000..85b3db8c469 --- /dev/null +++ b/packages/web-pkg/tests/unit/components/Filters/ItemFilterInline.spec.ts @@ -0,0 +1,70 @@ +import ItemFilterInline from '../../../../src/components/Filters/ItemFilterInline.vue' +import { InlineFilterOption } from '../../../../src/components/Filters/types' +import { defaultComponentMocks, defaultPlugins, mount } from 'web-test-helpers' +import { queryItemAsString } from '../../../../src/composables/appDefaults' +import { mock } from 'jest-mock-extended' + +jest.mock('../../../../src/composables/appDefaults', () => ({ + appDefaults: jest.fn(), + queryItemAsString: jest.fn() +})) + +const selectors = { + filterOption: '.item-inline-filter-option', + filterOptionLabel: '.item-inline-filter-option-label', + selectedOptionLabel: '.item-inline-filter-option-selected .item-inline-filter-option-label' +} + +describe('ItemFilterInline', () => { + const filterOptions = [ + mock({ name: 'filter1', label: 'filter1' }), + mock({ name: 'filter2', label: 'filter2' }) + ] + + it('renders all given options', () => { + const { wrapper } = getWrapper({ props: { filterOptions } }) + expect(wrapper.findAll(selectors.filterOption).length).toBe(filterOptions.length) + expect(wrapper.findAll(selectors.filterOption).at(0).text()).toEqual(filterOptions[0].label) + expect(wrapper.findAll(selectors.filterOption).at(1).text()).toEqual(filterOptions[1].label) + }) + it('emits the "toggleFilter"-event on click on an option', async () => { + const { wrapper } = getWrapper({ props: { filterOptions } }) + await wrapper.find(selectors.filterOption).trigger('click') + expect(wrapper.emitted('toggleFilter').length).toBeGreaterThan(0) + }) + describe('route query', () => { + it('sets the active option as query param', async () => { + const { wrapper, mocks } = getWrapper({ props: { filterOptions } }) + const currentRouteQuery = (mocks.$router.currentRoute as any).query + expect(mocks.$router.push).not.toHaveBeenCalled() + await wrapper.find(selectors.filterOption).trigger('click') + expect(currentRouteQuery[wrapper.vm.queryParam]).toBeDefined() + expect(mocks.$router.push).toHaveBeenCalled() + }) + it('sets the active optin initially when given via query param', async () => { + const initialQuery = filterOptions[1].name + const { wrapper } = getWrapper({ initialQuery, props: { filterOptions } }) + await wrapper.vm.$nextTick() + expect(wrapper.find(selectors.selectedOptionLabel).text()).toEqual(initialQuery) + }) + }) +}) + +function getWrapper({ props = {}, initialQuery = '' } = {}) { + jest.mocked(queryItemAsString).mockImplementation(() => initialQuery) + const mocks = defaultComponentMocks() + return { + mocks, + wrapper: mount(ItemFilterInline, { + props: { + filterName: 'InlineFilter', + ...props + }, + global: { + plugins: [...defaultPlugins()], + mocks, + provide: mocks + } + }) + } +} diff --git a/packages/web-pkg/tests/unit/composables/actions/files/useFileActionsAcceptShare.spec.ts b/packages/web-pkg/tests/unit/composables/actions/files/useFileActionsSyncShare.spec.ts similarity index 90% rename from packages/web-pkg/tests/unit/composables/actions/files/useFileActionsAcceptShare.spec.ts rename to packages/web-pkg/tests/unit/composables/actions/files/useFileActionsSyncShare.spec.ts index e4ba16962ca..25f31db3221 100644 --- a/packages/web-pkg/tests/unit/composables/actions/files/useFileActionsAcceptShare.spec.ts +++ b/packages/web-pkg/tests/unit/composables/actions/files/useFileActionsSyncShare.spec.ts @@ -1,6 +1,6 @@ import { mock } from 'jest-mock-extended' import { unref } from 'vue' -import { useFileActionsAcceptShare } from '../../../../../src/composables/actions/files/useFileActionsAcceptShare' +import { useFileActionsSyncShare } from '../../../../../src/composables/actions/files/useFileActionsSyncShare' import { Resource } from '@ownclouders/web-client' import { ShareStatus } from '@ownclouders/web-client/src/helpers/share' import { useStore } from '../../../../../src/composables' @@ -22,7 +22,7 @@ describe('acceptShare', () => { const { wrapper } = getWrapper({ setup: () => { const store = useStore() - const { actions } = useFileActionsAcceptShare({ store }) + const { actions } = useFileActionsSyncShare({ store }) const resources = inputData.resources expect(unref(actions)[0].isEnabled({ space: null, resources })).toBe( @@ -43,7 +43,7 @@ describe('acceptShare', () => { routeName: sharesWithOthersLocation, setup: () => { const store = useStore() - const { actions } = useFileActionsAcceptShare({ store }) + const { actions } = useFileActionsSyncShare({ store }) expect( unref(actions)[0].isEnabled({ space: null, resources: [resource] }) diff --git a/packages/web-pkg/tests/unit/helpers/share/triggerShareAction.spec.ts b/packages/web-pkg/tests/unit/helpers/share/triggerShareAction.spec.ts index c35d6570be5..d7a91f2322d 100644 --- a/packages/web-pkg/tests/unit/helpers/share/triggerShareAction.spec.ts +++ b/packages/web-pkg/tests/unit/helpers/share/triggerShareAction.spec.ts @@ -22,7 +22,7 @@ describe('method triggerShareAction', () => { await expect( triggerShareAction({ resource: null, - status: ShareStatus.pending, + status: 3 as any, hasResharing: true, hasShareJail: false, client: null diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a1911e0a466..4c239ced98b 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1132,8 +1132,8 @@ importers: specifier: ^2.1.0 version: 2.1.0 owncloud-sdk: - specifier: 3.1.0-alpha.9 - version: 3.1.0-alpha.9(axios@1.4.0)(cross-fetch@3.1.4)(promise@8.1.0)(qs@6.10.3)(utf8@3.0.0)(uuid@9.0.0)(webdav@5.3.0)(xml-js@1.6.11) + specifier: file:./../../../owncloud-sdk + version: file:../owncloud-sdk(axios@1.4.0)(cross-fetch@3.1.4)(promise@8.1.0)(qs@6.10.3)(utf8@3.0.0)(uuid@9.0.0)(webdav@5.3.0)(xml-js@1.6.11) p-queue: specifier: ^6.6.2 version: 6.6.2 @@ -16893,28 +16893,6 @@ packages: engines: {node: '>=0.10.0'} dev: true - /owncloud-sdk@3.1.0-alpha.9(axios@1.4.0)(cross-fetch@3.1.4)(promise@8.1.0)(qs@6.10.3)(utf8@3.0.0)(uuid@9.0.0)(webdav@5.3.0)(xml-js@1.6.11): - resolution: {integrity: sha512-RFisWiv7ZJbWnLKSt2UyPVWbsZqYQ1crWQwpRGwsnKD0Ow5qMXvhbKzZh0EsEF6KEGiQVV3j1lfmgxUDIgBKgA==} - peerDependencies: - axios: ^0.27.2 - cross-fetch: ^3.0.6 - promise: ^8.1.0 - qs: ^6.10.3 - utf8: ^3.0.0 - uuid: ^8.2.0 - webdav: 4.10.0 - xml-js: ^1.6.11 - dependencies: - axios: 1.4.0 - cross-fetch: 3.1.4 - promise: 8.1.0 - qs: 6.10.3 - utf8: 3.0.0 - uuid: 9.0.0 - webdav: 5.3.0 - xml-js: 1.6.11 - dev: false - /p-finally@1.0.0: resolution: {integrity: sha512-LICb2p9CB7FS+0eR1oqWnHhp0FljGLZCWBE9aix0Uye9W8LTQPwMTYVGWQWIw9RdQiDg4+epXQODwIYJtSJaow==} engines: {node: '>=4'} @@ -22727,6 +22705,31 @@ packages: preact: 10.7.1 dev: false + file:../owncloud-sdk(axios@1.4.0)(cross-fetch@3.1.4)(promise@8.1.0)(qs@6.10.3)(utf8@3.0.0)(uuid@9.0.0)(webdav@5.3.0)(xml-js@1.6.11): + resolution: {directory: ../owncloud-sdk, type: directory} + id: file:../owncloud-sdk + name: owncloud-sdk + version: 3.0.0 + peerDependencies: + axios: ^0.27.2 + cross-fetch: ^3.0.6 + promise: ^8.1.0 + qs: ^6.10.3 + utf8: ^3.0.0 + uuid: ^8.2.0 + webdav: 4.10.0 + xml-js: ^1.6.11 + dependencies: + axios: 1.4.0 + cross-fetch: 3.1.4 + promise: 8.1.0 + qs: 6.10.3 + utf8: 3.0.0 + uuid: 9.0.0 + webdav: 5.3.0 + xml-js: 1.6.11 + dev: false + github.com/dschmidt/v-calendar/3ce6e3b8afd5491cb53ee811281d5fa8a45b044d(vue@3.3.4): resolution: {tarball: https://codeload.github.com/dschmidt/v-calendar/tar.gz/3ce6e3b8afd5491cb53ee811281d5fa8a45b044d} id: github.com/dschmidt/v-calendar/3ce6e3b8afd5491cb53ee811281d5fa8a45b044d diff --git a/tests/acceptance/pageObjects/FilesPageElement/fileActionsMenu.js b/tests/acceptance/pageObjects/FilesPageElement/fileActionsMenu.js index ba86501ae50..a774bdbd31e 100644 --- a/tests/acceptance/pageObjects/FilesPageElement/fileActionsMenu.js +++ b/tests/acceptance/pageObjects/FilesPageElement/fileActionsMenu.js @@ -226,11 +226,11 @@ module.exports = { locateStrategy: 'xpath' }, acceptShareButtonInAccordion: { - selector: '//button[contains(@class, "oc-files-actions-accept-share-trigger")]', + selector: '//button[contains(@class, "oc-files-actions-sync-share-trigger")]', locateStrategy: 'xpath' }, declineShareButtonInAccordion: { - selector: '//button[contains(@class, "oc-files-actions-decline-share-trigger")]', + selector: '//button[contains(@class, "oc-files-actions-unsync-share-trigger")]', locateStrategy: 'xpath' }, previewButtonInAccordion: { diff --git a/tests/acceptance/pageObjects/sharedWithMePage.js b/tests/acceptance/pageObjects/sharedWithMePage.js index 6b726417073..243041e824b 100644 --- a/tests/acceptance/pageObjects/sharedWithMePage.js +++ b/tests/acceptance/pageObjects/sharedWithMePage.js @@ -159,7 +159,7 @@ module.exports = { locateStrategy: 'xpath' }, batchDeclineSharesButton: { - selector: '.oc-files-actions-decline-share-trigger' + selector: '.oc-files-actions-unsync-share-trigger' } } } diff --git a/tests/e2e/support/objects/app-files/share/actions.ts b/tests/e2e/support/objects/app-files/share/actions.ts index 298246ca743..7ff7a690ae7 100644 --- a/tests/e2e/support/objects/app-files/share/actions.ts +++ b/tests/e2e/support/objects/app-files/share/actions.ts @@ -27,7 +27,7 @@ const publicLinkInputField = '/following-sibling::div//p[contains(@class,"oc-files-file-link-url")]' const showAllButton = '#files-shared-with-me-pending-section #files-shared-with-me-show-all' const selecAllCheckbox = '#files-shared-with-me-pending-section #resource-table-select-all' -const acceptButton = '.oc-files-actions-accept-share-trigger' +const acceptButton = '.oc-files-actions-sync-share-trigger' const pendingShareItem = '//div[@id="files-shared-with-me-pending-section"]//tr[contains(@class,"oc-tbody-tr")]' From 3b8e825463d4038c719e01cd4a2720e3d6a7ac10 Mon Sep 17 00:00:00 2001 From: Jannik Stehle Date: Wed, 18 Oct 2023 18:03:14 +0200 Subject: [PATCH 04/13] fixup! put remaining parts together to make it work --- .../src/components/OcButton/OcButton.vue | 1 + .../components/Shares/SharedWithMeSection.vue | 2 +- .../src/views/shares/SharedWithMe.vue | 24 ++------- .../components/Filters/ItemFilterInline.vue | 4 ++ packages/web-runtime/package.json | 2 +- pnpm-lock.yaml | 51 +++++++++---------- 6 files changed, 35 insertions(+), 49 deletions(-) diff --git a/packages/design-system/src/components/OcButton/OcButton.vue b/packages/design-system/src/components/OcButton/OcButton.vue index d51668ae0da..99fd847e290 100644 --- a/packages/design-system/src/components/OcButton/OcButton.vue +++ b/packages/design-system/src/components/OcButton/OcButton.vue @@ -221,6 +221,7 @@ export default defineComponent({ &-raw-inverse { background-color: transparent; border-style: none; + font-size: var(--oc-font-size-medium); font-weight: normal; min-height: 0; padding: 0; diff --git a/packages/web-app-files/src/components/Shares/SharedWithMeSection.vue b/packages/web-app-files/src/components/Shares/SharedWithMeSection.vue index ccebeca1b1a..a4e7e736838 100644 --- a/packages/web-app-files/src/components/Shares/SharedWithMeSection.vue +++ b/packages/web-app-files/src/components/Shares/SharedWithMeSection.vue @@ -293,6 +293,6 @@ export default defineComponent({ height: auto; } .oc-files-actions-hide-share-trigger:hover { - background-color: var(--oc-color-background-secondary); + background-color: var(--oc-color-background-secondary) !important; } diff --git a/packages/web-app-files/src/views/shares/SharedWithMe.vue b/packages/web-app-files/src/views/shares/SharedWithMe.vue index ec554856a5f..d07e9575aba 100644 --- a/packages/web-app-files/src/views/shares/SharedWithMe.vue +++ b/packages/web-app-files/src/views/shares/SharedWithMe.vue @@ -19,26 +19,8 @@ @toggle-filter="setAreHiddenFilesShown" /> - - diff --git a/packages/web-pkg/src/components/Filters/ItemFilterInline.vue b/packages/web-pkg/src/components/Filters/ItemFilterInline.vue index ad20badd8e7..89e79755ddd 100644 --- a/packages/web-pkg/src/components/Filters/ItemFilterInline.vue +++ b/packages/web-pkg/src/components/Filters/ItemFilterInline.vue @@ -62,6 +62,10 @@ export default defineComponent({ const queryStr = queryItemAsString(unref(currentRouteQuery)) if (queryStr && props.filterOptions.some(({ name }) => name === queryStr)) { activeOption.value = queryStr + emit( + 'toggleFilter', + props.filterOptions.find(({ name }) => name === queryStr) + ) } }) diff --git a/packages/web-runtime/package.json b/packages/web-runtime/package.json index e1d31ca13a7..8da947ec66a 100644 --- a/packages/web-runtime/package.json +++ b/packages/web-runtime/package.json @@ -26,7 +26,7 @@ "luxon": "^2.4.0", "marked": "^4.0.12", "oidc-client-ts": "^2.1.0", - "owncloud-sdk": "file:./../../../owncloud-sdk", + "owncloud-sdk": "3.1.0-alpha.10", "p-queue": "^6.6.2", "pinia": "^2.1.3", "portal-vue": "3.0.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 4c239ced98b..b308a20744d 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1132,8 +1132,8 @@ importers: specifier: ^2.1.0 version: 2.1.0 owncloud-sdk: - specifier: file:./../../../owncloud-sdk - version: file:../owncloud-sdk(axios@1.4.0)(cross-fetch@3.1.4)(promise@8.1.0)(qs@6.10.3)(utf8@3.0.0)(uuid@9.0.0)(webdav@5.3.0)(xml-js@1.6.11) + specifier: 3.1.0-alpha.10 + version: 3.1.0-alpha.10(axios@1.4.0)(cross-fetch@3.1.4)(promise@8.1.0)(qs@6.10.3)(utf8@3.0.0)(uuid@9.0.0)(webdav@5.3.0)(xml-js@1.6.11) p-queue: specifier: ^6.6.2 version: 6.6.2 @@ -16893,6 +16893,28 @@ packages: engines: {node: '>=0.10.0'} dev: true + /owncloud-sdk@3.1.0-alpha.10(axios@1.4.0)(cross-fetch@3.1.4)(promise@8.1.0)(qs@6.10.3)(utf8@3.0.0)(uuid@9.0.0)(webdav@5.3.0)(xml-js@1.6.11): + resolution: {integrity: sha512-cAq6BKkyDvm5MpcksicpBsfkr4ZEB+nm1Yl74FH3Qtm/wbI4uWwaTjqQmzYF5prAQDBDbi9F6nADp83zqfmPTA==} + peerDependencies: + axios: ^0.27.2 + cross-fetch: ^3.0.6 + promise: ^8.1.0 + qs: ^6.10.3 + utf8: ^3.0.0 + uuid: ^8.2.0 + webdav: 4.10.0 + xml-js: ^1.6.11 + dependencies: + axios: 1.4.0 + cross-fetch: 3.1.4 + promise: 8.1.0 + qs: 6.10.3 + utf8: 3.0.0 + uuid: 9.0.0 + webdav: 5.3.0 + xml-js: 1.6.11 + dev: false + /p-finally@1.0.0: resolution: {integrity: sha512-LICb2p9CB7FS+0eR1oqWnHhp0FljGLZCWBE9aix0Uye9W8LTQPwMTYVGWQWIw9RdQiDg4+epXQODwIYJtSJaow==} engines: {node: '>=4'} @@ -22705,31 +22727,6 @@ packages: preact: 10.7.1 dev: false - file:../owncloud-sdk(axios@1.4.0)(cross-fetch@3.1.4)(promise@8.1.0)(qs@6.10.3)(utf8@3.0.0)(uuid@9.0.0)(webdav@5.3.0)(xml-js@1.6.11): - resolution: {directory: ../owncloud-sdk, type: directory} - id: file:../owncloud-sdk - name: owncloud-sdk - version: 3.0.0 - peerDependencies: - axios: ^0.27.2 - cross-fetch: ^3.0.6 - promise: ^8.1.0 - qs: ^6.10.3 - utf8: ^3.0.0 - uuid: ^8.2.0 - webdav: 4.10.0 - xml-js: ^1.6.11 - dependencies: - axios: 1.4.0 - cross-fetch: 3.1.4 - promise: 8.1.0 - qs: 6.10.3 - utf8: 3.0.0 - uuid: 9.0.0 - webdav: 5.3.0 - xml-js: 1.6.11 - dev: false - github.com/dschmidt/v-calendar/3ce6e3b8afd5491cb53ee811281d5fa8a45b044d(vue@3.3.4): resolution: {tarball: https://codeload.github.com/dschmidt/v-calendar/tar.gz/3ce6e3b8afd5491cb53ee811281d5fa8a45b044d} id: github.com/dschmidt/v-calendar/3ce6e3b8afd5491cb53ee811281d5fa8a45b044d From 6a63eecbc576f79ec9d7f750aa076a7b44703ddd Mon Sep 17 00:00:00 2001 From: Jannik Stehle Date: Thu, 19 Oct 2023 08:59:16 +0200 Subject: [PATCH 05/13] keep original action names internally for accepting/declining shares --- packages/web-pkg/src/components/AppBar/AppBar.vue | 8 ++++---- .../web-pkg/src/components/FilesList/ContextActions.vue | 8 ++++---- packages/web-pkg/src/composables/actions/files/index.ts | 4 ++-- .../src/composables/actions/files/useFileActions.ts | 8 ++++---- ...leActionsSyncShare.ts => useFileActionsAcceptShare.ts} | 6 +++--- ...ctionsUnsyncShare.ts => useFileActionsDeclineShare.ts} | 6 +++--- .../unit/components/FilesList/ContextActions.spec.ts | 4 ++-- ...yncShare.spec.ts => useFileActionsAcceptShare.spec.ts} | 6 +++--- .../pageObjects/FilesPageElement/fileActionsMenu.js | 4 ++-- tests/acceptance/pageObjects/sharedWithMePage.js | 2 +- tests/e2e/support/objects/app-files/share/actions.ts | 2 +- 11 files changed, 29 insertions(+), 29 deletions(-) rename packages/web-pkg/src/composables/actions/files/{useFileActionsSyncShare.ts => useFileActionsAcceptShare.ts} (95%) rename packages/web-pkg/src/composables/actions/files/{useFileActionsUnsyncShare.ts => useFileActionsDeclineShare.ts} (95%) rename packages/web-pkg/tests/unit/composables/actions/files/{useFileActionsSyncShare.spec.ts => useFileActionsAcceptShare.spec.ts} (90%) diff --git a/packages/web-pkg/src/components/AppBar/AppBar.vue b/packages/web-pkg/src/components/AppBar/AppBar.vue index 84192c08922..ec4e8cc1695 100644 --- a/packages/web-pkg/src/components/AppBar/AppBar.vue +++ b/packages/web-pkg/src/components/AppBar/AppBar.vue @@ -89,9 +89,9 @@ import ContextActions from '../FilesList/ContextActions.vue' import SidebarToggle from './SidebarToggle.vue' import { ViewMode } from '../../ui/types' import { - useFileActionsSyncShare, + useFileActionsAcceptShare, useFileActionsCopy, - useFileActionsUnsyncShare, + useFileActionsDeclineShare, useFileActionsDelete, useFileActionsDownloadArchive, useFileActionsDownloadFile, @@ -166,10 +166,10 @@ export default defineComponent({ const store = useStore() const { $gettext } = useGettext() - const { actions: acceptShareActions } = useFileActionsSyncShare({ store }) + const { actions: acceptShareActions } = useFileActionsAcceptShare({ store }) const { actions: hideShareActions } = useFileActionsToggleHideShare({ store }) const { actions: copyActions } = useFileActionsCopy({ store }) - const { actions: declineShareActions } = useFileActionsUnsyncShare({ store }) + const { actions: declineShareActions } = useFileActionsDeclineShare({ store }) const { actions: deleteActions } = useFileActionsDelete({ store }) const { actions: downloadArchiveActions } = useFileActionsDownloadArchive({ store }) const { actions: downloadFileActions } = useFileActionsDownloadFile() diff --git a/packages/web-pkg/src/components/FilesList/ContextActions.vue b/packages/web-pkg/src/components/FilesList/ContextActions.vue index c8dc683ef0f..58123b10b8e 100644 --- a/packages/web-pkg/src/components/FilesList/ContextActions.vue +++ b/packages/web-pkg/src/components/FilesList/ContextActions.vue @@ -13,9 +13,9 @@ import { useFileActionsPaste, useFileActionsShowDetails, useFileActionsShowShares, - useFileActionsSyncShare, + useFileActionsAcceptShare, useFileActionsCopy, - useFileActionsUnsyncShare, + useFileActionsDeclineShare, useFileActionsDelete, useFileActionsDownloadArchive, useFileActionsEmptyTrashBin, @@ -48,10 +48,10 @@ export default defineComponent({ const { editorActions, loadExternalAppActions } = useFileActions() - const { actions: acceptShareActions } = useFileActionsSyncShare({ store }) + const { actions: acceptShareActions } = useFileActionsAcceptShare({ store }) const { actions: copyActions } = useFileActionsCopy({ store }) const { actions: createQuickLinkActions } = useFileActionsCreateQuickLink({ store }) - const { actions: declineShareActions } = useFileActionsUnsyncShare({ store }) + const { actions: declineShareActions } = useFileActionsDeclineShare({ store }) const { actions: deleteActions } = useFileActionsDelete({ store }) const { actions: downloadArchiveActions } = useFileActionsDownloadArchive({ store }) const { actions: downloadFileActions } = useFileActionsDownloadFile() diff --git a/packages/web-pkg/src/composables/actions/files/index.ts b/packages/web-pkg/src/composables/actions/files/index.ts index d6cbb6ee1e1..0ff81baa772 100644 --- a/packages/web-pkg/src/composables/actions/files/index.ts +++ b/packages/web-pkg/src/composables/actions/files/index.ts @@ -1,10 +1,10 @@ export * from './useFileActions' export * from './useFileActionsSetReadme' -export * from './useFileActionsSyncShare' +export * from './useFileActionsAcceptShare' export * from './useFileActionsToggleHideShare' export * from './useFileActionsCopy' export * from './useFileActionsCreateQuicklink' -export * from './useFileActionsUnsyncShare' +export * from './useFileActionsDeclineShare' export * from './useFileActionsDelete' export * from './useFileActionsDownloadArchive' export * from './useFileActionsDownloadFile' diff --git a/packages/web-pkg/src/composables/actions/files/useFileActions.ts b/packages/web-pkg/src/composables/actions/files/useFileActions.ts index 87691e82b93..30039e2d77b 100644 --- a/packages/web-pkg/src/composables/actions/files/useFileActions.ts +++ b/packages/web-pkg/src/composables/actions/files/useFileActions.ts @@ -19,10 +19,10 @@ import { } from '../../actions' import { - useFileActionsSyncShare, + useFileActionsAcceptShare, useFileActionsToggleHideShare, useFileActionsCopy, - useFileActionsUnsyncShare, + useFileActionsDeclineShare, useFileActionsDelete, useFileActionsDownloadArchive, useFileActionsDownloadFile, @@ -54,11 +54,11 @@ export const useFileActions = ({ store }: { store?: Store } = {}) => { const { openUrl } = useWindowOpen() - const { actions: acceptShareActions } = useFileActionsSyncShare({ store }) + const { actions: acceptShareActions } = useFileActionsAcceptShare({ store }) const { actions: hideShareActions } = useFileActionsToggleHideShare({ store }) const { actions: copyActions } = useFileActionsCopy({ store }) const { actions: deleteActions } = useFileActionsDelete({ store }) - const { actions: declineShareActions } = useFileActionsUnsyncShare({ store }) + const { actions: declineShareActions } = useFileActionsDeclineShare({ store }) const { actions: downloadArchiveActions } = useFileActionsDownloadArchive({ store }) const { actions: downloadFileActions } = useFileActionsDownloadFile() const { actions: favoriteActions } = useFileActionsFavorite({ store }) diff --git a/packages/web-pkg/src/composables/actions/files/useFileActionsSyncShare.ts b/packages/web-pkg/src/composables/actions/files/useFileActionsAcceptShare.ts similarity index 95% rename from packages/web-pkg/src/composables/actions/files/useFileActionsSyncShare.ts rename to packages/web-pkg/src/composables/actions/files/useFileActionsAcceptShare.ts index e7795d95f74..341efb3d849 100644 --- a/packages/web-pkg/src/composables/actions/files/useFileActionsSyncShare.ts +++ b/packages/web-pkg/src/composables/actions/files/useFileActionsAcceptShare.ts @@ -14,7 +14,7 @@ import { computed, unref } from 'vue' import { useGettext } from 'vue3-gettext' import { FileAction, FileActionOptions } from '../../actions' -export const useFileActionsSyncShare = ({ store }: { store?: Store } = {}) => { +export const useFileActionsAcceptShare = ({ store }: { store?: Store } = {}) => { store = store || useStore() const router = useRouter() const { $gettext, $ngettext } = useGettext() @@ -83,7 +83,7 @@ export const useFileActionsSyncShare = ({ store }: { store?: Store } = {}) const actions = computed((): FileAction[] => [ { - name: 'sync-share', + name: 'accept-share', icon: 'check', handler: (args) => loadingService.addTask(() => handler(args)), label: () => $gettext('Enable sync'), @@ -111,7 +111,7 @@ export const useFileActionsSyncShare = ({ store }: { store?: Store } = {}) return !acceptDisabled }, componentType: 'button', - class: 'oc-files-actions-sync-share-trigger' + class: 'oc-files-actions-accept-share-trigger' } ]) diff --git a/packages/web-pkg/src/composables/actions/files/useFileActionsUnsyncShare.ts b/packages/web-pkg/src/composables/actions/files/useFileActionsDeclineShare.ts similarity index 95% rename from packages/web-pkg/src/composables/actions/files/useFileActionsUnsyncShare.ts rename to packages/web-pkg/src/composables/actions/files/useFileActionsDeclineShare.ts index b59354f4ac6..bd2dd6e0ffc 100644 --- a/packages/web-pkg/src/composables/actions/files/useFileActionsUnsyncShare.ts +++ b/packages/web-pkg/src/composables/actions/files/useFileActionsDeclineShare.ts @@ -17,7 +17,7 @@ import { computed, unref } from 'vue' import { useGettext } from 'vue3-gettext' import { FileAction, FileActionOptions } from '../types' -export const useFileActionsUnsyncShare = ({ store }: { store?: Store } = {}) => { +export const useFileActionsDeclineShare = ({ store }: { store?: Store } = {}) => { store = store || useStore() const router = useRouter() const { $gettext, $ngettext } = useGettext() @@ -85,7 +85,7 @@ export const useFileActionsUnsyncShare = ({ store }: { store?: Store } = {} const actions = computed((): FileAction[] => [ { - name: 'unsync-share', + name: 'decline-share', icon: 'spam-3', handler: (args) => loadingService.addTask(() => handler(args)), label: () => $gettext('Disable sync'), @@ -113,7 +113,7 @@ export const useFileActionsUnsyncShare = ({ store }: { store?: Store } = {} return !declineDisabled }, componentType: 'button', - class: 'oc-files-actions-unsync-share-trigger' + class: 'oc-files-actions-decline-share-trigger' } ]) diff --git a/packages/web-pkg/tests/unit/components/FilesList/ContextActions.spec.ts b/packages/web-pkg/tests/unit/components/FilesList/ContextActions.spec.ts index c4d0ac64bcf..8f0d74f6e9a 100644 --- a/packages/web-pkg/tests/unit/components/FilesList/ContextActions.spec.ts +++ b/packages/web-pkg/tests/unit/components/FilesList/ContextActions.spec.ts @@ -11,7 +11,7 @@ import { Resource, SpaceResource } from '@ownclouders/web-client/src/helpers' import ContextActions from '../../../../src/components/FilesList/ContextActions.vue' import { - useFileActionsSyncShare, + useFileActionsAcceptShare, useFileActionsCreateQuickLink, useFileActionsRename, useFileActionsCopy @@ -46,7 +46,7 @@ describe.skip('ContextActions', () => { it('render enabled actions', () => { const enabledComposables = [ - useFileActionsSyncShare, + useFileActionsAcceptShare, useFileActionsCreateQuickLink, useFileActionsRename, useFileActionsCopy diff --git a/packages/web-pkg/tests/unit/composables/actions/files/useFileActionsSyncShare.spec.ts b/packages/web-pkg/tests/unit/composables/actions/files/useFileActionsAcceptShare.spec.ts similarity index 90% rename from packages/web-pkg/tests/unit/composables/actions/files/useFileActionsSyncShare.spec.ts rename to packages/web-pkg/tests/unit/composables/actions/files/useFileActionsAcceptShare.spec.ts index 25f31db3221..e4ba16962ca 100644 --- a/packages/web-pkg/tests/unit/composables/actions/files/useFileActionsSyncShare.spec.ts +++ b/packages/web-pkg/tests/unit/composables/actions/files/useFileActionsAcceptShare.spec.ts @@ -1,6 +1,6 @@ import { mock } from 'jest-mock-extended' import { unref } from 'vue' -import { useFileActionsSyncShare } from '../../../../../src/composables/actions/files/useFileActionsSyncShare' +import { useFileActionsAcceptShare } from '../../../../../src/composables/actions/files/useFileActionsAcceptShare' import { Resource } from '@ownclouders/web-client' import { ShareStatus } from '@ownclouders/web-client/src/helpers/share' import { useStore } from '../../../../../src/composables' @@ -22,7 +22,7 @@ describe('acceptShare', () => { const { wrapper } = getWrapper({ setup: () => { const store = useStore() - const { actions } = useFileActionsSyncShare({ store }) + const { actions } = useFileActionsAcceptShare({ store }) const resources = inputData.resources expect(unref(actions)[0].isEnabled({ space: null, resources })).toBe( @@ -43,7 +43,7 @@ describe('acceptShare', () => { routeName: sharesWithOthersLocation, setup: () => { const store = useStore() - const { actions } = useFileActionsSyncShare({ store }) + const { actions } = useFileActionsAcceptShare({ store }) expect( unref(actions)[0].isEnabled({ space: null, resources: [resource] }) diff --git a/tests/acceptance/pageObjects/FilesPageElement/fileActionsMenu.js b/tests/acceptance/pageObjects/FilesPageElement/fileActionsMenu.js index a774bdbd31e..ba86501ae50 100644 --- a/tests/acceptance/pageObjects/FilesPageElement/fileActionsMenu.js +++ b/tests/acceptance/pageObjects/FilesPageElement/fileActionsMenu.js @@ -226,11 +226,11 @@ module.exports = { locateStrategy: 'xpath' }, acceptShareButtonInAccordion: { - selector: '//button[contains(@class, "oc-files-actions-sync-share-trigger")]', + selector: '//button[contains(@class, "oc-files-actions-accept-share-trigger")]', locateStrategy: 'xpath' }, declineShareButtonInAccordion: { - selector: '//button[contains(@class, "oc-files-actions-unsync-share-trigger")]', + selector: '//button[contains(@class, "oc-files-actions-decline-share-trigger")]', locateStrategy: 'xpath' }, previewButtonInAccordion: { diff --git a/tests/acceptance/pageObjects/sharedWithMePage.js b/tests/acceptance/pageObjects/sharedWithMePage.js index 243041e824b..6b726417073 100644 --- a/tests/acceptance/pageObjects/sharedWithMePage.js +++ b/tests/acceptance/pageObjects/sharedWithMePage.js @@ -159,7 +159,7 @@ module.exports = { locateStrategy: 'xpath' }, batchDeclineSharesButton: { - selector: '.oc-files-actions-unsync-share-trigger' + selector: '.oc-files-actions-decline-share-trigger' } } } diff --git a/tests/e2e/support/objects/app-files/share/actions.ts b/tests/e2e/support/objects/app-files/share/actions.ts index 7ff7a690ae7..298246ca743 100644 --- a/tests/e2e/support/objects/app-files/share/actions.ts +++ b/tests/e2e/support/objects/app-files/share/actions.ts @@ -27,7 +27,7 @@ const publicLinkInputField = '/following-sibling::div//p[contains(@class,"oc-files-file-link-url")]' const showAllButton = '#files-shared-with-me-pending-section #files-shared-with-me-show-all' const selecAllCheckbox = '#files-shared-with-me-pending-section #resource-table-select-all' -const acceptButton = '.oc-files-actions-sync-share-trigger' +const acceptButton = '.oc-files-actions-accept-share-trigger' const pendingShareItem = '//div[@id="files-shared-with-me-pending-section"]//tr[contains(@class,"oc-tbody-tr")]' From 76bd442497b3d31684e23c98be817146c58fcacf Mon Sep 17 00:00:00 2001 From: Jannik Stehle Date: Thu, 19 Oct 2023 11:30:18 +0200 Subject: [PATCH 06/13] test: fix tests --- .../components/Shares/SharedWithMeSection.vue | 1 + .../src/views/shares/SharedWithMe.vue | 2 - .../pageObjects/sharedWithMePage.js | 37 +++++---------- .../stepDefinitions/sharingContext.js | 4 +- .../e2e/cucumber/features/smoke/share.feature | 6 +-- tests/e2e/cucumber/steps/ui/shares.ts | 16 +++++++ .../objects/app-files/share/actions.ts | 46 ++----------------- .../support/objects/app-files/share/index.ts | 6 ++- .../support/objects/app-files/share/utils.ts | 12 +++++ 9 files changed, 55 insertions(+), 75 deletions(-) diff --git a/packages/web-app-files/src/components/Shares/SharedWithMeSection.vue b/packages/web-app-files/src/components/Shares/SharedWithMeSection.vue index a4e7e736838..d81d4a8d8c5 100644 --- a/packages/web-app-files/src/components/Shares/SharedWithMeSection.vue +++ b/packages/web-app-files/src/components/Shares/SharedWithMeSection.vue @@ -43,6 +43,7 @@ v-if="getShowSynchedIcon(resource)" v-oc-tooltip="$gettext('Synced with your devices')" name="cloudy-2" + class="sync-enabled" /> diff --git a/packages/web-app-files/src/views/shares/SharedWithMe.vue b/packages/web-app-files/src/views/shares/SharedWithMe.vue index d07e9575aba..7c92200ca1d 100644 --- a/packages/web-app-files/src/views/shares/SharedWithMe.vue +++ b/packages/web-app-files/src/views/shares/SharedWithMe.vue @@ -24,8 +24,6 @@ :display-thumbnails="displayThumbnails" :file-list-header-y="fileListHeaderY" :items="items" - :resource-clickable="true" - :show-more-toggle="true" :side-bar-open="sideBarOpen" :sort-by="sortBy" :sort-dir="sortDir" diff --git a/tests/acceptance/pageObjects/sharedWithMePage.js b/tests/acceptance/pageObjects/sharedWithMePage.js index 6b726417073..63c732a3da1 100644 --- a/tests/acceptance/pageObjects/sharedWithMePage.js +++ b/tests/acceptance/pageObjects/sharedWithMePage.js @@ -42,16 +42,21 @@ module.exports = { */ hasShareStatusByFilenameAndUser: async function (status, filename, owner) { let selector = - util.format(this.elements.shareTable.selector, status) + this.api.page.FilesPageElement.filesList().getFileRowSelectorByFileName(filename) if (owner) { selector += util.format(this.elements.shareOwnerName.selector, owner) } + selector += this.elements.syncEnabled.selector let isPresent = false await this.api.element('xpath', selector, function (result) { isPresent = !!(result.value && result.value.ELEMENT) }) - return isPresent + + if (status === SHARE_STATE.accepted) { + return isPresent + } + + return !isPresent }, /** * Checks if the share matching the given status and filename is present on the given page. @@ -74,26 +79,6 @@ module.exports = { .click('@batchDeclineSharesButton') .waitForAjaxCallsToStartAndFinish() }, - /** - * @param {string} filename - * @param {string} action - It takes one of the following : Decline and Accept - * @param {string} user - The user who created the share - *Performs required action, such as accept and decline, on the file row element of the desired file name - * shared by specific user - */ - declineAcceptFile: function (action, filename, user) { - const actionLocatorButton = { - locateStrategy: this.elements.shareStatusActionOnFileRow.locateStrategy, - selector: - this.api.page.FilesPageElement.filesList().getFileRowSelectorByFileName(filename) + - util.format(this.elements.shareOwnerName.selector, user) + - util.format(this.elements.shareStatusActionOnFileRow.selector, action) - } - return this.waitForElementVisible(actionLocatorButton) - .initAjaxCounters() - .click(actionLocatorButton) - .waitForOutstandingAjaxCalls() - }, /** * gets the username of user that the element(file/folder/resource) on the shared-with-me page is shared by * @@ -137,15 +122,15 @@ module.exports = { } }, elements: { - shareTable: { - selector: '//table[@data-test-share-status="%s"]', - locateStrategy: 'xpath' - }, shareOwnerName: { selector: '//td[contains(@class,"oc-table-data-cell-owner")]//span[@data-test-user-name="%s"]', locateStrategy: 'xpath' }, + syncEnabled: { + selector: '/ancestor::tr//span[contains(@class,"sync-enabled")]', + locateStrategy: 'xpath' + }, sharedFrom: { // ugly hack: oc-avatar has a parent div.oc-avatars, which is also matched by `contains(@class, 'oc-avatar')`. // to solve this we try matching on the class surrounded by blanks, which is not matching the oc-avatars anymore. diff --git a/tests/acceptance/stepDefinitions/sharingContext.js b/tests/acceptance/stepDefinitions/sharingContext.js index 4065ec2385a..827f015eb5b 100644 --- a/tests/acceptance/stepDefinitions/sharingContext.js +++ b/tests/acceptance/stepDefinitions/sharingContext.js @@ -809,7 +809,7 @@ When( 'the user declines share {string} offered by user {string} using the webUI', async function (filename, user) { await client.pause(200) - return client.page.sharedWithMePage().declineAcceptFile('Decline', filename, user) + return client.page.FilesPageElement.filesList().declineShare(filename) } ) @@ -817,7 +817,7 @@ When( 'the user accepts share {string} offered by user {string} using the webUI', async function (filename, user) { await client.pause(200) - return client.page.sharedWithMePage().declineAcceptFile('Accept', filename, user) + return client.page.FilesPageElement.filesList().acceptShare(filename) } ) diff --git a/tests/e2e/cucumber/features/smoke/share.feature b/tests/e2e/cucumber/features/smoke/share.feature index 570e9d1d173..5f5215f994b 100644 --- a/tests/e2e/cucumber/features/smoke/share.feature +++ b/tests/e2e/cucumber/features/smoke/share.feature @@ -36,7 +36,7 @@ Feature: share And "Brian" declines the following share | name | | shared_folder | - Then "Brian" should not be able to open the folder "shared_folder" + Then "Brian" should not see a sync status for the folder "shared_folder" When "Brian" accepts the following share from the context menu | name | | shared_folder | @@ -99,7 +99,7 @@ Feature: share And "Brian" opens the "files" app And "Brian" navigates to the shared with me page - Then "Brian" should not be able to open the file "shareToBrian.txt" + Then "Brian" should not see a sync status for the folder "shareToBrian.txt" When "Brian" accepts the following share | name | | shareToBrian.txt | @@ -109,7 +109,7 @@ Feature: share And "Brian" declines the following share | name | | sharedFile.txt | - Then "Brian" should not be able to open the file "sharedFile.txt" + Then "Brian" should not see a sync status for the folder "sharedFile.txt" When "Brian" accepts the following share from the context menu | name | | sharedFile.txt | diff --git a/tests/e2e/cucumber/steps/ui/shares.ts b/tests/e2e/cucumber/steps/ui/shares.ts index bc0f6ab6424..73c1a0fe15e 100644 --- a/tests/e2e/cucumber/steps/ui/shares.ts +++ b/tests/e2e/cucumber/steps/ui/shares.ts @@ -202,6 +202,22 @@ When( } ) +When( + /"([^"]*)" (should|should not) see a sync status for the (folder|file) "([^"]*)"?$/, + async function ( + this: World, + stepUser: string, + condition: string, + _: string, + resource: string + ): Promise { + const shouldSee = condition === 'should' + const { page } = this.actorsEnvironment.getActor({ key: stepUser }) + const shareObject = new objects.applicationFiles.Share({ page }) + expect(await shareObject.resourceIsSynced(resource)).toBe(shouldSee) + } +) + Then( /"([^"]*)" (should|should not) be able to see the following shares$/, async function ( diff --git a/tests/e2e/support/objects/app-files/share/actions.ts b/tests/e2e/support/objects/app-files/share/actions.ts index 298246ca743..938d59081d8 100644 --- a/tests/e2e/support/objects/app-files/share/actions.ts +++ b/tests/e2e/support/objects/app-files/share/actions.ts @@ -7,10 +7,6 @@ import { copyLinkArgs, clearCurrentPopup } from '../link/actions' import { config } from '../../../../config.js' import { createdLinkStore } from '../../../store' -const filesSharedWithMeAccepted = - '#files-shared-with-me-accepted-section [data-test-resource-name="%s"]' -const shareAcceptDeclineButton = - '//*[@data-test-resource-name="%s"]/ancestor::tr//button[contains(@class, "file-row-share-%s")]' const quickShareButton = '//*[@data-test-resource-name="%s"]/ancestor::tr//button[contains(@class, "files-quick-action-collaborators")]' const noPermissionToShareLabel = @@ -19,14 +15,11 @@ const actionMenuDropdownButton = '//*[@data-test-resource-name="%s"]/ancestor::tr//button[contains(@class, "resource-table-btn-action-dropdown")]' const actionsTriggerButton = '//*[@data-test-resource-name="%s"]/ancestor::tr//button[contains(@class, "oc-files-actions-%s-trigger")]' -const filesSharedWithMeDeclined = - '#files-shared-with-me-declined-section [data-test-resource-name="%s"]' const publicLinkInputField = '//h4[contains(@class, "oc-files-file-link-name") and text()="%s"]' + '/following-sibling::div//p[contains(@class,"oc-files-file-link-url")]' -const showAllButton = '#files-shared-with-me-pending-section #files-shared-with-me-show-all' -const selecAllCheckbox = '#files-shared-with-me-pending-section #resource-table-select-all' +const selecAllCheckbox = '#resource-table-select-all' const acceptButton = '.oc-files-actions-accept-share-trigger' const pendingShareItem = '//div[@id="files-shared-with-me-pending-section"]//tr[contains(@class,"oc-tbody-tr")]' @@ -83,27 +76,11 @@ export interface ShareStatusArgs extends Omit { } export const acceptShare = async (args: ShareStatusArgs): Promise => { - const { resource, via, page } = args - if (via === 'CONTEXT_MENU') { - await clickActionInContextMenu({ page, resource }, 'accept-share') - } else { - await Promise.all([ - page.waitForResponse( - (resp) => - resp.url().includes('shares') && - resp.status() === 200 && - resp.request().method() === 'POST' - ), - page.locator(util.format(shareAcceptDeclineButton, resource, 'status-accept')).click() - ]) - } - await page.locator(util.format(filesSharedWithMeAccepted, resource)).waitFor() + const { resource, page } = args + await clickActionInContextMenu({ page, resource }, 'accept-share') } export const acceptAllShare = async ({ page }: { page: Page }): Promise => { - if (await page.locator(showAllButton).isVisible()) { - await page.locator(showAllButton).click() - } await page.locator(selecAllCheckbox).click() const numberOfPendingShares = await page.locator(pendingShareItem).count() const checkResponses = [] @@ -122,21 +99,8 @@ export const acceptAllShare = async ({ page }: { page: Page }): Promise => } export const declineShare = async (args: ShareStatusArgs): Promise => { - const { page, resource, via } = args - if (via === 'CONTEXT_MENU') { - await clickActionInContextMenu({ page, resource }, 'decline-share') - } else { - await Promise.all([ - page.waitForResponse( - (resp) => - resp.url().includes('shares') && - resp.status() === 200 && - resp.request().method() === 'DELETE' - ), - page.locator(util.format(shareAcceptDeclineButton, resource, 'decline')).click() - ]) - } - await page.locator(util.format(filesSharedWithMeDeclined, resource)).waitFor() + const { page, resource } = args + await clickActionInContextMenu({ page, resource }, 'decline-share') } export const clickActionInContextMenu = async ( diff --git a/tests/e2e/support/objects/app-files/share/index.ts b/tests/e2e/support/objects/app-files/share/index.ts index 514c50e2315..f47410dd4a7 100644 --- a/tests/e2e/support/objects/app-files/share/index.ts +++ b/tests/e2e/support/objects/app-files/share/index.ts @@ -1,6 +1,6 @@ import { Page } from 'playwright' import * as po from './actions' -import { resourceIsNotOpenable, isAcceptedSharePresent } from './utils' +import { resourceIsNotOpenable, isAcceptedSharePresent, resourceIsSynced } from './utils' import { copyLinkArgs } from '../link/actions' export class Share { #page: Page @@ -62,6 +62,10 @@ export class Share { return await resourceIsNotOpenable({ page: this.#page, resource }) } + async resourceIsSynced(resource): Promise { + return await resourceIsSynced({ page: this.#page, resource }) + } + async setDenyShare(args: Omit): Promise { const startUrl = this.#page.url() await po.setDenyShare({ ...args, page: this.#page }) diff --git a/tests/e2e/support/objects/app-files/share/utils.ts b/tests/e2e/support/objects/app-files/share/utils.ts index 0bac497c99e..044fb8ef749 100644 --- a/tests/e2e/support/objects/app-files/share/utils.ts +++ b/tests/e2e/support/objects/app-files/share/utils.ts @@ -4,6 +4,8 @@ import util from 'util' const acceptedShareItem = '//*[@data-test-resource-name="%s"]/ancestor::tr//span[@data-test-user-name="%s"]' const itemSelector = '.files-table [data-test-resource-name="%s"]' +const syncEnabled = + '//*[@data-test-resource-name="%s"]//ancestor::tr//span[contains(@class, "sync-enabled")]' export const resourceIsNotOpenable = async ({ page, @@ -24,6 +26,16 @@ export const resourceIsNotOpenable = async ({ } } +export const resourceIsSynced = ({ + page, + resource +}: { + page: Page + resource: string +}): Promise => { + return page.locator(util.format(syncEnabled, resource)).isVisible() +} + export const isAcceptedSharePresent = async ({ page, resource, From f0f837980edcdc6aa0487799d9d1fd034e4bce93 Mon Sep 17 00:00:00 2001 From: Jannik Stehle Date: Thu, 19 Oct 2023 12:25:59 +0200 Subject: [PATCH 07/13] do not allow decline action on pending shares --- .../actions/files/useFileActionsDeclineShare.ts | 3 ++- tests/e2e/cucumber/features/smoke/share.feature | 10 ++-------- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/packages/web-pkg/src/composables/actions/files/useFileActionsDeclineShare.ts b/packages/web-pkg/src/composables/actions/files/useFileActionsDeclineShare.ts index bd2dd6e0ffc..4e7ca3d290f 100644 --- a/packages/web-pkg/src/composables/actions/files/useFileActionsDeclineShare.ts +++ b/packages/web-pkg/src/composables/actions/files/useFileActionsDeclineShare.ts @@ -107,8 +107,9 @@ export const useFileActionsDeclineShare = ({ store }: { store?: Store } = { return false } + // decline (= unsync) is only available for accepted (= synced) shares const declineDisabled = resources.some((resource) => { - return resource.status === ShareStatus.declined + return resource.status !== ShareStatus.accepted }) return !declineDisabled }, diff --git a/tests/e2e/cucumber/features/smoke/share.feature b/tests/e2e/cucumber/features/smoke/share.feature index 5f5215f994b..428d6ea2c45 100644 --- a/tests/e2e/cucumber/features/smoke/share.feature +++ b/tests/e2e/cucumber/features/smoke/share.feature @@ -33,9 +33,6 @@ Feature: share | name | | folder_to_shared | | folder_to_customShared | - And "Brian" declines the following share - | name | - | shared_folder | Then "Brian" should not see a sync status for the folder "shared_folder" When "Brian" accepts the following share from the context menu | name | @@ -99,17 +96,14 @@ Feature: share And "Brian" opens the "files" app And "Brian" navigates to the shared with me page - Then "Brian" should not see a sync status for the folder "shareToBrian.txt" + Then "Brian" should not see a sync status for the file "shareToBrian.txt" When "Brian" accepts the following share | name | | shareToBrian.txt | | shareToBrian.md | | testavatar.jpeg | | simple.pdf | - And "Brian" declines the following share - | name | - | sharedFile.txt | - Then "Brian" should not see a sync status for the folder "sharedFile.txt" + Then "Brian" should not see a sync status for the file "sharedFile.txt" When "Brian" accepts the following share from the context menu | name | | sharedFile.txt | From d4a3373a61877b19ded0c6312fd0c2ef945491a1 Mon Sep 17 00:00:00 2001 From: Jannik Stehle Date: Thu, 26 Oct 2023 11:03:35 +0200 Subject: [PATCH 08/13] feat: rename hide to hidden, use PUT for the request to set it --- packages/web-client/src/helpers/share/functions.ts | 2 +- .../actions/files/useFileActionsAcceptShare.ts | 1 - .../actions/files/useFileActionsDeclineShare.ts | 1 - .../actions/files/useFileActionsToggleHideShare.ts | 13 ++++++------- .../src/helpers/share/triggerShareAction.ts | 14 +++++++++----- 5 files changed, 16 insertions(+), 15 deletions(-) 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' From c213c8f8c3687e9dd3db11e7fa1988a0991cba7c Mon Sep 17 00:00:00 2001 From: Jannik Stehle Date: Thu, 26 Oct 2023 17:21:03 +0200 Subject: [PATCH 09/13] foo --- .../web-app-files/src/components/Shares/SharedWithMeSection.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/web-app-files/src/components/Shares/SharedWithMeSection.vue b/packages/web-app-files/src/components/Shares/SharedWithMeSection.vue index d81d4a8d8c5..b52e7504583 100644 --- a/packages/web-app-files/src/components/Shares/SharedWithMeSection.vue +++ b/packages/web-app-files/src/components/Shares/SharedWithMeSection.vue @@ -42,7 +42,7 @@ From e1ea875ae06fdc27a6c7bb18e391418399a701ff Mon Sep 17 00:00:00 2001 From: Jannik Stehle Date: Fri, 27 Oct 2023 11:18:45 +0200 Subject: [PATCH 10/13] fix: center no-content-message for shared-with-me-section --- .../src/components/Shares/SharedWithMeSection.vue | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/packages/web-app-files/src/components/Shares/SharedWithMeSection.vue b/packages/web-app-files/src/components/Shares/SharedWithMeSection.vue index b52e7504583..e3df3b308a3 100644 --- a/packages/web-app-files/src/components/Shares/SharedWithMeSection.vue +++ b/packages/web-app-files/src/components/Shares/SharedWithMeSection.vue @@ -5,11 +5,7 @@ ({{ items.length }}) - + From 1aa63cb34dd492669e7a2c028977556e756d0aaa Mon Sep 17 00:00:00 2001 From: Jannik Stehle Date: Fri, 27 Oct 2023 11:19:17 +0200 Subject: [PATCH 11/13] feat: add action to hide shares to context menu --- packages/web-pkg/src/components/FilesList/ContextActions.vue | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/web-pkg/src/components/FilesList/ContextActions.vue b/packages/web-pkg/src/components/FilesList/ContextActions.vue index 58123b10b8e..9fc8d86e027 100644 --- a/packages/web-pkg/src/components/FilesList/ContextActions.vue +++ b/packages/web-pkg/src/components/FilesList/ContextActions.vue @@ -5,7 +5,7 @@