Skip to content

Commit ac3aaa2

Browse files
diocasrodcoffani
authored andcommitted
Add spaces filtering
1 parent 4ec11aa commit ac3aaa2

File tree

4 files changed

+83
-10
lines changed

4 files changed

+83
-10
lines changed

packages/web-app-files/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ export const navItems = (context: ComponentCustomProperties): AppNavigationItem[
136136
activeFor: () => {
137137
const projects = [{ path: `/${appInfo.id}/spaces/project` }]
138138
spacesStores.spaces.forEach((drive) => {
139-
if (isProjectSpaceResource(drive)) {
139+
if (isProjectSpaceResource(drive) || drive.driveType === 'explorer') {
140140
projects.push({
141141
path: `/${appInfo.id}/spaces/${drive.driveAlias}`
142142
})

packages/web-app-files/src/views/spaces/GenericSpace.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ export default defineComponent({
297297
const route = useRoute()
298298
const breadcrumbs = computed(() => {
299299
const rootBreadcrumbItems: BreadcrumbItem[] = []
300-
if (isProjectSpaceResource(unref(space))) {
300+
if (isProjectSpaceResource(unref(space)) || unref(space).driveType === 'explorer') {
301301
rootBreadcrumbItems.push({
302302
id: uuidV4(),
303303
text: $gettext('Spaces'),

packages/web-app-files/src/views/spaces/Projects.vue

Lines changed: 78 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@
1515
<template #actions>
1616
<create-space v-if="hasCreatePermission" class="oc-mr-s" />
1717
<div v-if="!selectedResourcesIds?.length" class="oc-flex oc-flex-middle oc-pl-s">
18-
<span v-text="$gettext('Learn about spaces')" />
18+
<!-- <span v-text="$gettext('Learn about spaces')" />
1919
<oc-contextual-helper
2020
:list="spacesHelpList"
2121
:title="$gettext('Spaces')"
2222
class="oc-ml-xs"
23-
/>
23+
/> -->
2424
</div>
2525
</template>
2626
</app-bar>
@@ -45,6 +45,28 @@
4545
<oc-icon name="filter-2" class="oc-mr-xs" />
4646
<span v-text="$gettext('Filter:')" />
4747
</div>
48+
<item-filter-inline
49+
class="project-visibility-filter"
50+
filter-name="projectVisibility"
51+
:filter-options="visibilityOptions"
52+
@toggle-filter="setVisibilityOption"
53+
/>
54+
<!--<item-filter
55+
:allow-multiple="true"
56+
:filter-label="$gettext('Storage Type')"
57+
:filterable-attributes="['label']"
58+
:items="storageTypes"
59+
:option-filter-label="$gettext('Filter storage types')"
60+
:show-option-filter="true"
61+
id-attribute="key"
62+
class="storage-type-filter oc-ml-s"
63+
display-name-attribute="label"
64+
filter-name="storageType"
65+
>
66+
<template #item="{ item }">
67+
<span class="oc-ml-s" v-text="item.label" />
68+
</template>
69+
</item-filter>-->
4870
<!-- FIXME: TEMPORARY REMOVAL OF FILTER -->
4971
<!-- <item-filter-toggle -->
5072
<!-- :filter-label="$gettext('Include disabled')" -->
@@ -97,7 +119,7 @@
97119
</template>
98120
</template>
99121
<template #actions="{ resource }">
100-
<oc-button
122+
<!--<oc-button
101123
v-if="!resource.disabled"
102124
v-oc-tooltip="showSpaceMemberLabel"
103125
class="spaces-list-show-members-button"
@@ -106,7 +128,7 @@
106128
@click="openSidebarSharePanel(resource as SpaceResource)"
107129
>
108130
<oc-icon name="group" fill-type="line" />
109-
</oc-button>
131+
</oc-button>-->
110132
</template>
111133
<template #contextMenu="{ resource }">
112134
<space-context-actions
@@ -223,6 +245,7 @@ import {
223245
import { orderBy } from 'lodash-es'
224246
import { useResourcesViewDefaults } from '../../composables'
225247
import { folderViewsProjectSpacesExtensionPoint } from '../../extensionPoints'
248+
import { ItemFilterInline, InlineFilterOption, ItemFilter } from '@ownclouders/web-pkg'
226249
227250
export default defineComponent({
228251
components: {
@@ -237,7 +260,9 @@ export default defineComponent({
237260
ResourceIcon,
238261
ResourceTiles,
239262
ResourceTable,
240-
SpaceContextActions
263+
SpaceContextActions,
264+
ItemFilterInline,
265+
ItemFilter
241266
},
242267
setup() {
243268
const spacesStore = useSpacesStore()
@@ -259,6 +284,34 @@ export default defineComponent({
259284
(drive) => isPersonalSpaceResource(drive) && drive.isOwner(userStore.user)
260285
)
261286
287+
const visibilityOption = ref('project')
288+
const storageTypeQuery = useRouteQuery('q_storageType')
289+
290+
const visibilityOptions = computed(() => [
291+
{ name: 'project', label: $gettext('My Spaces') },
292+
{ name: 'explorer', label: $gettext('Explorer') },
293+
{ name: 'all', label: $gettext('All') }
294+
])
295+
296+
const storageTypes = computed(() => [
297+
{
298+
key: 'eos',
299+
value: 'eos',
300+
label: 'EOS'
301+
},
302+
{
303+
key: 'win',
304+
value: 'win',
305+
label: 'Winspaces'
306+
}
307+
])
308+
309+
const setVisibilityOption = async (value: InlineFilterOption) => {
310+
if (visibilityOption.value !== value.name) {
311+
visibilityOption.value = value.name
312+
}
313+
}
314+
262315
const loadResourcesTask = useTask(function* (signal) {
263316
clearResourceList()
264317
setAncestorMetaData({})
@@ -281,7 +334,11 @@ export default defineComponent({
281334
let loadPreviewToken: string = null
282335
283336
const runtimeSpaces = computed(() => {
284-
return spacesStore.spaces.filter(isProjectSpaceResource) || []
337+
return (
338+
spacesStore.spaces.filter(
339+
(space) => isProjectSpaceResource(space) || space?.driveType === 'explorer'
340+
) || []
341+
)
285342
})
286343
const selectedSpace = computed(() => {
287344
if (
@@ -322,6 +379,16 @@ export default defineComponent({
322379
spaces = spaces.filter((space) => space.disabled !== true)
323380
}
324381
382+
const selectedStorageTypes = queryItemAsString(unref(storageTypeQuery))?.split('+')
383+
if (selectedStorageTypes) {
384+
spaces = spaces.filter((space) =>
385+
selectedStorageTypes.some((type) => space.mimeType?.includes(type))
386+
)
387+
}
388+
if (unref(visibilityOption) !== 'all') {
389+
spaces = spaces.filter((space) => space.driveType === unref(visibilityOption))
390+
}
391+
325392
if (!(filterTerm || '').trim()) {
326393
return spaces
327394
}
@@ -529,7 +596,11 @@ export default defineComponent({
529596
setSelection,
530597
viewSize,
531598
fileListHeaderY,
532-
spacesHelpList
599+
spacesHelpList,
600+
visibilityOptions,
601+
storageTypes,
602+
setVisibilityOption,
603+
isProjectSpaceResource
533604
}
534605
},
535606
computed: {

packages/web-pkg/src/composables/piniaStores/spaces.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,9 @@ export const useSpacesStore = defineStore('spaces', () => {
262262
graphRoles: sharesStore.graphRoles,
263263
signal
264264
})
265-
spaces.value = unref(spaces).filter((s) => !isProjectSpaceResource(s))
265+
spaces.value = unref(spaces).filter(
266+
(s) => !isProjectSpaceResource(s) && s.driveType !== 'explorer'
267+
)
266268
addSpaces(projectSpaces)
267269
}
268270

0 commit comments

Comments
 (0)