Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

migrating resourceTiles to web-pkg #10330

Merged
merged 8 commits into from
Jan 23, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When importing from web-pkg from any other package than web-pkg itself, please use @ownclouders/web-pkg.

Suggested change
import { determineSortFields as determineResourceTilesSortFields } from '@ownclouders/web-pkg/src/helpers/ui/resourceTiles'
import { determineSortFields as determineResourceTilesSortFields } from '@ownclouders/web-pkg'

For this to work you need to export determineSortFields in web-pkg via the index file in packages/web-pkg/src/helpers/ui/index.ts. Since you will get a naming conflict then (because there's 2 exported methods named determineSortFields), I'd suggesting renaming the actual functions to determineResourceTableSortFields and determineResourceTilesSortFields.

import { Task } from 'vue-concurrency'
import { Resource } from '@ownclouders/web-client'
import { useSelectedResources, SelectedResourcesResult } from '@ownclouders/web-pkg'
Expand Down
1 change: 0 additions & 1 deletion packages/web-app-files/src/helpers/ui/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
export * as fileList from './filesList'
export * as resourceTiles from './resourceTiles'
2 changes: 1 addition & 1 deletion packages/web-app-files/src/views/spaces/GenericSpace.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
import ResourceTiles from '@ownclouders/web-pkg/src/components/FilesList/ResourceTiles.vue'
import { ResourceTiles } from '@ownclouders/web-pkg'

You need to export ResourceTiles properly in web-pkg as well here.

import SpaceHeader from '../../components/Spaces/SpaceHeader.vue'
import WhitespaceContextMenu from 'web-app-files/src/components/Spaces/WhitespaceContextMenu.vue'
import { eventBus } from '@ownclouders/web-pkg'
Expand Down
4 changes: 2 additions & 2 deletions packages/web-app-files/src/views/spaces/Projects.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
import ResourceTiles from '@ownclouders/web-pkg/src/components/FilesList/ResourceTiles.vue'
import { ResourceTiles } from '@ownclouders/web-pkg'

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'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, please use ownclouders/web-pkg as import and make the sort fields available in web-pkg via exports.

import { defaultFuseOptions, formatFileSize, ResourceIcon } from '@ownclouders/web-pkg'
import { useGettext } from 'vue3-gettext'
import {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
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', () => ({
...jest.requireActual('@ownclouders/web-pkg'),

jest.mock('../../../../src/composables/viewMode', () => ({
...jest.requireActual('../../../../src/composables/viewMode'),
useTileSize: jest.fn().mockReturnValue({
tileSizePixels: 100
})
Expand Down