Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion packages/web-pkg/src/composables/piniaStores/spaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,6 @@ export const useSpacesStore = defineStore('spaces', () => {
])

addSpaces([...personalSpaces, ...projectSpaces])
spacesInitialized.value = true
} finally {
spacesLoading.value = false
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { useClientService } from '../clientService'
import { urlJoin } from '@opencloud-eu/web-client'
import { useSpacesStore } from '../piniaStores'
import { DavProperty } from '@opencloud-eu/web-client/webdav'
import { useTask } from 'vue-concurrency'

export const useGetResourceContext = () => {
const clientService = useClientService()
Expand All @@ -25,7 +26,7 @@ export const useGetResourceContext = () => {
)
}

const loadFileInfoById = (fileId: string) => {
const loadFileInfoById = (fileId: string, signal?: AbortSignal) => {
const davProperties = [
DavProperty.FileId,
DavProperty.FileParent,
Expand All @@ -34,32 +35,32 @@ export const useGetResourceContext = () => {
]

const tmpSpace = buildSpace({ id: fileId, name: '' })
return clientService.webdav.getFileInfo(tmpSpace, { fileId }, { davProperties })
return clientService.webdav.getFileInfo(tmpSpace, { fileId }, { davProperties, signal })
}

// get context for a resource when only having its id. be careful, this might be very expensive!
const getResourceContext = async (id: string) => {
const resourceContextTask = useTask(function* (signal, id) {
let path: string
let resource: Resource
let space = getMatchingSpaceByFileId(id)

if (space) {
path = await clientService.webdav.getPathForFileId(id)
resource = await clientService.webdav.getFileInfo(space, { path })
path = yield clientService.webdav.getPathForFileId(id, { signal })
resource = yield clientService.webdav.getFileInfo(space, { path }, { signal })
return { space, resource, path }
}

// no matching space found => the file doesn't lie in own spaces => it's a share.
// do PROPFINDs on parents until root of accepted share is found in `mountpoint` spaces
await spacesStore.loadMountPoints({ graphClient: clientService.graphAuthenticated })
yield spacesStore.loadMountPoints({ graphClient: clientService.graphAuthenticated, signal })

let mountPoint = getMatchingMountPoint(id)
resource = await loadFileInfoById(id)
resource = yield loadFileInfoById(id, signal)
const sharePathSegments = mountPoint ? [] : [unref(resource).name]
let tmpResource = unref(resource)

while (!mountPoint) {
tmpResource = await loadFileInfoById(tmpResource.parentFolderId)
tmpResource = yield loadFileInfoById(tmpResource.parentFolderId, signal)
mountPoint = getMatchingMountPoint(tmpResource.id)
if (!mountPoint) {
sharePathSegments.unshift(tmpResource.name)
Expand All @@ -76,6 +77,11 @@ export const useGetResourceContext = () => {

path = urlJoin(...sharePathSegments)
return { space, resource, path }
}).restartable()

// get context for a resource when only having its id. be careful, this might be very expensive!
const getResourceContext = (id: string) => {
return resourceContextTask.perform(id)
}

return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,6 @@ describe('spaces', () => {
)
expect(instance.spaces.length).toBe(2)
expect(instance.spacesLoading).toBeFalsy()
expect(instance.spacesInitialized).toBeTruthy()
}
})
})
Expand Down
28 changes: 14 additions & 14 deletions packages/web-runtime/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ import Avatar from './components/Avatar.vue'
import { extensionPoints } from './extensionPoints'
import { isSilentRedirectRoute } from './helpers/silentRedirect'
import { extensions } from './extensions'
import { UnifiedRoleDefinition } from '@opencloud-eu/web-client/graph/generated'

export const bootstrapApp = async (configurationPath: string, appsReadyCallback: () => void) => {
const isSilentRedirect = isSilentRedirectRoute()
Expand Down Expand Up @@ -202,13 +203,18 @@ export const bootstrapApp = async (configurationPath: string, appsReadyCallback:
return
}

await announceConfiguration({
path: configurationPath,
configStore,
token: authStore.accessToken
})

const clientService = app.config.globalProperties.$clientService

const [graphRoleDefinitions] = await Promise.all([
clientService.graphAuthenticated.permissions.listRoleDefinitions(),
spacesStore.loadSpaces({ graphClient: clientService.graphAuthenticated }),
announceConfiguration({
path: configurationPath,
configStore,
token: authStore.accessToken
})
])

const previewService = app.config.globalProperties.$previewService
const passwordPolicyService = app.config.globalProperties.passwordPolicyService
passwordPolicyService.initialize(capabilityStore)
Expand All @@ -229,22 +235,16 @@ export const bootstrapApp = async (configurationPath: string, appsReadyCallback:
})
}

// load sharing roles from graph API
const graphRoleDefinitions =
await clientService.graphAuthenticated.permissions.listRoleDefinitions()
sharesStore.setGraphRoles(graphRoleDefinitions)

// Load spaces to make them available across the application
await spacesStore.loadSpaces({ graphClient: clientService.graphAuthenticated })
sharesStore.setGraphRoles(graphRoleDefinitions as UnifiedRoleDefinition[])
const personalSpace = spacesStore.spaces.find(isPersonalSpaceResource)

if (personalSpace) {
spacesStore.updateSpaceField({
id: personalSpace.id,
field: 'name',
value: app.config.globalProperties.$gettext('Personal')
})
}
spacesStore.setSpacesInitialized(true)
},
{
immediate: true
Expand Down
Loading