Skip to content

Commit

Permalink
Show correct parent folder for project space resources
Browse files Browse the repository at this point in the history
  • Loading branch information
JammingBen committed May 12, 2023
1 parent aa089b1 commit 20a8c57
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 13 deletions.
2 changes: 1 addition & 1 deletion changelog/unreleased/bugfix-spaces-in-search-results
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Bugfix: Spaces in search results

Spaces in search results are no longer being displayed as folder resources, fixing wrong icons and sidebar panels.
Spaces in search results are no longer being displayed as folder resources, fixing wrong icons, parent folders and sidebar panels.

https://github.com/owncloud/web/issues/9022
https://github.com/owncloud/web/pull/9026
34 changes: 23 additions & 11 deletions packages/web-app-files/src/components/FilesList/ResourceTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
<oc-resource
:key="`${item.path}-${resourceDomSelector(item)}-${item.thumbnail}`"
:resource="item"
:is-path-displayed="getArePathsDisplayed(item)"
:is-path-displayed="arePathsDisplayed"
:parent-folder-name-default="getDefaultParentFolderName(item)"
:is-thumbnail-displayed="shouldDisplayThumbnails(item)"
:is-extension-displayed="areFileExtensionsShown"
Expand Down Expand Up @@ -192,7 +192,12 @@ import { mapGetters, mapActions, mapState } from 'vuex'
import { basename, dirname } from 'path'
import { useWindowSize } from '@vueuse/core'
import { Resource } from 'web-client'
import { buildShareSpaceResource, extractDomSelector, SpaceResource } from 'web-client/src/helpers'
import {
buildShareSpaceResource,
extractDomSelector,
isProjectSpaceResource,
SpaceResource
} from 'web-client/src/helpers'
import { ShareTypes } from 'web-client/src/helpers/share'
import {
Expand Down Expand Up @@ -220,7 +225,11 @@ import { ClipboardActions } from 'web-app-files/src/helpers/clipboardActions'
import { isResourceTxtFileAlmostEmpty } from 'web-app-files/src/helpers/resources'
import { determineSortFields } from 'web-app-files/src/helpers/ui/resourceTable'
import { useFileActionsRename } from 'web-app-files/src/composables/actions/files/useFileActionsRename'
import { createLocationShares, createLocationCommon } from 'web-app-files/src/router'
import {
createLocationShares,
createLocationCommon,
createLocationSpaces
} from 'web-app-files/src/router'
import { ref } from 'vue'
const TAGS_MINIMUM_SCREEN_WIDTH = 850
Expand Down Expand Up @@ -648,7 +657,7 @@ export default defineComponent({
openTagsSidebar() {
eventBus.publish(SideBarEventTopics.open)
},
openSharingSidebar(file) {
openSharingSidebar(file: Resource) {
let panelToOpen
if (file.type === 'space') {
panelToOpen = 'space-share'
Expand All @@ -659,17 +668,20 @@ export default defineComponent({
}
eventBus.publish(SideBarEventTopics.openWithPanel, panelToOpen)
},
folderLink(file) {
folderLink(file: Resource) {
return this.resourceRouteResolver.createFolderLink({
path: file.path,
fileId: file.fileId,
resource: file
})
},
parentFolderLink(file) {
parentFolderLink(file: Resource) {
if (file.shareId && file.path === '/') {
return createLocationShares('files-shares-with-me')
}
if (isProjectSpaceResource(file)) {
return createLocationSpaces('files-spaces-projects')
}
return this.resourceRouteResolver.createFolderLink({
path: dirname(file.path),
Expand Down Expand Up @@ -828,7 +840,7 @@ export default defineComponent({
linkCount
})
},
getOwnerAvatarDescription(resource) {
getOwnerAvatarDescription(resource: Resource) {
const translated = this.$gettext('This %{ resourceType } is owned by %{ ownerName }')
const resourceType =
resource.type === 'folder' ? this.$gettext('folder') : this.$gettext('file')
Expand All @@ -837,8 +849,11 @@ export default defineComponent({
ownerName: resource.owner[0].displayName
})
},
getDefaultParentFolderName(resource) {
getDefaultParentFolderName(resource: Resource) {
if (this.hasProjectSpaces) {
if (isProjectSpaceResource(resource)) {
return this.$gettext('Spaces')
}
const matchingSpace = this.resourceRouteResolver.getMatchingSpace(resource)
if (matchingSpace?.driveType === 'project') {
return matchingSpace.name
Expand All @@ -860,9 +875,6 @@ export default defineComponent({
}
return this.$gettext('Personal')
},
getArePathsDisplayed(resource) {
return this.arePathsDisplayed && resource.type !== 'space'
}
}
})
Expand Down
9 changes: 8 additions & 1 deletion packages/web-app-files/src/components/Search/Preview.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import { mapGetters } from 'vuex'
import { createLocationShares, createLocationSpaces } from '../../router'
import { basename, dirname } from 'path'
import { useCapabilityShareJailEnabled } from 'web-pkg/src/composables'
import { buildShareSpaceResource, Resource } from 'web-client/src/helpers'
import { buildShareSpaceResource, isProjectSpaceResource, Resource } from 'web-client/src/helpers'
import { configurationManager } from 'web-pkg/src/configuration'
import { eventBus } from 'web-pkg/src/services/eventBus'
import { createFileRouteOptions } from 'web-pkg/src/helpers/router'
Expand Down Expand Up @@ -115,6 +115,10 @@ export default defineComponent({
return this.$gettext('All files and folders')
}
if (isProjectSpaceResource(this.resource)) {
return this.$gettext('Spaces')
}
if (this.matchingSpace?.driveType === 'project') {
return this.matchingSpace.name
}
Expand All @@ -134,6 +138,9 @@ export default defineComponent({
if (this.resource.shareId && this.resource.path === '/') {
return createLocationShares('files-shares-with-me')
}
if (isProjectSpaceResource(this.resource)) {
return createLocationSpaces('files-spaces-projects')
}
return this.createFolderLink(dirname(this.resource.path), this.resource.parentFolderId)
}
},
Expand Down

0 comments on commit 20a8c57

Please sign in to comment.