Skip to content

Commit

Permalink
Show space icons in search (#9349)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan authored Jul 7, 2023
1 parent 05f5207 commit 162a772
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 4 deletions.
19 changes: 18 additions & 1 deletion packages/design-system/src/components/OcResource/OcResource.vue
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
class="parent-folder"
@click.stop="$emit('parentFolderClicked')"
>
<oc-icon name="folder-2" size="small" fill-type="line" />
<oc-icon v-bind="parentFolderLinkIconAttrs" />
<span class="text" v-text="parentFolder" />
</component>
</div>
Expand Down Expand Up @@ -102,6 +102,14 @@ export default defineComponent({
required: false,
default: null
},
/**
* The resource parent folder link path icon additional attributes
*/
parentFolderLinkIconAdditionalAttributes: {
type: Object,
required: false,
default: () => {}
},
/**
* The resource to be displayed
*/
Expand Down Expand Up @@ -176,6 +184,15 @@ export default defineComponent({
}
},
parentFolderLinkIconAttrs() {
return {
'fill-type': 'line',
name: 'folder-2',
size: 'small',
...this.parentFolderLinkIconAdditionalAttributes
}
},
hasThumbnail() {
return (
this.isThumbnailDisplayed &&
Expand Down
27 changes: 27 additions & 0 deletions packages/web-app-files/src/components/FilesList/ResourceTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@
:is-resource-clickable="isResourceClickable(item.id)"
:folder-link="folderLink(item)"
:parent-folder-link="parentFolderLink(item)"
:parent-folder-link-icon-additional-attributes="
parentFolderLinkIconAdditionalAttributes(item)
"
:class="{ 'resource-table-resource-cut': isResourceCut(item) }"
@click="emitFileClick(item)"
/>
Expand Down Expand Up @@ -562,6 +565,15 @@ export default defineComponent({
wrap: 'nowrap',
width: 'shrink'
},
{
name: 'status',
prop: 'disabled',
title: this.$gettext('Status'),
type: 'slot',
alignH: 'right',
wrap: 'nowrap',
width: 'shrink'
},
this.hasTags
? {
name: 'tags',
Expand Down Expand Up @@ -753,6 +765,21 @@ export default defineComponent({
resource: file
})
},
parentFolderLinkIconAdditionalAttributes(file) {
// Identify if resource is project space or is part of a project space and the resource is located in its root
if (
isProjectSpaceResource(file) ||
(isProjectSpaceResource(this.getInternalSpace(file.storageId) || ({} as Resource)) &&
file.path.split('/').length === 2)
) {
return {
name: 'layout-grid',
'fill-type': 'fill'
}
}
return {}
},
fileDragged(file) {
this.addSelectedResource(file)
},
Expand Down
23 changes: 22 additions & 1 deletion packages/web-app-files/src/components/Search/Preview.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
:is-path-displayed="true"
:is-resource-clickable="false"
:parent-folder-link="parentFolderLink"
:parent-folder-link-icon-additional-attributes="parentFolderLinkIconAdditionalAttributes"
:parent-folder-name-default="defaultParentFolderName"
:is-thumbnail-displayed="displayThumbnails"
@parent-folder-clicked="parentFolderClicked"
Expand All @@ -29,7 +30,7 @@ import { computed, defineComponent, ref, unref } from 'vue'
import { mapGetters } from 'vuex'
import { createLocationShares, createLocationSpaces } from '../../router'
import { basename, dirname } from 'path'
import { useCapabilityShareJailEnabled } from 'web-pkg/src/composables'
import { useCapabilityShareJailEnabled, useGetMatchingSpace } from 'web-pkg/src/composables'
import { buildShareSpaceResource, isProjectSpaceResource, Resource } from 'web-client/src/helpers'
import { configurationManager } from 'web-pkg/src/configuration'
import { eventBus } from 'web-pkg/src/services/eventBus'
Expand All @@ -53,6 +54,7 @@ export default defineComponent({
}
},
setup(props) {
const { getInternalSpace } = useGetMatchingSpace()
const previewData = ref()
const resource = computed((): Resource => {
return {
Expand All @@ -65,6 +67,7 @@ export default defineComponent({
})
return {
...useFileActions(),
getInternalSpace,
hasShareJail: useCapabilityShareJailEnabled(),
previewData,
resource
Expand Down Expand Up @@ -142,6 +145,24 @@ export default defineComponent({
return createLocationSpaces('files-spaces-projects')
}
return this.createFolderLink(dirname(this.resource.path), this.resource.parentFolderId)
},
parentFolderLinkIconAdditionalAttributes() {
// Identify if resource is project space or is part of a project space and the resource is located in its root
if (
isProjectSpaceResource(this.resource) ||
(isProjectSpaceResource(
this.getInternalSpace(this.resource.storageId) || ({} as Resource)
) &&
this.resource.path.split('/').length === 2)
) {
return {
name: 'layout-grid',
'fill-type': 'fill'
}
}
return {}
}
},
mounted() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export const useFileActionsCreateSpaceFromResource = ({ store }: { store?: Store
return [
{
name: 'create-space-from-resource',
icon: 'layout-grid',
icon: 'function',
handler,
label: () => {
return $gettext('Create Space from selection')
Expand Down
1 change: 1 addition & 0 deletions packages/web-app-files/src/views/spaces/Projects.vue
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ export default defineComponent({
'totalQuota',
'usedQuota',
'remainingQuota',
'status',
'mdate'
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ exports[`Projects view different files view states lists all available project s
<div id="files-view">
<app-bar-stub breadcrumbs="[object Object]" breadcrumbscontextactionsitems="" hasbulkactions="true" hasfileextensions="false" hashiddenfiles="false" haspagination="false" hassharesnavigation="false" hassidebartoggle="true" hasviewoptions="true" showactionsonselection="true" sidebaropen="false" viewmodes="[object Object],[object Object]"></app-bar-stub>
<div class="spaces-list oc-mt-l">
<resource-table-stub arepathsdisplayed="false" areresourcesclickable="true" arethumbnailsdisplayed="true" class="spaces-table" dragdrop="false" fieldsdisplayed="image,name,manager,members,totalQuota,usedQuota,remainingQuota,mdate" hasactions="true" headerposition="0" hover="true" isselectable="true" paddingx="small" resourcedomselector="[Function]" resources="[object Object],[object Object]" selectedids="" sort-fields="[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]" sortby="[Function]" sortdir="desc" sticky="false" viewmode="resource-table"></resource-table-stub>
<resource-table-stub arepathsdisplayed="false" areresourcesclickable="true" arethumbnailsdisplayed="true" class="spaces-table" dragdrop="false" fieldsdisplayed="image,name,manager,members,totalQuota,usedQuota,remainingQuota,status,mdate" hasactions="true" headerposition="0" hover="true" isselectable="true" paddingx="small" resourcedomselector="[Function]" resources="[object Object],[object Object]" selectedids="" sort-fields="[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]" sortby="[Function]" sortdir="desc" sticky="false" viewmode="resource-table"></resource-table-stub>
</div>
</div>
</div>
Expand Down

0 comments on commit 162a772

Please sign in to comment.