From 0931a4086b88490e9d631c676e1adf6b76b96a72 Mon Sep 17 00:00:00 2001 From: Jacob Noah Date: Fri, 12 Jan 2024 15:47:02 +0100 Subject: [PATCH 1/6] migrating resourceTiles to web-pkg --- .../useResourcesViewDefaults.ts | 2 +- .../web-app-files/src/helpers/ui/index.ts | 1 - .../src/views/spaces/GenericSpace.vue | 2 +- .../src/views/spaces/Projects.vue | 4 +- .../__snapshots__/ResourceTiles.spec.ts.snap | 41 ------------------- .../components/FilesList/ResourceTiles.vue | 20 ++++----- .../src/helpers/ui/resourceTiles.ts | 2 +- .../FilesList/ResourceTiles.spec.ts | 4 +- 8 files changed, 16 insertions(+), 60 deletions(-) delete mode 100644 packages/web-app-files/tests/unit/components/FilesList/__snapshots__/ResourceTiles.spec.ts.snap rename packages/{web-app-files => web-pkg}/src/components/FilesList/ResourceTiles.vue (97%) rename packages/{web-app-files => web-pkg}/src/helpers/ui/resourceTiles.ts (96%) rename packages/{web-app-files => web-pkg}/tests/unit/components/FilesList/ResourceTiles.spec.ts (97%) diff --git a/packages/web-app-files/src/composables/resourcesViewDefaults/useResourcesViewDefaults.ts b/packages/web-app-files/src/composables/resourcesViewDefaults/useResourcesViewDefaults.ts index b778399f0c0..1c3bb4ad674 100644 --- a/packages/web-app-files/src/composables/resourcesViewDefaults/useResourcesViewDefaults.ts +++ b/packages/web-app-files/src/composables/resourcesViewDefaults/useResourcesViewDefaults.ts @@ -11,7 +11,7 @@ import { useStore } from '@ownclouders/web-pkg' import { determineSortFields as determineResourceTableSortFields } from '@ownclouders/web-pkg' -import { determineSortFields as determineResourceTilesSortFields } from '../../helpers/ui/resourceTiles' +import { determineSortFields as determineResourceTilesSortFields } from '@ownclouders/web-pkg/src/helpers/ui/resourceTiles' import { Task } from 'vue-concurrency' import { Resource } from '@ownclouders/web-client' import { useSelectedResources, SelectedResourcesResult } from '@ownclouders/web-pkg' diff --git a/packages/web-app-files/src/helpers/ui/index.ts b/packages/web-app-files/src/helpers/ui/index.ts index 50e6d766a79..10d773d27d5 100644 --- a/packages/web-app-files/src/helpers/ui/index.ts +++ b/packages/web-app-files/src/helpers/ui/index.ts @@ -1,2 +1 @@ export * as fileList from './filesList' -export * as resourceTiles from './resourceTiles' diff --git a/packages/web-app-files/src/views/spaces/GenericSpace.vue b/packages/web-app-files/src/views/spaces/GenericSpace.vue index 04344882879..33ab3abee93 100644 --- a/packages/web-app-files/src/views/spaces/GenericSpace.vue +++ b/packages/web-app-files/src/views/spaces/GenericSpace.vue @@ -206,7 +206,7 @@ import ListInfo from '../../components/FilesList/ListInfo.vue' import NotFoundMessage from '../../components/FilesList/NotFoundMessage.vue' import QuickActions from '../../components/FilesList/QuickActions.vue' import ResourceDetails from '../../components/FilesList/ResourceDetails.vue' -import ResourceTiles from '../../components/FilesList/ResourceTiles.vue' +import ResourceTiles from '@ownclouders/web-pkg/src/components/FilesList/ResourceTiles.vue' import SpaceHeader from '../../components/Spaces/SpaceHeader.vue' import WhitespaceContextMenu from 'web-app-files/src/components/Spaces/WhitespaceContextMenu.vue' import { eventBus } from '@ownclouders/web-pkg' diff --git a/packages/web-app-files/src/views/spaces/Projects.vue b/packages/web-app-files/src/views/spaces/Projects.vue index 9d1df547feb..db08ad9d88b 100644 --- a/packages/web-app-files/src/views/spaces/Projects.vue +++ b/packages/web-app-files/src/views/spaces/Projects.vue @@ -206,14 +206,14 @@ import { SpaceResource } from '@ownclouders/web-client/src/helpers' import FilesViewWrapper from '../../components/FilesViewWrapper.vue' -import ResourceTiles from '../../components/FilesList/ResourceTiles.vue' +import ResourceTiles from '@ownclouders/web-pkg/src/components/FilesList/ResourceTiles.vue' import { ResourceTable } from '@ownclouders/web-pkg' import { eventBus } from '@ownclouders/web-pkg' import { SideBarEventTopics, useSideBar } from '@ownclouders/web-pkg' import { WebDAV } from '@ownclouders/web-client/src/webdav' import { useScrollTo } from '@ownclouders/web-pkg' import { useSelectedResources } from '@ownclouders/web-pkg' -import { sortFields as availableSortFields } from '../../helpers/ui/resourceTiles' +import { sortFields as availableSortFields } from '@ownclouders/web-pkg/src/helpers/ui/resourceTiles' import { defaultFuseOptions, formatFileSize, ResourceIcon } from '@ownclouders/web-pkg' import { useGettext } from 'vue3-gettext' import { diff --git a/packages/web-app-files/tests/unit/components/FilesList/__snapshots__/ResourceTiles.spec.ts.snap b/packages/web-app-files/tests/unit/components/FilesList/__snapshots__/ResourceTiles.spec.ts.snap deleted file mode 100644 index 9db57a99c1e..00000000000 --- a/packages/web-app-files/tests/unit/components/FilesList/__snapshots__/ResourceTiles.spec.ts.snap +++ /dev/null @@ -1,41 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`ResourceTiles component renders a footer slot 1`] = ` -
- - - - -
-`; - -exports[`ResourceTiles component renders an array of spaces correctly 1`] = ` -
- - -
  • - -
  • -
  • - -
  • - - - - - -
    - - -
    -`; diff --git a/packages/web-app-files/src/components/FilesList/ResourceTiles.vue b/packages/web-pkg/src/components/FilesList/ResourceTiles.vue similarity index 97% rename from packages/web-app-files/src/components/FilesList/ResourceTiles.vue rename to packages/web-pkg/src/components/FilesList/ResourceTiles.vue index 2990ca41d9f..37c367dc97d 100644 --- a/packages/web-app-files/src/components/FilesList/ResourceTiles.vue +++ b/packages/web-pkg/src/components/FilesList/ResourceTiles.vue @@ -123,23 +123,21 @@ import { Resource, SpaceResource } from '@ownclouders/web-client' // Constants should match what is being used in OcTable/ResourceTable // Alignment regarding naming would be an API-breaking change and can // Be done at a later point in time? +import { ContextMenuQuickAction } from '../ContextActions' +import { createLocationSpaces } from '../../router' +import { createFileRouteOptions, displayPositionedDropdown } from '../../helpers' +import { eventBus } from '../../services' +import { ImageDimension } from '../../constants' +import { ResourceTile, ResourceGhostElement } from './index' import { - ContextMenuQuickAction, - createFileRouteOptions, - createLocationSpaces, - displayPositionedDropdown, - eventBus, - ImageDimension, + ViewModeConstants, SortDir, SortField, useMessages, useResourceRouteResolver, useStore, - useTileSize, - ViewModeConstants, - ResourceGhostElement, - ResourceTile -} from '@ownclouders/web-pkg' + useTileSize +} from '../../composables' export default defineComponent({ name: 'ResourceTiles', diff --git a/packages/web-app-files/src/helpers/ui/resourceTiles.ts b/packages/web-pkg/src/helpers/ui/resourceTiles.ts similarity index 96% rename from packages/web-app-files/src/helpers/ui/resourceTiles.ts rename to packages/web-pkg/src/helpers/ui/resourceTiles.ts index 7862cecb801..28ad7e45749 100644 --- a/packages/web-app-files/src/helpers/ui/resourceTiles.ts +++ b/packages/web-pkg/src/helpers/ui/resourceTiles.ts @@ -1,4 +1,4 @@ -import { SortDir, SortField } from '@ownclouders/web-pkg' +import { SortDir, SortField } from '../../composables' // just a dummy function to trick gettext tools function $gettext(msg) { diff --git a/packages/web-app-files/tests/unit/components/FilesList/ResourceTiles.spec.ts b/packages/web-pkg/tests/unit/components/FilesList/ResourceTiles.spec.ts similarity index 97% rename from packages/web-app-files/tests/unit/components/FilesList/ResourceTiles.spec.ts rename to packages/web-pkg/tests/unit/components/FilesList/ResourceTiles.spec.ts index 6d8524c2ae8..590e2cad254 100644 --- a/packages/web-app-files/tests/unit/components/FilesList/ResourceTiles.spec.ts +++ b/packages/web-pkg/tests/unit/components/FilesList/ResourceTiles.spec.ts @@ -1,6 +1,6 @@ import { createStore, defaultPlugins, defaultStoreMockOptions, mount } from 'web-test-helpers' -import ResourceTiles from 'web-app-files/src/components/FilesList/ResourceTiles.vue' -import { sortFields } from 'web-app-files/src/helpers/ui/resourceTiles' +import ResourceTiles from '../../../../src/components/FilesList/ResourceTiles.vue' +import { sortFields } from '../../../../src/helpers/ui/resourceTiles' import { Resource } from '@ownclouders/web-client' import { mock } from 'jest-mock-extended' jest.mock('@ownclouders/web-pkg', () => ({ From bc3f68489724bbece88387e92ce02c7b59df7285 Mon Sep 17 00:00:00 2001 From: Jannik Stehle Date: Mon, 15 Jan 2024 11:37:53 +0100 Subject: [PATCH 2/6] test: fix unit tests --- .../FilesList/ResourceTiles.spec.ts | 5 ++- .../__snapshots__/ResourceTiles.spec.ts.snap | 41 +++++++++++++++++++ 2 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 packages/web-pkg/tests/unit/components/FilesList/__snapshots__/ResourceTiles.spec.ts.snap diff --git a/packages/web-pkg/tests/unit/components/FilesList/ResourceTiles.spec.ts b/packages/web-pkg/tests/unit/components/FilesList/ResourceTiles.spec.ts index 590e2cad254..c8479c7022a 100644 --- a/packages/web-pkg/tests/unit/components/FilesList/ResourceTiles.spec.ts +++ b/packages/web-pkg/tests/unit/components/FilesList/ResourceTiles.spec.ts @@ -3,8 +3,9 @@ import ResourceTiles from '../../../../src/components/FilesList/ResourceTiles.vu import { sortFields } from '../../../../src/helpers/ui/resourceTiles' import { Resource } from '@ownclouders/web-client' import { mock } from 'jest-mock-extended' -jest.mock('@ownclouders/web-pkg', () => ({ - ...jest.requireActual('@ownclouders/web-pkg'), + +jest.mock('../../../../src/composables/viewMode', () => ({ + ...jest.requireActual('../../../../src/composables/viewMode'), useTileSize: jest.fn().mockReturnValue({ tileSizePixels: 100 }) diff --git a/packages/web-pkg/tests/unit/components/FilesList/__snapshots__/ResourceTiles.spec.ts.snap b/packages/web-pkg/tests/unit/components/FilesList/__snapshots__/ResourceTiles.spec.ts.snap new file mode 100644 index 00000000000..9db57a99c1e --- /dev/null +++ b/packages/web-pkg/tests/unit/components/FilesList/__snapshots__/ResourceTiles.spec.ts.snap @@ -0,0 +1,41 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`ResourceTiles component renders a footer slot 1`] = ` +
    + + + + +
    +`; + +exports[`ResourceTiles component renders an array of spaces correctly 1`] = ` +
    + + +
  • + +
  • +
  • + +
  • + + + + + +
    + + +
    +`; From 56b8cf8b096e0b9069331e94a75e7b24c5ace09a Mon Sep 17 00:00:00 2001 From: Jacob Noah Date: Mon, 15 Jan 2024 15:46:27 +0100 Subject: [PATCH 3/6] fixing migration resourceTiles to web-pkg --- .../resourcesViewDefaults/useResourcesViewDefaults.ts | 6 ++++-- packages/web-app-files/src/views/spaces/GenericSpace.vue | 2 +- packages/web-app-files/src/views/spaces/Projects.vue | 2 +- packages/web-pkg/src/components/FilesList/ResourceTable.vue | 4 ++-- packages/web-pkg/src/components/FilesList/index.ts | 1 + packages/web-pkg/src/helpers/ui/index.ts | 1 + packages/web-pkg/src/helpers/ui/resourceTable.ts | 2 +- packages/web-pkg/src/helpers/ui/resourceTiles.ts | 2 +- 8 files changed, 12 insertions(+), 8 deletions(-) diff --git a/packages/web-app-files/src/composables/resourcesViewDefaults/useResourcesViewDefaults.ts b/packages/web-app-files/src/composables/resourcesViewDefaults/useResourcesViewDefaults.ts index 1c3bb4ad674..366a908a60c 100644 --- a/packages/web-app-files/src/composables/resourcesViewDefaults/useResourcesViewDefaults.ts +++ b/packages/web-app-files/src/composables/resourcesViewDefaults/useResourcesViewDefaults.ts @@ -10,8 +10,10 @@ import { useRouteQuery, useStore } from '@ownclouders/web-pkg' -import { determineSortFields as determineResourceTableSortFields } from '@ownclouders/web-pkg' -import { determineSortFields as determineResourceTilesSortFields } from '@ownclouders/web-pkg/src/helpers/ui/resourceTiles' +import { + determineResourceTableSortFields, + determineResourceTilesSortFields +} from '@ownclouders/web-pkg' import { Task } from 'vue-concurrency' import { Resource } from '@ownclouders/web-client' import { useSelectedResources, SelectedResourcesResult } from '@ownclouders/web-pkg' diff --git a/packages/web-app-files/src/views/spaces/GenericSpace.vue b/packages/web-app-files/src/views/spaces/GenericSpace.vue index 33ab3abee93..685bc830a3c 100644 --- a/packages/web-app-files/src/views/spaces/GenericSpace.vue +++ b/packages/web-app-files/src/views/spaces/GenericSpace.vue @@ -206,7 +206,7 @@ import ListInfo from '../../components/FilesList/ListInfo.vue' import NotFoundMessage from '../../components/FilesList/NotFoundMessage.vue' import QuickActions from '../../components/FilesList/QuickActions.vue' import ResourceDetails from '../../components/FilesList/ResourceDetails.vue' -import ResourceTiles from '@ownclouders/web-pkg/src/components/FilesList/ResourceTiles.vue' +import { ResourceTiles } from '@ownclouders/web-pkg' import SpaceHeader from '../../components/Spaces/SpaceHeader.vue' import WhitespaceContextMenu from 'web-app-files/src/components/Spaces/WhitespaceContextMenu.vue' import { eventBus } from '@ownclouders/web-pkg' diff --git a/packages/web-app-files/src/views/spaces/Projects.vue b/packages/web-app-files/src/views/spaces/Projects.vue index db08ad9d88b..a799970fdf9 100644 --- a/packages/web-app-files/src/views/spaces/Projects.vue +++ b/packages/web-app-files/src/views/spaces/Projects.vue @@ -213,7 +213,7 @@ import { SideBarEventTopics, useSideBar } from '@ownclouders/web-pkg' import { WebDAV } from '@ownclouders/web-client/src/webdav' import { useScrollTo } from '@ownclouders/web-pkg' import { useSelectedResources } from '@ownclouders/web-pkg' -import { sortFields as availableSortFields } from '@ownclouders/web-pkg/src/helpers/ui/resourceTiles' +import { sortFields as availableSortFields } from '@ownclouders/web-pkg' import { defaultFuseOptions, formatFileSize, ResourceIcon } from '@ownclouders/web-pkg' import { useGettext } from 'vue3-gettext' import { diff --git a/packages/web-pkg/src/components/FilesList/ResourceTable.vue b/packages/web-pkg/src/components/FilesList/ResourceTable.vue index e11dedd4fa3..0fff6511f42 100644 --- a/packages/web-pkg/src/components/FilesList/ResourceTable.vue +++ b/packages/web-pkg/src/components/FilesList/ResourceTable.vue @@ -251,7 +251,7 @@ import ContextMenuQuickAction from '../ContextActions/ContextMenuQuickAction.vue import { useResourceRouteResolver } from '../../composables/filesList/useResourceRouteResolver' import { ClipboardActions } from '../../helpers/clipboardActions' -import { determineSortFields } from '../../helpers/ui/resourceTable' +import { determineResourceTableSortFields } from '../../helpers' import { useFileActionsRename } from '../../composables/actions' import { createLocationCommon } from '../../router' import get from 'lodash-es/get' @@ -545,7 +545,7 @@ export default defineComponent({ }) } - const sortFields = determineSortFields(firstResource) + const sortFields = determineResourceTableSortFields(firstResource) fields.push( ...[ { diff --git a/packages/web-pkg/src/components/FilesList/index.ts b/packages/web-pkg/src/components/FilesList/index.ts index 2cf910c4a8e..166229ced75 100644 --- a/packages/web-pkg/src/components/FilesList/index.ts +++ b/packages/web-pkg/src/components/FilesList/index.ts @@ -4,6 +4,7 @@ export { default as ResourceTable } from './ResourceTable.vue' export { default as ResourceListItem } from './ResourceListItem.vue' export { default as ResourceIcon } from './ResourceIcon.vue' export { default as ResourceTile } from './ResourceTile.vue' +export { default as ResourceTiles } from './ResourceTiles.vue' export { default as ResourceLink } from './ResourceLink.vue' export { default as ResourceName } from './ResourceName.vue' export { default as ResourceSize } from './ResourceSize.vue' diff --git a/packages/web-pkg/src/helpers/ui/index.ts b/packages/web-pkg/src/helpers/ui/index.ts index f852ecdd499..9dd34de416a 100644 --- a/packages/web-pkg/src/helpers/ui/index.ts +++ b/packages/web-pkg/src/helpers/ui/index.ts @@ -1 +1,2 @@ export * from './resourceTable' +export * from './resourceTiles' diff --git a/packages/web-pkg/src/helpers/ui/resourceTable.ts b/packages/web-pkg/src/helpers/ui/resourceTable.ts index 81a24fea610..197a3796c34 100644 --- a/packages/web-pkg/src/helpers/ui/resourceTable.ts +++ b/packages/web-pkg/src/helpers/ui/resourceTable.ts @@ -1,6 +1,6 @@ import { SortDir, SortField } from '../../composables/sort' -export const determineSortFields = (firstResource): SortField[] => { +export const determineResourceTableSortFields = (firstResource): SortField[] => { if (!firstResource) { return [] } diff --git a/packages/web-pkg/src/helpers/ui/resourceTiles.ts b/packages/web-pkg/src/helpers/ui/resourceTiles.ts index 28ad7e45749..f1087369d07 100644 --- a/packages/web-pkg/src/helpers/ui/resourceTiles.ts +++ b/packages/web-pkg/src/helpers/ui/resourceTiles.ts @@ -65,7 +65,7 @@ export const sortFields: SortField[] = [ } ] -export const determineSortFields = (firstResource): SortField[] => { +export const determineResourceTilesSortFields = (firstResource): SortField[] => { if (!firstResource) { return [] } From 433ef17a555bfc5b4d0fec85e3b0cd2594daaa12 Mon Sep 17 00:00:00 2001 From: Jacob Noah Date: Mon, 15 Jan 2024 15:49:57 +0100 Subject: [PATCH 4/6] fixing import resource tiles in projects --- packages/web-app-files/src/views/spaces/Projects.vue | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/web-app-files/src/views/spaces/Projects.vue b/packages/web-app-files/src/views/spaces/Projects.vue index a799970fdf9..ef0e88050bc 100644 --- a/packages/web-app-files/src/views/spaces/Projects.vue +++ b/packages/web-app-files/src/views/spaces/Projects.vue @@ -206,8 +206,7 @@ import { SpaceResource } from '@ownclouders/web-client/src/helpers' import FilesViewWrapper from '../../components/FilesViewWrapper.vue' -import ResourceTiles from '@ownclouders/web-pkg/src/components/FilesList/ResourceTiles.vue' -import { ResourceTable } from '@ownclouders/web-pkg' +import { ResourceTable, ResourceTiles } from '@ownclouders/web-pkg' import { eventBus } from '@ownclouders/web-pkg' import { SideBarEventTopics, useSideBar } from '@ownclouders/web-pkg' import { WebDAV } from '@ownclouders/web-client/src/webdav' From 91019fbeca3ac6ad556452009dee75b502fe01ab Mon Sep 17 00:00:00 2001 From: Jacob Noah Date: Tue, 16 Jan 2024 13:33:05 +0100 Subject: [PATCH 5/6] fixed sort import paths --- packages/web-pkg/src/helpers/ui/resourceTiles.ts | 2 +- packages/web-pkg/tests/unit/composables/sort/useSort.spec.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/web-pkg/src/helpers/ui/resourceTiles.ts b/packages/web-pkg/src/helpers/ui/resourceTiles.ts index f1087369d07..90596b90834 100644 --- a/packages/web-pkg/src/helpers/ui/resourceTiles.ts +++ b/packages/web-pkg/src/helpers/ui/resourceTiles.ts @@ -1,4 +1,4 @@ -import { SortDir, SortField } from '../../composables' +import { SortDir, SortField } from '../../composables/sort' // just a dummy function to trick gettext tools function $gettext(msg) { diff --git a/packages/web-pkg/tests/unit/composables/sort/useSort.spec.ts b/packages/web-pkg/tests/unit/composables/sort/useSort.spec.ts index e50e7a629a3..25bb47e5161 100644 --- a/packages/web-pkg/tests/unit/composables/sort/useSort.spec.ts +++ b/packages/web-pkg/tests/unit/composables/sort/useSort.spec.ts @@ -1,5 +1,5 @@ import { ref, unref } from 'vue' -import { SortDir, SortOptions, useSort } from '../../../../src/composables/sort' +import { SortDir, SortOptions, useSort } from '../../../../src/composables' import { Resource } from '@ownclouders/web-client/src/helpers/resource' import { getComposableWrapper } from 'web-test-helpers' From 096f5c0d99cdbcfd3881bb5f02d9be9a4a08cdb4 Mon Sep 17 00:00:00 2001 From: Jannik Stehle Date: Tue, 23 Jan 2024 07:52:03 +0100 Subject: [PATCH 6/6] test: fix unit tests --- packages/web-pkg/src/components/FilesList/ResourceTable.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/web-pkg/src/components/FilesList/ResourceTable.vue b/packages/web-pkg/src/components/FilesList/ResourceTable.vue index a5775291bf7..f1ce8c6747e 100644 --- a/packages/web-pkg/src/components/FilesList/ResourceTable.vue +++ b/packages/web-pkg/src/components/FilesList/ResourceTable.vue @@ -249,7 +249,7 @@ import ContextMenuQuickAction from '../ContextActions/ContextMenuQuickAction.vue import { useResourceRouteResolver } from '../../composables/filesList/useResourceRouteResolver' import { ClipboardActions } from '../../helpers/clipboardActions' -import { determineResourceTableSortFields } from '../../helpers' +import { determineResourceTableSortFields } from '../../helpers/ui/resourceTable' import { useFileActionsRename } from '../../composables/actions' import { createLocationCommon } from '../../router' import get from 'lodash-es/get'