Skip to content

Commit

Permalink
Polish and fix unit&integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pascalwengerter committed Mar 28, 2022
1 parent 2200ecc commit 4a29b02
Show file tree
Hide file tree
Showing 32 changed files with 246 additions and 419 deletions.
10 changes: 0 additions & 10 deletions packages/web-app-files/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,6 @@ export default {
SideBar
},
mixins: [Mixins],
data() {
return {
createFolder: false,
fileUploadName: '',
fileUploadProgress: 0,
upload: false,
fileName: '',
breadcrumbs: []
}
},
computed: {
...mapGetters('Files', ['dropzone']),
...mapState('Files/sidebar', { sidebarClosed: 'closed' }),
Expand Down
25 changes: 6 additions & 19 deletions packages/web-app-files/src/components/AppBar/AppBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
<div class="files-app-bar-actions">
<div class="oc-flex-1 oc-flex oc-flex-start" style="gap: 15px">
<slot v-if="selectedFiles.length === 0" name="actions" />
<size-info v-if="hasBulkActions && selectedFiles.length > 0" class="oc-visible@l" />
<batch-actions v-if="hasBulkActions && selectedFiles.length > 0" />
<size-info v-if="showBatchActions" class="oc-visible@l" />
<batch-actions v-if="showBatchActions" />
</div>
</div>
<slot name="static" />
Expand All @@ -36,8 +36,6 @@ import { mapGetters, mapState, mapMutations } from 'vuex'
import Mixins from '../../mixins'
import MixinFileActions from '../../mixins/fileActions'
import { isLocationSpacesActive } from '../../router'
import { useActiveLocation } from '../../composables'
import BatchActions from './SelectedResources/BatchActions.vue'
import ContextActions from '../FilesList/ContextActions.vue'
Expand All @@ -61,31 +59,20 @@ export default {
hasBulkActions: { type: Boolean, default: false },
hasSharesNavigation: { type: Boolean, default: false }
},
setup() {
return {
isPersonalLocation: useActiveLocation(isLocationSpacesActive, 'files-spaces-personal-home'),
isSpacesProjectLocation: useActiveLocation(isLocationSpacesActive, 'files-spaces-project')
}
},
data: () => ({
newFileAction: null,
path: '',
fileFolderCreationLoading: false
}),
computed: {
...mapGetters(['getToken', 'capabilities', 'configuration', 'newFileHandlers', 'user']),
...mapGetters('Files', ['files', 'currentFolder', 'selectedFiles', 'publicLinkPassword']),
...mapGetters('Files', ['files', 'selectedFiles']),
...mapState('Files', ['areHiddenFilesShown']),
// we should generalize the usage of pageTitle throughout the project next
pageTitle() {
const title = this.$route.meta.title
return this.$gettext(title)
},
areDefaultActionsVisible() {
return this.selectedFiles.length < 1
},
showBatchActions() {
return this.hasBulkActions && this.selectedFiles.length > 0
},
selectedResourcesAnnouncement() {
if (this.selectedFiles.length === 0) {
return this.$gettext('No items selected.')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,11 @@ export default {
isSpacesProjectLocation: useActiveLocation(isLocationSpacesActive, 'files-spaces-project')
}
},
data: () => ({
newFileAction: null,
path: '',
fileFolderCreationLoading: false
}),
computed: {
...mapGetters(['getToken', 'capabilities', 'configuration', 'newFileHandlers', 'user']),
...mapGetters('Files', ['files', 'currentFolder', 'publicLinkPassword']),
Expand Down
23 changes: 23 additions & 0 deletions packages/web-app-files/src/components/AppBar/EmptyTrashbin.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<template>
<action-menu-item :action="emptyTrashBinAction" :items="selectedFiles" appearance="outline" />
</template>

<script>
import { mapGetters } from 'vuex'
import ActionMenuItem from '../ActionMenuItem.vue'
import EmptyTrashBin from '../../mixins/actions/emptyTrashBin'
export default {
name: 'EmptyTrashbin',
components: { ActionMenuItem },
mixins: [EmptyTrashBin],
computed: {
...mapGetters('Files', ['selectedFiles']),
emptyTrashBinAction() {
return this.$_emptyTrashBin_items[0]
}
}
}
</script>
1 change: 0 additions & 1 deletion packages/web-app-files/src/components/Search/List.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<template>
<div class="files-search-result">
<app-bar :has-bulk-actions="true" />
<p>hi</p>
<no-content-message v-if="!paginatedResources.length" class="files-empty" icon="folder">
<template #message>
<p class="oc-text-muted">
Expand Down
10 changes: 9 additions & 1 deletion packages/web-app-files/src/components/TrashBin.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@
:breadcrumbs="breadcrumbs"
:breadcrumbs-context-actions-displayed="breadcrumbsContextActionsDisplayed"
:has-bulk-actions="true"
/>
>
<template #actions>
<oc-list>
<empty-trashbin />
</oc-list>
</template>
</app-bar>
<no-content-message
v-if="isEmpty"
id="files-trashbin-empty"
Expand Down Expand Up @@ -54,6 +60,7 @@
<script>
import { mapGetters, mapMutations, mapState } from 'vuex'
import AppBar from './AppBar/AppBar.vue'
import EmptyTrashbin from './AppBar/EmptyTrashbin.vue'
import ResourceTable from './FilesList/ResourceTable.vue'
import MixinFilesListFilter from '../mixins/filesListFilter'
Expand All @@ -73,6 +80,7 @@ export default {
components: {
AppBar,
EmptyTrashbin,
ResourceTable,
AppLoadingSpinner,
NoContentMessage,
Expand Down
3 changes: 1 addition & 2 deletions packages/web-app-files/src/helpers/resources.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import orderBy from 'lodash-es/orderBy'
import path from 'path'
import { DateTime } from 'luxon'
import { getIndicators } from './statusIndicators'
import { $gettext } from '../gettext'
import { DavPermission, DavProperty } from 'web-pkg/src/constants'
import {
LinkShareRoles,
Expand Down Expand Up @@ -437,7 +436,7 @@ function _buildLink(link) {

const role = LinkShareRoles.getByBitmask(parseInt(link.permissions), link.item_type === 'folder')
if (role) {
description = $gettext(role.label)
description = role.label
}

return {
Expand Down
13 changes: 7 additions & 6 deletions packages/web-app-files/src/views/Personal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@
<div>
<app-loading-spinner v-if="loadResourcesTask.isRunning" />
<template v-else>
<app-bar :has-bulk-actions="true" :breadcrumbs="breadcrumbs">
<app-bar
:has-bulk-actions="true"
:breadcrumbs="breadcrumbs"
:breadcrumbs-context-actions-displayed="true"
:breadcrumbs-context-actions-items="[currentFolder]"
>
<template #actions>
<create-and-upload />
</template>
Expand Down Expand Up @@ -167,14 +172,10 @@ export default defineComponent({
const personalRouteName = this.hasSpaces
? this.$gettext('Personal')
: this.$gettext('All files')
const f = [
return [
{ text: personalRouteName, to: '/' },
...breadcrumbsFromPath(this.$route.path, this.$route.params.item)
]
console.log(f)
return f
},
folderNotFound() {
Expand Down
7 changes: 6 additions & 1 deletion packages/web-app-files/src/views/spaces/Project.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@
<div class="space-overview">
<app-loading-spinner v-if="loadResourcesTask.isRunning" />
<template v-else>
<app-bar :has-bulk-actions="true" :breadcrumbs="breadcrumbs">
<app-bar
:has-bulk-actions="true"
:breadcrumbs="breadcrumbs"
:breadcrumbs-context-actions-displayed="true"
:breadcrumbs-context-actions-items="[currentFolder]"
>
<template #actions>
<create-and-upload />
</template>
Expand Down
6 changes: 0 additions & 6 deletions packages/web-app-files/tests/integration/specs/appBar.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,6 @@ describe('AppBar contains set of actions and informations', () => {
render(
AppBar,
{
setup: () => {
return {
isPersonalLocation: true,
isSharesLocation: false
}
},
store,
routes: [{ name: 'files-personal', path: '/files/list/personal/:item?/:page?' }]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import FilesApp from '@files/src'

let store
const routes = FilesApp.routes
const stubs = { 'context-actions': true }
const stubs = { 'app-bar': true, 'context-actions': true }
const cases = [
['Personal', '/spaces/personal/home', Personal],
['Favorites', '/list/favorites/', Favorites],
Expand Down Expand Up @@ -51,22 +51,6 @@ describe('User can navigate in files list using pagination', () => {
Files: StoreFiles
}
})
const appBar = document.createElement('div')
const breadcrumbs = document.createElement('div')
const breadcrumbItem = document.createElement('div')

appBar.id = 'files-app-bar'
breadcrumbs.id = 'files-breadcrumb'

breadcrumbItem.appendChild(document.createElement('div'))
breadcrumbs.appendChild(breadcrumbItem)
document.body.appendChild(appBar)
document.body.appendChild(breadcrumbs)
})

afterEach(() => {
document.body.removeChild(document.getElementById('files-app-bar'))
document.body.removeChild(document.getElementById('files-breadcrumb'))
})

test.each(cases)(
Expand Down
Loading

0 comments on commit 4a29b02

Please sign in to comment.