Skip to content

Commit

Permalink
Include spaces in the list info
Browse files Browse the repository at this point in the history
  • Loading branch information
JammingBen committed Nov 4, 2022
1 parent ef6006d commit b600815
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 17 deletions.
6 changes: 6 additions & 0 deletions changelog/unreleased/bugfix-include-spaces-in-list-info
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Bugfix: Include spaces in the list info

Spaces have been included in the list info below file lists that support displaying spaces.

https://github.com/owncloud/web/pull/7926
https://github.com/owncloud/web/issues/7924
64 changes: 50 additions & 14 deletions packages/web-app-files/src/components/FilesList/ListInfo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
:data-test-items="items"
:data-test-files="files"
:data-test-folders="folders"
:data-test-spaces="spaces"
:data-test-size="size"
class="oc-text-muted"
>
Expand All @@ -26,6 +27,16 @@ export default {
type: Number,
required: true
},
spaces: {
type: Number,
default: 0,
required: false
},
showSpaces: {
type: Boolean,
default: false,
required: false
},
/**
* Total size in bytes. Unformatted strings and integers are allowed.
*/
Expand All @@ -37,7 +48,8 @@ export default {
},
computed: {
items() {
return this.files + this.folders
const filesAndFolderCount = this.files + this.folders
return this.showSpaces ? filesAndFolderCount + this.spaces : filesAndFolderCount
},
text() {
const filesStr = this.$gettextInterpolate(
Expand All @@ -52,24 +64,48 @@ export default {
foldersCount: this.folders
}
)
const spacesStr = this.$gettextInterpolate(
this.$ngettext('%{ spacesCount } space', '%{ spacesCount } spaces', this.spaces),
{
spacesCount: this.spaces
}
)
const itemSize = formatFileSize(this.size, this.$language.current)
const translated =
this.size > 0
? this.$ngettext(
'%{ itemsCount } item with %{ itemSize } in total (%{ filesStr}, %{foldersStr})',
'%{ itemsCount } items with %{ itemSize } in total (%{ filesStr}, %{foldersStr})',
this.items
)
: this.$ngettext(
'%{ itemsCount } item in total (%{ filesStr}, %{foldersStr})',
'%{ itemsCount } items in total (%{ filesStr}, %{foldersStr})',
this.items
)
let translated
if (this.showSpaces) {
translated =
this.size > 0
? this.$ngettext(
'%{ itemsCount } item with %{ itemSize } in total (%{ filesStr}, %{foldersStr}, %{spacesStr})',
'%{ itemsCount } items with %{ itemSize } in total (%{ filesStr}, %{foldersStr}, %{spacesStr})',
this.items
)
: this.$ngettext(
'%{ itemsCount } item in total (%{ filesStr}, %{foldersStr}, %{spacesStr})',
'%{ itemsCount } items in total (%{ filesStr}, %{foldersStr}, %{spacesStr})',
this.items
)
} else {
translated =
this.size > 0
? this.$ngettext(
'%{ itemsCount } item with %{ itemSize } in total (%{ filesStr}, %{foldersStr})',
'%{ itemsCount } items with %{ itemSize } in total (%{ filesStr}, %{foldersStr})',
this.items
)
: this.$ngettext(
'%{ itemsCount } item in total (%{ filesStr}, %{foldersStr})',
'%{ itemsCount } items in total (%{ filesStr}, %{foldersStr})',
this.items
)
}
return this.$gettextInterpolate(translated, {
itemsCount: this.items,
itemSize,
filesStr,
foldersStr
foldersStr,
spacesStr
})
}
}
Expand Down
4 changes: 3 additions & 1 deletion packages/web-app-files/src/store/getters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,11 @@ export default {
totalFilesCount: (state, getters) => {
const fileCount = getters.filesAll.filter((file) => file.type === 'file').length
const folderCount = getters.filesAll.filter((file) => file.type === 'folder').length
const spaceCount = getters.filesAll.filter((file) => file.type === 'space').length
return {
files: fileCount,
folders: folderCount
folders: folderCount,
spaces: spaceCount
}
},
currentFileOutgoingCollaborators: (state) => {
Expand Down
7 changes: 5 additions & 2 deletions packages/web-app-files/src/views/shares/SharedViaLink.vue
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@
class="oc-width-1-1 oc-my-s"
:files="totalFilesCount.files"
:folders="totalFilesCount.folders"
:spaces="totalFilesCount.spaces"
:show-spaces="hasProjectSpaces"
/>
</template>
</resource-table>
Expand Down Expand Up @@ -79,7 +81,7 @@ import ResourceTable from '../../components/FilesList/ResourceTable.vue'
import { useResourcesViewDefaults } from '../../composables'
import { defineComponent } from '@vue/composition-api'
import { Resource } from 'web-client'
import { useStore } from 'web-pkg/src/composables'
import { useCapabilityProjectSpacesEnabled, useStore } from 'web-pkg/src/composables'
import { buildShareSpaceResource, SpaceResource } from 'web-client/src/helpers'
import { configurationManager } from 'web-pkg/src/configuration'
Expand Down Expand Up @@ -119,7 +121,8 @@ export default defineComponent({
return {
...useResourcesViewDefaults<Resource, any, any[]>(),
getSpace
getSpace,
hasProjectSpaces: useCapabilityProjectSpacesEnabled()
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ describe('ListInfo', () => {
expect(itemElement.attributes('data-test-items')).toBe('5')
expect(itemElement.attributes('data-test-files')).toBe('2')
expect(itemElement.attributes('data-test-folders')).toBe('3')
expect(itemElement.attributes('data-test-spaces')).toBe('1')
})

it('should show text with files and folders total and individual count', () => {
Expand Down Expand Up @@ -96,6 +97,7 @@ function getWrapper(props = {}) {
propsData: {
files: 2,
folders: 3,
spaces: 1,
...props
}
})
Expand Down

0 comments on commit b600815

Please sign in to comment.