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

Move useSort composable to web-pkg #8804

Merged
merged 1 commit into from
Apr 13, 2023
Merged
Show file tree
Hide file tree
Changes from all 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 @@ -199,6 +199,7 @@ import {
useCapabilityFilesTags,
useCapabilityProjectSpacesEnabled,
useCapabilityShareJailEnabled,
SortDir,
useStore,
useUserContext
} from 'web-pkg/src/composables'
Expand All @@ -213,7 +214,6 @@ import { SideBarEventTopics } from 'web-pkg/src/composables/sideBar'
import { configurationManager } from 'web-pkg/src/configuration'
import ContextMenuQuickAction from 'web-pkg/src/components/ContextActions/ContextMenuQuickAction.vue'

import { SortDir } from 'web-app-files/src/composables'
import { useResourceRouteResolver } from 'web-app-files/src/composables/filesList/useResourceRouteResolver'
import { ViewModeConstants } from 'web-app-files/src/composables/viewMode'
import { ClipboardActions } from 'web-app-files/src/helpers/clipboardActions'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,13 @@
import { onBeforeUpdate, defineComponent, nextTick, PropType, computed, ref, unref } from 'vue'
import { useGettext } from 'vue3-gettext'
import { Resource, SpaceResource } from 'web-client'
import { useStore } from 'web-pkg/src/composables'
import { useStore, SortDir, SortField } from 'web-pkg/src/composables'
import { ImageDimension } from 'web-pkg/src/constants'
import { createFileRouteOptions } from 'web-pkg/src/helpers/router'
import { displayPositionedDropdown } from 'web-pkg/src/helpers/contextMenuDropdown'
import { createLocationSpaces } from 'web-app-files/src/router'
import ContextMenuQuickAction from 'web-pkg/src/components/ContextActions/ContextMenuQuickAction.vue'
import { SortDir, SortField, ViewModeConstants } from 'web-app-files/src/composables'
import { ViewModeConstants } from 'web-app-files/src/composables'

// Constants should match what is being used in OcTable/ResourceTable
// Alignment regarding naming would be an API-breaking change and can
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,13 @@ import { ImageDimension, ImageType } from 'web-pkg/src/constants'
import { VisibilityObserver } from 'web-pkg/src/observer'
import { mapActions } from 'vuex'
import { useFileActions } from '../../composables/actions/files/useFileActions'
import { useCapabilityShareJailEnabled, useStore } from 'web-pkg/src/composables'
import { useCapabilityShareJailEnabled, SortDir, useStore } from 'web-pkg/src/composables'
import { createLocationSpaces } from '../../router'
import ListInfo from '../../components/FilesList/ListInfo.vue'
import { ShareStatus } from 'web-client/src/helpers/share'
import ContextActions from '../../components/FilesList/ContextActions.vue'
import NoContentMessage from 'web-pkg/src/components/NoContentMessage.vue'
import { useSelectedResources } from '../../composables/selection'
import { SortDir } from '../../composables'
import { RouteLocationNamedRaw } from 'vue-router'
import { buildShareSpaceResource, Resource, SpaceResource } from 'web-client/src/helpers'
import { configurationManager } from 'web-pkg/src/configuration'
Expand Down
1 change: 0 additions & 1 deletion packages/web-app-files/src/composables/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,4 @@ export * from './router'
export * from './selection'
export * from './shares'
export * from './spaces'
export * from './sort'
export * from './viewMode'
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { nextTick, computed, unref, Ref } from 'vue'
import { folderService } from '../../services/folder'
import { fileList } from '../../helpers/ui'
import { usePagination, useFileListHeaderPosition, SortField } from '../'
import { useSort, SortDir } from '../sort/'
import { usePagination, useFileListHeaderPosition } from '../'
import { useSort, SortDir, SortField } from 'web-pkg/src/composables'
import { useSideBar } from 'web-pkg/src/composables/sideBar'

import {
Expand Down
2 changes: 1 addition & 1 deletion packages/web-app-files/src/helpers/ui/resourceTable.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { SortDir, SortField } from '../../composables/sort'
import { SortDir, SortField } from 'web-pkg/src/composables'

export const determineSortFields = (firstResource): SortField[] => {
if (!firstResource) {
Expand Down
2 changes: 1 addition & 1 deletion packages/web-app-files/src/helpers/ui/resourceTiles.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { SortDir, SortField } from '../../composables/sort'
import { SortDir, SortField } from 'web-pkg/src/composables'

// just a dummy function to trick gettext tools
function $gettext(msg) {
Expand Down
4 changes: 2 additions & 2 deletions packages/web-app-files/src/views/shares/SharedWithMe.vue
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@

<script lang="ts">
import { mapGetters } from 'vuex'
import { useSort, useResourcesViewDefaults } from '../../composables'
import { useResourcesViewDefaults } from '../../composables'

import AppLoadingSpinner from 'web-pkg/src/components/AppLoadingSpinner.vue'
import AppBar from '../../components/AppBar/AppBar.vue'
Expand All @@ -74,7 +74,7 @@ import SideBar from '../../components/SideBar/SideBar.vue'
import FilesViewWrapper from '../../components/FilesViewWrapper.vue'
import { buildShareSpaceResource } from 'web-client/src/helpers'
import { configurationManager } from 'web-pkg/src/configuration'
import { useCapabilityShareJailEnabled, useStore } from 'web-pkg/src/composables'
import { useCapabilityShareJailEnabled, useSort, useStore } from 'web-pkg/src/composables'

export default defineComponent({
components: {
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 @@ -79,7 +79,7 @@ import AppLoadingSpinner from 'web-pkg/src/components/AppLoadingSpinner.vue'

import AppBar from '../../components/AppBar/AppBar.vue'
import CreateSpace from '../../components/AppBar/CreateSpace.vue'
import { useAbility, useClientService, useStore } from 'web-pkg/src/composables'
import { useAbility, useClientService, useSort, useStore } from 'web-pkg/src/composables'
import { ImageDimension } from 'web-pkg/src/constants'
import SpaceContextActions from '../../components/Spaces/SpaceContextActions.vue'
import { isProjectSpaceResource, SpaceResource } from 'web-client/src/helpers'
Expand All @@ -90,7 +90,7 @@ import { eventBus } from 'web-pkg/src/services/eventBus'
import { SideBarEventTopics, useSideBar } from 'web-pkg/src/composables/sideBar'
import { WebDAV } from 'web-client/src/webdav'
import { useScrollTo } from 'web-app-files/src/composables/scrollTo'
import { useSelectedResources, useSort, ViewModeConstants } from 'web-app-files/src/composables'
import { useSelectedResources, ViewModeConstants } from 'web-app-files/src/composables'
import { sortFields as availableSortFields } from '../../helpers/ui/resourceTiles'

export default defineComponent({
Expand Down
2 changes: 1 addition & 1 deletion packages/web-app-files/tests/mocks/useSortMock.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useSort } from 'web-app-files/src/composables'
import { useSort } from 'web-pkg/src/composables'
import { ref } from 'vue'

export const useSortMock = (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import SharedWithMe from '../../../../src/views/shares/SharedWithMe.vue'
import { useResourcesViewDefaults, useSort } from 'web-app-files/src/composables'
import { useResourcesViewDefaults } from 'web-app-files/src/composables'
import { useSort } from 'web-pkg/src/composables/sort'
import { useResourcesViewDefaultsMock } from 'web-app-files/tests/mocks/useResourcesViewDefaultsMock'
import { ShareStatus } from 'web-client/src/helpers/share'
import { ref } from 'vue'
Expand All @@ -16,6 +17,7 @@ import {
} from 'web-test-helpers'

jest.mock('web-app-files/src/composables')
jest.mock('web-pkg/src/composables/sort')

describe('SharedWithMe view', () => {
it('appBar always present', () => {
Expand Down
1 change: 1 addition & 0 deletions packages/web-pkg/src/composables/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ export * from './localStorage'
export * from './router'
export * from './previewService'
export * from './spaces'
export * from './sort'
export * from './store'
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ const defaultSortDirection = (name: string, fields: SortField[]): SortDir => {
return SortDir.Desc
}

const sortHelper = <T extends SortableItem>(
export const sortHelper = <T extends SortableItem>(
items: T[],
fields: SortField[],
sortBy: string,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ref, unref } from 'vue'
import { SortDir, SortOptions, useSort } from '../../../../src/composables'
import { SortDir, SortOptions, useSort } from 'web-pkg'
import { Resource } from 'web-client/src/helpers/resource'
import { getComposableWrapper } from 'web-test-helpers'

Expand Down