From af742df3d23120be003fe71e9d90eb6a503357ac Mon Sep 17 00:00:00 2001 From: Jannik Stehle Date: Wed, 20 Nov 2024 10:23:14 +0100 Subject: [PATCH] refactor: move folder loaders to web-pkg Moves the folder loaders from the files app to `web-pkg` so they can be used from other packages. --- .../useResourcesViewDefaults.ts | 4 ++-- .../src/views/spaces/GenericSpace.vue | 4 ++-- .../src/services/folder/folderService.ts} | 8 +++----- packages/web-pkg/src/services/folder/index.ts | 2 ++ .../src/services/folder/loaders}/index.ts | 0 .../services/folder/loaders}/loaderFavorites.ts | 4 ++-- .../folder/loaders}/loaderSharedViaLink.ts | 4 ++-- .../services/folder/loaders}/loaderSharedWithMe.ts | 4 ++-- .../folder/loaders}/loaderSharedWithOthers.ts | 4 ++-- .../src/services/folder/loaders}/loaderSpace.ts | 14 ++++---------- .../src/services/folder/loaders}/loaderTrashbin.ts | 4 ++-- .../src/services/folder/loaders}/types.ts | 0 packages/web-pkg/src/services/index.ts | 1 + 13 files changed, 24 insertions(+), 29 deletions(-) rename packages/{web-app-files/src/services/folder.ts => web-pkg/src/services/folder/folderService.ts} (94%) create mode 100644 packages/web-pkg/src/services/folder/index.ts rename packages/{web-app-files/src/services/folder => web-pkg/src/services/folder/loaders}/index.ts (100%) rename packages/{web-app-files/src/services/folder => web-pkg/src/services/folder/loaders}/loaderFavorites.ts (93%) rename packages/{web-app-files/src/services/folder => web-pkg/src/services/folder/loaders}/loaderSharedViaLink.ts (95%) rename packages/{web-app-files/src/services/folder => web-pkg/src/services/folder/loaders}/loaderSharedWithMe.ts (95%) rename packages/{web-app-files/src/services/folder => web-pkg/src/services/folder/loaders}/loaderSharedWithOthers.ts (95%) rename packages/{web-app-files/src/services/folder => web-pkg/src/services/folder/loaders}/loaderSpace.ts (96%) rename packages/{web-app-files/src/services/folder => web-pkg/src/services/folder/loaders}/loaderTrashbin.ts (93%) rename packages/{web-app-files/src/services/folder => web-pkg/src/services/folder/loaders}/types.ts (100%) diff --git a/packages/web-app-files/src/composables/resourcesViewDefaults/useResourcesViewDefaults.ts b/packages/web-app-files/src/composables/resourcesViewDefaults/useResourcesViewDefaults.ts index edb9cbd0f69..9985e96bc23 100644 --- a/packages/web-app-files/src/composables/resourcesViewDefaults/useResourcesViewDefaults.ts +++ b/packages/web-app-files/src/composables/resourcesViewDefaults/useResourcesViewDefaults.ts @@ -1,5 +1,4 @@ import { nextTick, computed, unref, Ref } from 'vue' -import { folderService } from '../../services/folder' import { fileList } from '../../helpers/ui' import { usePagination, @@ -7,7 +6,8 @@ import { SortDir, SortField, useRouteName, - useResourcesStore + useResourcesStore, + folderService } from '@ownclouders/web-pkg' import { useSideBar } from '@ownclouders/web-pkg' import { queryItemAsString, useRouteQuery } 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 7c642d20cff..ccef01732ab 100644 --- a/packages/web-app-files/src/views/spaces/GenericSpace.vue +++ b/packages/web-app-files/src/views/spaces/GenericSpace.vue @@ -161,7 +161,8 @@ import { useOpenWithDefaultApp, useKeyboardActions, useRoute, - useRouteQuery + useRouteQuery, + FolderLoaderOptions } from '@ownclouders/web-pkg' import CreateAndUpload from '../../components/AppBar/CreateAndUpload.vue' import FilesViewWrapper from '../../components/FilesViewWrapper.vue' @@ -174,7 +175,6 @@ import SpaceHeader from '../../components/Spaces/SpaceHeader.vue' import WhitespaceContextMenu from '../../components/Spaces/WhitespaceContextMenu.vue' import { eventBus } from '@ownclouders/web-pkg' import { useResourcesViewDefaults } from '../../composables' -import { FolderLoaderOptions } from '../../services/folder' import { BreadcrumbItem } from '@ownclouders/design-system/helpers' import { v4 as uuidV4 } from 'uuid' import { diff --git a/packages/web-app-files/src/services/folder.ts b/packages/web-pkg/src/services/folder/folderService.ts similarity index 94% rename from packages/web-app-files/src/services/folder.ts rename to packages/web-pkg/src/services/folder/folderService.ts index 600f806eaf5..9b619f04c1d 100644 --- a/packages/web-app-files/src/services/folder.ts +++ b/packages/web-pkg/src/services/folder/folderService.ts @@ -17,9 +17,9 @@ import { useSharesStore, useAuthService, AuthServiceInterface -} from '@ownclouders/web-pkg' +} from '../../composables' import { unref } from 'vue' -import { ClientService } from '@ownclouders/web-pkg' +import { ClientService } from '../../services' import { FolderLoaderSpace, @@ -28,9 +28,7 @@ import { FolderLoaderSharedWithMe, FolderLoaderSharedWithOthers, FolderLoaderTrashbin -} from './folder/index' - -export * from './folder/types' +} from './loaders' export type FolderLoaderTask = any diff --git a/packages/web-pkg/src/services/folder/index.ts b/packages/web-pkg/src/services/folder/index.ts new file mode 100644 index 00000000000..47e467c1ab9 --- /dev/null +++ b/packages/web-pkg/src/services/folder/index.ts @@ -0,0 +1,2 @@ +export * from './folderService' +export * from './loaders' diff --git a/packages/web-app-files/src/services/folder/index.ts b/packages/web-pkg/src/services/folder/loaders/index.ts similarity index 100% rename from packages/web-app-files/src/services/folder/index.ts rename to packages/web-pkg/src/services/folder/loaders/index.ts diff --git a/packages/web-app-files/src/services/folder/loaderFavorites.ts b/packages/web-pkg/src/services/folder/loaders/loaderFavorites.ts similarity index 93% rename from packages/web-app-files/src/services/folder/loaderFavorites.ts rename to packages/web-pkg/src/services/folder/loaders/loaderFavorites.ts index 478283d42c8..953be1398cb 100644 --- a/packages/web-app-files/src/services/folder/loaderFavorites.ts +++ b/packages/web-pkg/src/services/folder/loaders/loaderFavorites.ts @@ -1,8 +1,8 @@ -import { FolderLoader, FolderLoaderTask, TaskContext } from '../folder' +import { FolderLoader, FolderLoaderTask, TaskContext } from '../folderService' import { Router } from 'vue-router' import { useTask } from 'vue-concurrency' import { buildResource } from '@ownclouders/web-client' -import { isLocationCommonActive } from '@ownclouders/web-pkg' +import { isLocationCommonActive } from '../../../router' export class FolderLoaderFavorites implements FolderLoader { public isEnabled(): boolean { diff --git a/packages/web-app-files/src/services/folder/loaderSharedViaLink.ts b/packages/web-pkg/src/services/folder/loaders/loaderSharedViaLink.ts similarity index 95% rename from packages/web-app-files/src/services/folder/loaderSharedViaLink.ts rename to packages/web-pkg/src/services/folder/loaders/loaderSharedViaLink.ts index d23626e335c..5b9a446a1d0 100644 --- a/packages/web-app-files/src/services/folder/loaderSharedViaLink.ts +++ b/packages/web-pkg/src/services/folder/loaders/loaderSharedViaLink.ts @@ -1,7 +1,7 @@ -import { FolderLoader, FolderLoaderTask, TaskContext } from '../folder' +import { FolderLoader, FolderLoaderTask, TaskContext } from '../folderService' import { Router } from 'vue-router' import { useTask } from 'vue-concurrency' -import { isLocationSharesActive } from '@ownclouders/web-pkg' +import { isLocationSharesActive } from '../../../router' import { buildOutgoingShareResource, call } from '@ownclouders/web-client' export class FolderLoaderSharedViaLink implements FolderLoader { diff --git a/packages/web-app-files/src/services/folder/loaderSharedWithMe.ts b/packages/web-pkg/src/services/folder/loaders/loaderSharedWithMe.ts similarity index 95% rename from packages/web-app-files/src/services/folder/loaderSharedWithMe.ts rename to packages/web-pkg/src/services/folder/loaders/loaderSharedWithMe.ts index ab506a05c02..f4b9b8b5e66 100644 --- a/packages/web-app-files/src/services/folder/loaderSharedWithMe.ts +++ b/packages/web-pkg/src/services/folder/loaders/loaderSharedWithMe.ts @@ -1,8 +1,8 @@ -import { FolderLoader, FolderLoaderTask, TaskContext } from '../folder' +import { FolderLoader, FolderLoaderTask, TaskContext } from '../folderService' import { Router } from 'vue-router' import { useTask } from 'vue-concurrency' import { buildIncomingShareResource, call } from '@ownclouders/web-client' -import { isLocationSharesActive } from '@ownclouders/web-pkg' +import { isLocationSharesActive } from '../../../router' export class FolderLoaderSharedWithMe implements FolderLoader { public isEnabled(): boolean { diff --git a/packages/web-app-files/src/services/folder/loaderSharedWithOthers.ts b/packages/web-pkg/src/services/folder/loaders/loaderSharedWithOthers.ts similarity index 95% rename from packages/web-app-files/src/services/folder/loaderSharedWithOthers.ts rename to packages/web-pkg/src/services/folder/loaders/loaderSharedWithOthers.ts index 7dd4ab82a83..396c6b98928 100644 --- a/packages/web-app-files/src/services/folder/loaderSharedWithOthers.ts +++ b/packages/web-pkg/src/services/folder/loaders/loaderSharedWithOthers.ts @@ -1,7 +1,7 @@ -import { FolderLoader, FolderLoaderTask, TaskContext } from '../folder' +import { FolderLoader, FolderLoaderTask, TaskContext } from '../folderService' import { Router } from 'vue-router' import { useTask } from 'vue-concurrency' -import { isLocationSharesActive } from '@ownclouders/web-pkg' +import { isLocationSharesActive } from '../../../router' import { buildOutgoingShareResource, call } from '@ownclouders/web-client' export class FolderLoaderSharedWithOthers implements FolderLoader { diff --git a/packages/web-app-files/src/services/folder/loaderSpace.ts b/packages/web-pkg/src/services/folder/loaders/loaderSpace.ts similarity index 96% rename from packages/web-app-files/src/services/folder/loaderSpace.ts rename to packages/web-pkg/src/services/folder/loaders/loaderSpace.ts index a1a7bc6a0fc..9a6bea8fdc7 100644 --- a/packages/web-app-files/src/services/folder/loaderSpace.ts +++ b/packages/web-pkg/src/services/folder/loaders/loaderSpace.ts @@ -1,14 +1,7 @@ -import { FolderLoader, FolderLoaderTask, TaskContext } from '../folder' +import { FolderLoader, FolderLoaderTask, TaskContext } from '../folderService' import { Router } from 'vue-router' import { useTask } from 'vue-concurrency' import isEmpty from 'lodash-es/isEmpty' -import { - isLocationPublicActive, - isLocationSpacesActive, - SharesStore, - SpacesStore, - UserStore -} from '@ownclouders/web-pkg' import { buildIncomingShareResource, call, @@ -20,10 +13,11 @@ import { } from '@ownclouders/web-client' import { unref } from 'vue' import { FolderLoaderOptions } from './types' -import { useFileRouteReplace } from '@ownclouders/web-pkg' -import { getIndicators } from '@ownclouders/web-pkg' import { Graph } from '@ownclouders/web-client/graph' import { DriveItem } from '@ownclouders/web-client/graph/generated' +import { isLocationSpacesActive, isLocationPublicActive } from '../../../router' +import { SharesStore, SpacesStore, useFileRouteReplace, UserStore } from '../../../composables' +import { getIndicators } from '../../../helpers' export class FolderLoaderSpace implements FolderLoader { public isEnabled(): boolean { diff --git a/packages/web-app-files/src/services/folder/loaderTrashbin.ts b/packages/web-pkg/src/services/folder/loaders/loaderTrashbin.ts similarity index 93% rename from packages/web-app-files/src/services/folder/loaderTrashbin.ts rename to packages/web-pkg/src/services/folder/loaders/loaderTrashbin.ts index 9fceb5d5134..dc52492e060 100644 --- a/packages/web-app-files/src/services/folder/loaderTrashbin.ts +++ b/packages/web-pkg/src/services/folder/loaders/loaderTrashbin.ts @@ -1,8 +1,8 @@ -import { FolderLoader, FolderLoaderTask, TaskContext } from '../folder' +import { FolderLoader, FolderLoaderTask, TaskContext } from '../folderService' import { Router } from 'vue-router' import { useTask } from 'vue-concurrency' import { DavProperties } from '@ownclouders/web-client/webdav' -import { isLocationTrashActive } from '@ownclouders/web-pkg' +import { isLocationTrashActive } from '../../../router' import { SpaceResource } from '@ownclouders/web-client' export class FolderLoaderTrashbin implements FolderLoader { diff --git a/packages/web-app-files/src/services/folder/types.ts b/packages/web-pkg/src/services/folder/loaders/types.ts similarity index 100% rename from packages/web-app-files/src/services/folder/types.ts rename to packages/web-pkg/src/services/folder/loaders/types.ts diff --git a/packages/web-pkg/src/services/index.ts b/packages/web-pkg/src/services/index.ts index 519fe9edb4f..6b2a45388dd 100644 --- a/packages/web-pkg/src/services/index.ts +++ b/packages/web-pkg/src/services/index.ts @@ -3,6 +3,7 @@ export * from './archiver' export * from './cache' export * from './client' export * from './eventBus' +export * from './folder' export * from './loadingService' export * from './preview' export * from './passwordPolicy'