diff --git a/packages/web-app-files/src/services/folder/loaderSpace.ts b/packages/web-app-files/src/services/folder/loaderSpace.ts index a8a9d91525f..350578b2ff9 100644 --- a/packages/web-app-files/src/services/folder/loaderSpace.ts +++ b/packages/web-app-files/src/services/folder/loaderSpace.ts @@ -51,14 +51,17 @@ export class FolderLoaderSpace implements FolderLoader { options: FolderLoaderOptions = {} ) { try { + console.log('FOLDER LOADER') store.commit('Files/CLEAR_CURRENT_FILES_LIST') - + console.log('path', path) + console.log('fileId', fileId) const resources = yield webdav.listFiles(space, { path, fileId }) let currentFolder = resources.shift() - replaceInvalidFileRoute({ space, resource: currentFolder, path, fileId }) + console.log('currentFolder', currentFolder.path) + // replaceInvalidFileRoute({ space, resource: currentFolder, path, fileId }) if (path === '/') { - if (space.driveType === 'share') { + if (space.driveType === 'share' && space.shareId) { const parentShare = yield client.shares.getShare(space.shareId) const aggregatedShares = aggregateResourceShares( [parentShare.shareInfo], @@ -67,7 +70,7 @@ export class FolderLoaderSpace implements FolderLoader { true ) currentFolder = aggregatedShares[0] - } else if (!['personal', 'public'].includes(space.driveType)) { + } else if (!['personal', 'public', 'share'].includes(space.driveType)) { // note: in the future we might want to show the space as root for personal spaces as well (to show quota and the like). Currently not needed. currentFolder = space } diff --git a/packages/web-client/src/helpers/space/functions.ts b/packages/web-client/src/helpers/space/functions.ts index 56bef530e7f..6c1230ef692 100644 --- a/packages/web-client/src/helpers/space/functions.ts +++ b/packages/web-client/src/helpers/space/functions.ts @@ -38,17 +38,18 @@ export function buildShareSpaceResource({ shareName, serverUrl }: { - shareId: string | number + shareId?: string | number shareName: string serverUrl: string }): ShareSpaceResource { const space = buildSpace({ - id: [SHARE_JAIL_ID, shareId].join('!'), + id: [SHARE_JAIL_ID, shareId].filter(Boolean).join('!'), driveAlias: `share/${shareName}`, driveType: 'share', name: shareName, shareId, - serverUrl + serverUrl, + ...(!shareId && { webDavPath: buildWebDavSpacesPath(SHARE_JAIL_ID, shareName) }) }) as ShareSpaceResource space.rename = (newName: string) => { space.driveAlias = `share/${newName}` diff --git a/packages/web-client/src/helpers/space/types.ts b/packages/web-client/src/helpers/space/types.ts index 5ab8306513e..400a7c9556d 100644 --- a/packages/web-client/src/helpers/space/types.ts +++ b/packages/web-client/src/helpers/space/types.ts @@ -8,7 +8,7 @@ // or all types get different members, the underscored props can be removed. import { Resource } from '../resource' -export const SHARE_JAIL_ID = 'a0ca6a90-a365-4782-871e-d44447bbc668' +export const SHARE_JAIL_ID = 'a0ca6a90-a365-4782-871e-d44447bbc668$a0ca6a90-a365-4782-871e-d44447bbc668' export interface SpaceResource extends Resource { disabled?: boolean diff --git a/packages/web-pkg/src/composables/driveResolver/useDriveResolver.ts b/packages/web-pkg/src/composables/driveResolver/useDriveResolver.ts index a3bb4ee8ed5..38ca0a0d1c4 100644 --- a/packages/web-pkg/src/composables/driveResolver/useDriveResolver.ts +++ b/packages/web-pkg/src/composables/driveResolver/useDriveResolver.ts @@ -64,6 +64,8 @@ export const useDriveResolver = (options: DriveResolverOptions = {}) => { serverUrl: configurationManager.serverUrl }) path = item.join('/') + console.log('drive resolver: matching space', matchingSpace) + console.log('drive resolver: path', path) } else { if (unref(hasSpaces) && unref(fileId)) { matchingSpace = unref(spaces).find((s) => { diff --git a/packages/web-runtime/src/pages/resolveAliasLink.vue b/packages/web-runtime/src/pages/resolveAliasLink.vue index 9fc874732cf..ee6ea34a7bd 100644 --- a/packages/web-runtime/src/pages/resolveAliasLink.vue +++ b/packages/web-runtime/src/pages/resolveAliasLink.vue @@ -8,15 +8,17 @@ import { useRouteParam, useStore, useTranslations, - useUserContext, useRouter } from "web-pkg/src/composables"; import { unref, ref, defineComponent, computed, onMounted } from "@vue/composition-api"; -import { authService } from "../services/auth"; import { useLoadTokenInfo } from "../composables/tokenInfo"; import { clientService } from "web-pkg/src/services"; import { createLocationSpaces } from "files/src/router"; import {urlJoin} from "web-pkg/src/utils"; +import {buildShareSpaceResource} from "web-client/src/helpers"; +import {configurationManager} from "web-pkg/src/configuration"; +import {createFileRouteOptions} from "web-pkg/src/helpers/router"; +import {dirname} from "path"; export default defineComponent({ name: 'ResolveAliasLink', @@ -26,16 +28,10 @@ export default defineComponent({ const route = useRoute() const token = useRouteParam('token') const { $gettext } = useTranslations() - const isUserContext = useUserContext({ store }) const { loadTokenInfoTask } = useLoadTokenInfo(unref(token)) const tokenInfo = ref(undefined) onMounted(async () => { - if (!unref(isUserContext)) { - await authService.loginUser() - return router.push({ name: '/login' }) - } - tokenInfo.value = await loadTokenInfoTask.perform() resolveAliasLink() }) @@ -44,25 +40,38 @@ export default defineComponent({ const resolveAliasLink = async () => { const { id, storage_id: storageId, space_id: spaceId } = unref(tokenInfo) - const path = await clientService.owncloudSdk.files.getPathForFileId(id) - const matchingSpace = getMatchingSpace(`${storageId}$${spaceId}`) + let path = await clientService.owncloudSdk.files.getPathForFileId(id) + let matchingSpace = getMatchingSpace(`${storageId}$${spaceId}`) + + if (!matchingSpace){ + const [shareName, ...pathSegments] = path.split('/').filter(Boolean) + matchingSpace = buildShareSpaceResource({ + shareName, + serverUrl: configurationManager.serverUrl + }) + path = urlJoin(pathSegments) + } + + console.log('mathcing space', matchingSpace) + console.log('path', path) + const resource = await clientService.webdav.getFileInfo(matchingSpace, { path }) - let driveAliasPath let scrollTo + let fileId if (resource.type !== 'file') { - driveAliasPath = path + fileId = resource.fileId scrollTo = '' } else { - driveAliasPath = '' + path = dirname(path) + fileId = resource.parentFolderId scrollTo = path } + const {params, query} = createFileRouteOptions(matchingSpace, {fileId, path}) const location = createLocationSpaces('files-spaces-generic', { - params: { - driveAliasAndItem: matchingSpace.getDriveAliasAndItem({ path: driveAliasPath }) - }, - query: { scrollTo: urlJoin(scrollTo, { leadingSlash: false }) } + params, + query: {...query, scrollTo: urlJoin(scrollTo, { leadingSlash: false }) } }) return router.push(location) }