From 4fa195ff606b2f5c63184d88e7490e7ae227244c Mon Sep 17 00:00:00 2001 From: Dominik Schmidt Date: Mon, 22 Aug 2022 11:54:38 +0200 Subject: [PATCH 01/11] Move right sidebar logic from App.vue to SideBar.vue --- packages/web-app-files/src/App.vue | 45 +---------------- .../src/components/SideBar/SideBar.vue | 49 +++++++++++++++++-- 2 files changed, 46 insertions(+), 48 deletions(-) diff --git a/packages/web-app-files/src/App.vue b/packages/web-app-files/src/App.vue index 3b4c170f6fe..be7a6bdd495 100644 --- a/packages/web-app-files/src/App.vue +++ b/packages/web-app-files/src/App.vue @@ -4,21 +4,10 @@
- + diff --git a/packages/web-app-files/src/components/FilesList/Pagination.vue b/packages/web-app-files/src/components/FilesList/Pagination.vue index aa92bab8804..087c53c51f4 100644 --- a/packages/web-app-files/src/components/FilesList/Pagination.vue +++ b/packages/web-app-files/src/components/FilesList/Pagination.vue @@ -24,7 +24,7 @@ export default { watch: { currentPage: { handler: function () { - document.getElementsByClassName('files-list-wrapper')[0]?.scrollTo(0, 0) + document.getElementsByClassName('files-view-wrapper')[0]?.scrollTo(0, 0) } } } diff --git a/packages/web-app-files/src/components/FilesViewWrapper.vue b/packages/web-app-files/src/components/FilesViewWrapper.vue new file mode 100644 index 00000000000..2bfa3218dc8 --- /dev/null +++ b/packages/web-app-files/src/components/FilesViewWrapper.vue @@ -0,0 +1,40 @@ + + + + + diff --git a/packages/web-app-files/src/components/TrashBin.vue b/packages/web-app-files/src/components/TrashBin.vue index 04c16d1d768..b7cf5c64278 100644 --- a/packages/web-app-files/src/components/TrashBin.vue +++ b/packages/web-app-files/src/components/TrashBin.vue @@ -1,6 +1,6 @@ - + @@ -68,11 +68,13 @@ import { bus } from 'web-pkg/src/instance' import { defineComponent } from '@vue/composition-api' import { Resource } from 'web-client' import SideBar from '../components/SideBar/SideBar.vue' +import FilesViewWrapper from './FilesViewWrapper.vue' export default defineComponent({ name: 'TrashBin', components: { + FilesViewWrapper, AppBar, ResourceTable, AppLoadingSpinner, diff --git a/packages/web-app-files/src/mixins/filesListScrolling.js b/packages/web-app-files/src/mixins/filesListScrolling.js index 34b442c745c..d22c1d9dc6c 100644 --- a/packages/web-app-files/src/mixins/filesListScrolling.js +++ b/packages/web-app-files/src/mixins/filesListScrolling.js @@ -15,7 +15,7 @@ export default { // top reached if (resourceElement.getBoundingClientRect().top < topOffset) { - const fileListWrapperElement = document.getElementsByClassName('files-list-wrapper')[0] + const fileListWrapperElement = document.getElementsByClassName('files-view-wrapper')[0] fileListWrapperElement.scrollBy(0, -resourceElement.offsetHeight) } } diff --git a/packages/web-app-files/src/views/Favorites.vue b/packages/web-app-files/src/views/Favorites.vue index f12a9f6775f..67c83f71ebd 100644 --- a/packages/web-app-files/src/views/Favorites.vue +++ b/packages/web-app-files/src/views/Favorites.vue @@ -1,6 +1,6 @@ - + @@ -82,11 +82,13 @@ import { defineComponent } from '@vue/composition-api' import { Resource } from 'web-client' import { useStore } from 'web-pkg/src/composables' import SideBar from '../components/SideBar/SideBar.vue' +import FilesViewWrapper from '../components/FilesViewWrapper.vue' const visibilityObserver = new VisibilityObserver() export default defineComponent({ components: { + FilesViewWrapper, AppBar, ResourceTable, QuickActions, diff --git a/packages/web-app-files/src/views/Personal.vue b/packages/web-app-files/src/views/Personal.vue index c8438b82ba0..b4ee0dfa23d 100644 --- a/packages/web-app-files/src/views/Personal.vue +++ b/packages/web-app-files/src/views/Personal.vue @@ -1,7 +1,7 @@ - + @@ -110,11 +110,13 @@ import { useGraphClient } from 'web-client/src/composables' import { useCapabilityShareJailEnabled, useRouteParam } from 'web-pkg/src/composables' import KeyboardActions from '../components/FilesList/KeyboardActions.vue' import SideBar from '../components/SideBar/SideBar.vue' +import FilesViewWrapper from '../components/FilesViewWrapper.vue' const visibilityObserver = new VisibilityObserver() export default defineComponent({ components: { + FilesViewWrapper, AppBar, CreateAndUpload, ResourceTable, diff --git a/packages/web-app-files/src/views/PublicFiles.vue b/packages/web-app-files/src/views/PublicFiles.vue index 2145fe520ed..68675d3ba5d 100644 --- a/packages/web-app-files/src/views/PublicFiles.vue +++ b/packages/web-app-files/src/views/PublicFiles.vue @@ -1,7 +1,7 @@ - + @@ -98,11 +98,13 @@ import { Resource } from 'web-client' import { usePublicLinkPassword, useStore } from 'web-pkg/src/composables' import KeyboardActions from '../components/FilesList/KeyboardActions.vue' import SideBar from '../components/SideBar/SideBar.vue' +import FilesViewWrapper from '../components/FilesViewWrapper.vue' const visibilityObserver = new VisibilityObserver() export default defineComponent({ components: { + FilesViewWrapper, AppBar, CreateAndUpload, ResourceTable, diff --git a/packages/web-app-files/src/views/shares/SharedResource.vue b/packages/web-app-files/src/views/shares/SharedResource.vue index 2df582293ba..854774956eb 100644 --- a/packages/web-app-files/src/views/shares/SharedResource.vue +++ b/packages/web-app-files/src/views/shares/SharedResource.vue @@ -1,7 +1,7 @@ - + @@ -98,6 +98,9 @@ import NotFoundMessage from '../../components/FilesList/NotFoundMessage.vue' import ListInfo from '../../components/FilesList/ListInfo.vue' import Pagination from '../../components/FilesList/Pagination.vue' import ContextActions from '../../components/FilesList/ContextActions.vue' +import KeyboardActions from '../../components/FilesList/KeyboardActions.vue' +import SideBar from '../../components/SideBar/SideBar.vue' +import FilesViewWrapper from '../../components/FilesViewWrapper.vue' // misc import { VisibilityObserver } from 'web-pkg/src/observer' @@ -111,8 +114,6 @@ import { move } from '../../helpers/resource' import { Resource } from 'web-client' import { breadcrumbsFromPath, concatBreadcrumbs } from '../../helpers/breadcrumbs' import { useRouteParam, useRouteQuery } from 'web-pkg/src/composables' -import KeyboardActions from '../../components/FilesList/KeyboardActions.vue' -import SideBar from '../../components/SideBar/SideBar.vue' const visibilityObserver = new VisibilityObserver() @@ -129,7 +130,8 @@ export default defineComponent({ Pagination, ContextActions, KeyboardActions, - SideBar + SideBar, + FilesViewWrapper }, mixins: [ diff --git a/packages/web-app-files/src/views/shares/SharedViaLink.vue b/packages/web-app-files/src/views/shares/SharedViaLink.vue index 6556c3b0f2e..58367277095 100644 --- a/packages/web-app-files/src/views/shares/SharedViaLink.vue +++ b/packages/web-app-files/src/views/shares/SharedViaLink.vue @@ -1,6 +1,6 @@ - + - - diff --git a/packages/web-app-files/tests/unit/components/components.setup.js b/packages/web-app-files/tests/unit/components/components.setup.js index dc6bc795811..ae217a2966f 100644 --- a/packages/web-app-files/tests/unit/components/components.setup.js +++ b/packages/web-app-files/tests/unit/components/components.setup.js @@ -72,8 +72,7 @@ export const getStore = function ({ slogan = null, user = null, generalThemeName = '', - selectedResourcesForMove = null, - locationPickerTargetFolder = null + selectedResourcesForMove = null } = {}) { return createStore(Vuex.Store, { state: { @@ -118,8 +117,7 @@ export const getStore = function ({ currentFolder: currentFolder, currentPage: currentPage, selectedIds: selectedFiles ? selectedFiles.map((file) => file.id) : [], - selectedResourcesForMove: selectedResourcesForMove, - locationPickerTargetFolder: locationPickerTargetFolder + selectedResourcesForMove: selectedResourcesForMove }, getters: { totalFilesCount: () => totalFilesCount, From dec137540149078d7141ad1283eaa780065140be Mon Sep 17 00:00:00 2001 From: Benedikt Kulmann Date: Mon, 22 Aug 2022 13:55:00 +0200 Subject: [PATCH 06/11] fix: details panel menu item handlers --- .../web-app-files/src/components/SideBar/SideBar.vue | 9 ++++----- packages/web-app-files/src/store/modules/sidebar.ts | 8 ++++++-- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/packages/web-app-files/src/components/SideBar/SideBar.vue b/packages/web-app-files/src/components/SideBar/SideBar.vue index 3ef247ae521..1af525496d2 100644 --- a/packages/web-app-files/src/components/SideBar/SideBar.vue +++ b/packages/web-app-files/src/components/SideBar/SideBar.vue @@ -66,15 +66,14 @@ export default defineComponent({ setup() { const store = useStore() - // TODO: use getters - const showSidebar = computed(() => !store.state.Files.sidebar.closed) - const sidebarActivePanel = computed(() => store.state.Files.sidebar.activePanel) + const showSidebar = computed(() => !store.getters['Files/sidebar/closed']) + const sidebarActivePanel = computed(() => store.getters['Files/sidebar/activePanel']) const closeSidebar = () => { store.dispatch('Files/sidebar/close') } - const setActiveSidebarPanel = () => { - store.dispatch('Files/sidebar/setActivePanel') + const setActiveSidebarPanel = (panelName) => { + store.dispatch('Files/sidebar/setActivePanel', panelName) } const focusSideBar = (component, event) => { diff --git a/packages/web-app-files/src/store/modules/sidebar.ts b/packages/web-app-files/src/store/modules/sidebar.ts index 416c67c2f29..ac0eeddb569 100644 --- a/packages/web-app-files/src/store/modules/sidebar.ts +++ b/packages/web-app-files/src/store/modules/sidebar.ts @@ -4,6 +4,10 @@ export default { closed: true, activePanel: null }), + getters: { + closed: (state) => state.closed, + activePanel: (state) => state.activePanel + }, mutations: { SET_CLOSED(state, closed) { state.closed = closed @@ -17,7 +21,7 @@ export default { commit('SET_CLOSED', false) commit('SET_ACTIVE_PANEL', null) }, - openWithPanel({ commit }, panel) { + openWithPanel({ commit }, panel: string) { commit('SET_CLOSED', false) commit('SET_ACTIVE_PANEL', panel) }, @@ -28,7 +32,7 @@ export default { toggle({ commit, state }) { commit('SET_CLOSED', !state.closed) }, - setActivePanel({ commit }, panel) { + setActivePanel({ commit }, panel: string) { commit('SET_ACTIVE_PANEL', panel) }, resetActivePanel({ commit }) { From bf6c742c801b9668cabf72ff69ec4c783529ff53 Mon Sep 17 00:00:00 2001 From: Benedikt Kulmann Date: Mon, 22 Aug 2022 14:17:47 +0200 Subject: [PATCH 07/11] test: fix unit tests for views --- .../unit/components/SideBar/SideBar.spec.js | 3 ++- .../tests/unit/views/Favorites.spec.js | 3 ++- .../tests/unit/views/Personal.spec.js | 3 ++- .../tests/unit/views/PublicFiles.spec.ts | 3 ++- .../unit/views/shares/SharedViaLink.spec.js | 3 ++- .../unit/views/shares/SharedWithMe.spec.js | 3 ++- .../views/shares/SharedWithOthers.spec.js | 3 ++- .../tests/unit/views/spaces/Project.spec.js | 1 + .../tests/unit/views/spaces/Projects.spec.js | 1 + .../tests/unit/views/spaces/Trashbin.spec.js | 1 + .../tests/unit/views/views.setup.js | 20 ++----------------- 11 files changed, 19 insertions(+), 25 deletions(-) diff --git a/packages/web-app-files/tests/unit/components/SideBar/SideBar.spec.js b/packages/web-app-files/tests/unit/components/SideBar/SideBar.spec.js index a1cc4308b23..c734140f113 100644 --- a/packages/web-app-files/tests/unit/components/SideBar/SideBar.spec.js +++ b/packages/web-app-files/tests/unit/components/SideBar/SideBar.spec.js @@ -243,7 +243,8 @@ function createWrapper({ item, selectedItems, mocks, currentRouteName = 'files-s currentRoute: createLocationSpaces(currentRouteName), resolve: (r) => { return { href: r.name } - } + }, + afterEach: jest.fn() } }, mocks diff --git a/packages/web-app-files/tests/unit/views/Favorites.spec.js b/packages/web-app-files/tests/unit/views/Favorites.spec.js index 99f58b384d5..7ebb722014b 100644 --- a/packages/web-app-files/tests/unit/views/Favorites.spec.js +++ b/packages/web-app-files/tests/unit/views/Favorites.spec.js @@ -11,7 +11,8 @@ const stubs = { 'oc-pagination': true, 'resource-table': true, 'oc-spinner': true, - 'context-actions': true + 'context-actions': true, + 'side-bar': true } const selectors = { diff --git a/packages/web-app-files/tests/unit/views/Personal.spec.js b/packages/web-app-files/tests/unit/views/Personal.spec.js index dfc8b45c877..bc9f10bb554 100644 --- a/packages/web-app-files/tests/unit/views/Personal.spec.js +++ b/packages/web-app-files/tests/unit/views/Personal.spec.js @@ -54,7 +54,8 @@ const stubs = { 'resource-table': true, 'not-found-message': true, 'quick-actions': true, - 'list-info': true + 'list-info': true, + 'side-bar': true } const resourceForestJpg = { diff --git a/packages/web-app-files/tests/unit/views/PublicFiles.spec.ts b/packages/web-app-files/tests/unit/views/PublicFiles.spec.ts index 9bb1b1b03b1..b3ed2c73b85 100644 --- a/packages/web-app-files/tests/unit/views/PublicFiles.spec.ts +++ b/packages/web-app-files/tests/unit/views/PublicFiles.spec.ts @@ -20,7 +20,8 @@ const stubs = { 'context-actions': true, pagination: true, 'list-info': true, - 'router-link': RouterLinkStub + 'router-link': RouterLinkStub, + 'side-bar': true } const router = { diff --git a/packages/web-app-files/tests/unit/views/shares/SharedViaLink.spec.js b/packages/web-app-files/tests/unit/views/shares/SharedViaLink.spec.js index 4c7a0c78389..8100802b968 100644 --- a/packages/web-app-files/tests/unit/views/shares/SharedViaLink.spec.js +++ b/packages/web-app-files/tests/unit/views/shares/SharedViaLink.spec.js @@ -30,7 +30,8 @@ const stubs = { 'context-actions': true, pagination: true, 'list-info': true, - 'router-link': true + 'router-link': true, + 'side-bar': true } const listLoaderStub = 'app-loading-spinner-stub' diff --git a/packages/web-app-files/tests/unit/views/shares/SharedWithMe.spec.js b/packages/web-app-files/tests/unit/views/shares/SharedWithMe.spec.js index 28d6b46609a..23e94a6898d 100644 --- a/packages/web-app-files/tests/unit/views/shares/SharedWithMe.spec.js +++ b/packages/web-app-files/tests/unit/views/shares/SharedWithMe.spec.js @@ -13,7 +13,8 @@ const stubs = { 'oc-pagination': true, 'oc-spinner': true, 'context-actions': true, - 'no-content-message': true + 'no-content-message': true, + 'side-bar': true } const selectors = { diff --git a/packages/web-app-files/tests/unit/views/shares/SharedWithOthers.spec.js b/packages/web-app-files/tests/unit/views/shares/SharedWithOthers.spec.js index 8b2471139f4..437241cd1b5 100644 --- a/packages/web-app-files/tests/unit/views/shares/SharedWithOthers.spec.js +++ b/packages/web-app-files/tests/unit/views/shares/SharedWithOthers.spec.js @@ -36,7 +36,8 @@ const stubs = { 'oc-avatars': true, 'oc-resource-size': true, 'oc-button': true, - 'oc-drop': true + 'oc-drop': true, + 'side-bar': true } const appLoadingSpinnerStub = 'app-loading-spinner-stub' diff --git a/packages/web-app-files/tests/unit/views/spaces/Project.spec.js b/packages/web-app-files/tests/unit/views/spaces/Project.spec.js index 5f73744ffb3..e5def869a4c 100644 --- a/packages/web-app-files/tests/unit/views/spaces/Project.spec.js +++ b/packages/web-app-files/tests/unit/views/spaces/Project.spec.js @@ -230,6 +230,7 @@ function getMountedWrapper(spaceResources = [], spaceItem = null, imageContent = localVue, stubs: { 'app-bar': true, + 'side-bar': true, RouterLink: RouterLinkStub }, data: () => { diff --git a/packages/web-app-files/tests/unit/views/spaces/Projects.spec.js b/packages/web-app-files/tests/unit/views/spaces/Projects.spec.js index 3af47e3f9a6..9bbab2c84fc 100644 --- a/packages/web-app-files/tests/unit/views/spaces/Projects.spec.js +++ b/packages/web-app-files/tests/unit/views/spaces/Projects.spec.js @@ -87,6 +87,7 @@ function getMountedWrapper(activeFiles = []) { }), stubs: { 'app-bar': true, + 'side-bar': true, translate: true } }) diff --git a/packages/web-app-files/tests/unit/views/spaces/Trashbin.spec.js b/packages/web-app-files/tests/unit/views/spaces/Trashbin.spec.js index 9cbf9477696..68590bff9cc 100644 --- a/packages/web-app-files/tests/unit/views/spaces/Trashbin.spec.js +++ b/packages/web-app-files/tests/unit/views/spaces/Trashbin.spec.js @@ -67,6 +67,7 @@ function getWrapper() { }), stubs: { 'app-bar': true, + 'side-bar': true, 'trash-bin': true } }) diff --git a/packages/web-app-files/tests/unit/views/views.setup.js b/packages/web-app-files/tests/unit/views/views.setup.js index bf2128a1773..f91acc17cb6 100644 --- a/packages/web-app-files/tests/unit/views/views.setup.js +++ b/packages/web-app-files/tests/unit/views/views.setup.js @@ -116,8 +116,7 @@ export const getStore = function ({ user = { id: 'test' }, generalThemeName = '', capabilities = {}, - selectedResourcesForMove = null, - locationPickerTargetFolder = null + selectedResourcesForMove = null } = {}) { return createStore(Vuex.Store, { state: { @@ -162,8 +161,7 @@ export const getStore = function ({ currentFolder: currentFolder, currentPage: currentPage, selectedIds: selectedFiles ? selectedFiles.map((file) => file.id) : [], - selectedResourcesForMove: selectedResourcesForMove, - locationPickerTargetFolder: locationPickerTargetFolder + selectedResourcesForMove: selectedResourcesForMove }, getters: { totalFilesCount: () => totalFilesCount, @@ -207,20 +205,6 @@ export const getStore = function ({ closed: sidebarClosed }, namespaced: true - }, - pagination: { - state: { - currentPage, - itemsPerPage: 100 - }, - getters: { - pages: () => pages - }, - mutations: { - SET_ITEMS_PER_PAGE: () => {}, - UPDATE_CURRENT_PAGE: () => {} - }, - namespaced: true } } }, From 545c06f4277f45dd7384dfe1ab0c4be9e4c93134 Mon Sep 17 00:00:00 2001 From: Dominik Schmidt Date: Mon, 22 Aug 2022 14:48:26 +0200 Subject: [PATCH 08/11] Fix tests --- packages/web-app-files/src/views/Trashbin.vue | 2 +- .../tests/unit/components/TrashBin.spec.js | 3 +- .../__snapshots__/SharedViaLink.spec.js.snap | 19 +-- .../spaces/__snapshots__/Project.spec.js.snap | 106 +++++++++-------- .../__snapshots__/Projects.spec.js.snap | 111 +++++++++--------- .../tests/unit/views/views.shared.ts | 3 +- 6 files changed, 131 insertions(+), 113 deletions(-) diff --git a/packages/web-app-files/src/views/Trashbin.vue b/packages/web-app-files/src/views/Trashbin.vue index 67f8a002e7d..31bb873c1d6 100644 --- a/packages/web-app-files/src/views/Trashbin.vue +++ b/packages/web-app-files/src/views/Trashbin.vue @@ -2,7 +2,7 @@ -