Skip to content

Commit

Permalink
WIP pass spaces into personal and project views and render them in Dr…
Browse files Browse the repository at this point in the history
…iveResolver
  • Loading branch information
dschmidt authored and kulmann committed Sep 7, 2022
1 parent dc29711 commit a6128ed
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 124 deletions.
8 changes: 3 additions & 5 deletions packages/web-app-files/src/services/folder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,15 @@ import { Store } from 'vuex'
import { ClientService } from 'web-pkg/src/services/client'

import {
FolderLoaderSpacesProject,
FolderLoaderSpacesGeneric,
FolderLoaderSpacesShare,
FolderLoaderFavorites,
FolderLoaderLegacyPersonal,
FolderLoaderPublicFiles,
FolderLoaderSharedViaLink,
FolderLoaderSharedWithMe,
FolderLoaderSharedWithOthers,
FolderLoaderTrashbin,
FolderLoaderSpacesPersonal
FolderLoaderTrashbin
} from './folder/'

export * from './folder/util'
Expand Down Expand Up @@ -43,8 +42,7 @@ export class FolderService {
// legacy loaders
new FolderLoaderLegacyPersonal(),
// spaces loaders
new FolderLoaderSpacesPersonal(),
new FolderLoaderSpacesProject(),
new FolderLoaderSpacesGeneric(),
new FolderLoaderSpacesShare(),
// generic loaders
new FolderLoaderFavorites(),
Expand Down
3 changes: 1 addition & 2 deletions packages/web-app-files/src/services/folder/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
export * from './legacy/loaderPersonal'
export * from './spaces/loaderPersonal'
export * from './spaces/loaderProject'
export * from './spaces/loaderSpaceGeneric'
export * from './spaces/loaderShare'
export * from './loaderFavorites'
export * from './loaderPublicFiles'
Expand Down
95 changes: 0 additions & 95 deletions packages/web-app-files/src/services/folder/spaces/loaderProject.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
import { FolderLoader, FolderLoaderTask, TaskContext } from '../../folder'
import Router from 'vue-router'
import { useTask } from 'vue-concurrency'
import { DavProperties } from 'web-pkg/src/constants'
import { buildResource } from '../../../helpers/resources'
import { isLocationSpacesActive } from '../../../router'
import { buildResource } from '../../../helpers/resources'
import { DavProperties } from 'web-pkg/src/constants'
import { Store } from 'vuex'
import { fetchResources } from '../util'
import get from 'lodash-es/get'
import { useCapabilityShareJailEnabled } from 'web-pkg/src/composables'
import { getIndicators } from '../../../helpers/statusIndicators'
import { buildWebDavSpacesPath } from 'web-client/src/helpers'
import { fetchResources } from '../util'

export class FolderLoaderSpacesPersonal implements FolderLoader {
export class FolderLoaderSpacesGeneric implements FolderLoader {
public isEnabled(store: Store<any>): boolean {
return get(store, 'getters.capabilities.spaces.share_jail', false)
return get(store, 'getters.capabilities.spaces.enabled', false)
}

public isActive(router: Router): boolean {
return isLocationSpacesActive(router, 'files-spaces-personal')
return isLocationSpacesActive(router, 'files-spaces-generic')
}

public getTask(context: TaskContext): FolderLoaderTask {
Expand All @@ -27,21 +27,25 @@ export class FolderLoaderSpacesPersonal implements FolderLoader {
try {
store.commit('Files/CLEAR_CURRENT_FILES_LIST')

let resources = yield fetchResources(
const webDavResources = yield fetchResources(
clientService.owncloudSdk,
buildWebDavSpacesPath(
router.currentRoute.params.storageId,
path || router.currentRoute.params.item || ''
),
buildWebDavSpacesPath(ref.space.fileId, path || router.currentRoute.params.item || ''),
DavProperties.Default
)
resources = resources.map(buildResource)

let resources: any[]
if (!path) {
resources = [ref.space, ...webDavResources.slice(1).map(buildResource)]
} else {
resources = resources.map(buildResource)
}

const currentFolder = resources.shift()
const hasShareJail = useCapabilityShareJailEnabled(store)
yield store.dispatch('Files/loadSharesTree', {
client: clientService.owncloudSdk,
path: currentFolder.path
path: currentFolder.path,
storageId: ref.space.fileId
})

for (const file of resources) {
Expand All @@ -57,8 +61,8 @@ export class FolderLoaderSpacesPersonal implements FolderLoader {
console.error(error)
}

// FIXME: should not be part of the loader
ref.refreshFileListHeaderPosition()

ref.accessibleBreadcrumb_focusAndAnnounceBreadcrumb(sameRoute)
}).restartable()
}
Expand Down
13 changes: 9 additions & 4 deletions packages/web-app-files/src/views/Personal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -130,15 +130,20 @@ export default defineComponent({
KeyboardActions,
SideBar
},
mixins: [
MixinAccessibleBreadcrumb,
MixinFileActions,
MixinFilesListScrolling,
MixinFilesListFilter
],
setup() {
const storageId = useRouteParam('storageId')
props: {
space: {
type: Object,
required: false
}
},
setup(props) {
const storageId = props.space.fileId || useRouteParam('storageId')
const resourceTargetLocation = computed(() => {
return createLocationSpaces('files-spaces-personal', {
params: {
Expand Down Expand Up @@ -192,7 +197,7 @@ export default defineComponent({
$route: {
handler: async function (to, from) {
const needsRedirectWithStorageId =
to.params.storageId === 'home' || isNil(to.params.storageId)
to.params.storageId === 'home' || isNil(this.space.fileId)
if (needsRedirectWithStorageId) {
let storageId = this.user.id
if (this.hasShareJail) {
Expand Down
12 changes: 11 additions & 1 deletion packages/web-app-files/src/views/spaces/DriveResolver.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,27 @@
<p v-if="spacesLoading">Loading...</p>
<template v-else>
<p>Number of spaces loaded: {{ spaces.length }}</p>
<p v-if="space">found matching space. driveAlias: {{ space.driveAlias }}, item: {{ item }}</p>
<p v-if="space">
found matching space. {{ space.id }} driveAlias: {{ space.driveAlias }}, item: {{ item }}
</p>
<p v-else>no matching space found</p>
<Personal v-if="space.driveType === 'personal'" :space="space" />
<Project v-else :space="space" />
</template>
</div>
</template>

<script lang="ts">
import { computed, defineComponent, unref } from '@vue/composition-api'
import { useRouteParam, useStore } from 'web-pkg/src/composables'
import Personal from '../../views/Personal.vue'
import Project from '../../views/spaces/Project.vue'
export default defineComponent({
components: {
Personal,
Project
},
setup() {
const store = useStore()
const spacesLoading = computed(() => store.getters['runtime/spaces/spacesLoading'])
Expand Down
10 changes: 7 additions & 3 deletions packages/web-app-files/src/views/spaces/Project.vue
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@
import NoContentMessage from 'web-pkg/src/components/NoContentMessage.vue'
import NotFoundMessage from '../../components/FilesList/NotFoundMessage.vue'
import AppLoadingSpinner from 'web-pkg/src/components/AppLoadingSpinner.vue'
import { computed, defineComponent, ref } from '@vue/composition-api'
import { computed, defineComponent } from '@vue/composition-api'
import { marked } from 'marked'
import sanitizeHtml from 'sanitize-html'
import MixinAccessibleBreadcrumb from '../../mixins/accessibleBreadcrumb'
Expand Down Expand Up @@ -194,14 +194,18 @@ export default defineComponent({
currentSpace: computed(() => this.space)
}
},
props: {
space: {
type: Object,
required: true
}
},
setup() {
const store = useStore()
const space = ref({})
return {
...useResourcesViewDefaults(),
resourceTargetLocation: createLocationSpaces('files-spaces-project'),
space,
accessToken: useAccessToken({ store })
}
},
Expand Down

0 comments on commit a6128ed

Please sign in to comment.