diff --git a/changelog/unreleased/enhancement-add-page-size b/changelog/unreleased/enhancement-add-page-size new file mode 100644 index 00000000000..d324c192afa --- /dev/null +++ b/changelog/unreleased/enhancement-add-page-size @@ -0,0 +1,6 @@ +Enhancement: add page size view option + +We've added a new item into the view options which can be used to set the number of items displayed per page. +This value is persisted in the local storage so that the user doesn't have to update it every time he visits the app. + +https://github.com/owncloud/web/pull/5470 \ No newline at end of file diff --git a/packages/web-app-files/src/components/AppBar/AppBar.vue b/packages/web-app-files/src/components/AppBar/AppBar.vue index 23689bf5d97..fa2e63a7f22 100644 --- a/packages/web-app-files/src/components/AppBar/AppBar.vue +++ b/packages/web-app-files/src/components/AppBar/AppBar.vue @@ -99,35 +99,7 @@ - - - View - - - -
  • - -
  • -
    -
    + @@ -149,6 +121,7 @@ import FileDrop from './Upload/FileDrop.vue' import FileUpload from './Upload/FileUpload.vue' import FolderUpload from './Upload/FolderUpload.vue' import SizeInfo from './SelectedResources/SizeInfo.vue' +import ViewOptions from './ViewOptions.vue' export default { components: { @@ -156,7 +129,8 @@ export default { FileDrop, FileUpload, FolderUpload, - SizeInfo + SizeInfo, + ViewOptions }, mixins: [Mixins, MixinFileActions, MixinRoutes, MixinScrollToResource], data: () => ({ @@ -194,10 +168,6 @@ export default { return this.$gettext('Add files or folders') }, - viewButtonAriaLabel() { - return this.$gettext('Display customization options of the files list') - }, - currentPath() { const path = this.$route.params.item || '' if (path.endsWith('/')) { @@ -304,16 +274,6 @@ export default { this.selectedFiles.length ) return this.$gettextInterpolate(translated, { amount: this.selectedFiles.length }) - }, - - hiddenFilesShownModel: { - get() { - return this.areHiddenFilesShown - }, - - set(value) { - this.SET_HIDDEN_FILES_VISIBILITY(value) - } } }, diff --git a/packages/web-app-files/src/components/AppBar/ViewOptions.vue b/packages/web-app-files/src/components/AppBar/ViewOptions.vue new file mode 100644 index 00000000000..980f4102c85 --- /dev/null +++ b/packages/web-app-files/src/components/AppBar/ViewOptions.vue @@ -0,0 +1,87 @@ + + + + + diff --git a/packages/web-app-files/src/components/FilesList/Pagination.vue b/packages/web-app-files/src/components/FilesList/Pagination.vue index 1e0c258c986..81995ad82e0 100644 --- a/packages/web-app-files/src/components/FilesList/Pagination.vue +++ b/packages/web-app-files/src/components/FilesList/Pagination.vue @@ -1,23 +1,12 @@ - - diff --git a/packages/web-app-files/tests/unit/store/getters.spec.js b/packages/web-app-files/tests/unit/store/getters.spec.js index ea5ef36ab10..cd661f7e8f9 100644 --- a/packages/web-app-files/tests/unit/store/getters.spec.js +++ b/packages/web-app-files/tests/unit/store/getters.spec.js @@ -8,7 +8,8 @@ describe('Getters', () => { state = { files: FixtureFiles['/'], searchTermGlobal: '', - filesPageLimit: 10 + filesPageLimit: 10, + areHiddenFilesShown: true } }) @@ -26,5 +27,23 @@ describe('Getters', () => { expect(result.length).toEqual(5) }) + + it('returns only a portion of files if files page limit is set', () => { + state.filesPageLimit = 2 + + const { activeFiles, filesAll } = getters + const result = activeFiles(state, { filesAll: filesAll(state) }) + + expect(result.length).toEqual(2) + }) + + it('returns all files if files page limit is of type string', () => { + state.filesPageLimit = 'All' + + const { activeFiles, filesAll } = getters + const result = activeFiles(state, { filesAll: filesAll(state) }) + + expect(result.length).toEqual(5) + }) }) }) diff --git a/packages/web-app-files/tests/unit/store/mutations.spec.js b/packages/web-app-files/tests/unit/store/mutations.spec.js index 970b0ba0227..5f191287b5c 100644 --- a/packages/web-app-files/tests/unit/store/mutations.spec.js +++ b/packages/web-app-files/tests/unit/store/mutations.spec.js @@ -67,4 +67,14 @@ describe('vuex store mutations', () => { expect(state.areHiddenFilesShown).toEqual(false) }) + + it('sets the files page limit', () => { + const state = { filesPageLimit: 100 } + const { SET_FILES_PAGE_LIMIT } = mutations + + SET_FILES_PAGE_LIMIT(state, 500) + + expect(state.filesPageLimit).toEqual(500) + expect(window.localStorage.getItem('oc_filesPageLimit')).toEqual('500') + }) })