From 899782677731942861e3c4b979c7c83c8b49058c Mon Sep 17 00:00:00 2001 From: Pascal Wengerter Date: Mon, 9 May 2022 11:14:51 +0200 Subject: [PATCH] Fix personal drive ID in personal space/upload --- .../enhancement-introduce-sharing-jail | 9 +++ .../unreleased/enhancement-resumeable-uploads | 1 + .../src/components/AppBar/CreateAndUpload.vue | 60 +++++++------------ .../services/folder/spaces/loaderPersonal.ts | 8 +-- 4 files changed, 34 insertions(+), 44 deletions(-) create mode 100644 changelog/unreleased/enhancement-introduce-sharing-jail diff --git a/changelog/unreleased/enhancement-introduce-sharing-jail b/changelog/unreleased/enhancement-introduce-sharing-jail new file mode 100644 index 00000000000..5c46a014674 --- /dev/null +++ b/changelog/unreleased/enhancement-introduce-sharing-jail @@ -0,0 +1,9 @@ +Enhancement: Introduce sharing jail + +We've added the sharing jail to oCIS which means that navigating and +working with shares now happens inside the `Shares` navigation item. + +https://github.com/owncloud/web/pull/6593 +https://github.com/owncloud/web/pull/6909 +https://github.com/owncloud/web/issues/5152 +https://github.com/owncloud/web/issues/6448 diff --git a/changelog/unreleased/enhancement-resumeable-uploads b/changelog/unreleased/enhancement-resumeable-uploads index df429090a42..8ea012baff1 100644 --- a/changelog/unreleased/enhancement-resumeable-uploads +++ b/changelog/unreleased/enhancement-resumeable-uploads @@ -9,4 +9,5 @@ We've implemented Uppy as a library for handling uploads. This concludes the fol - Removed `vue2-dropzone` and `vue-drag-drop` libraries https://github.com/owncloud/web/pull/6202 +https://github.com/owncloud/web/issues/5031 https://github.com/owncloud/web/issues/6268 diff --git a/packages/web-app-files/src/components/AppBar/CreateAndUpload.vue b/packages/web-app-files/src/components/AppBar/CreateAndUpload.vue index cc0ea12dfb0..fa19a033f7e 100644 --- a/packages/web-app-files/src/components/AppBar/CreateAndUpload.vue +++ b/packages/web-app-files/src/components/AppBar/CreateAndUpload.vue @@ -167,6 +167,22 @@ export default defineComponent({ path: '', fileFolderCreationLoading: false }), + asyncComputed: { + personalDriveId: { + async get() { + const graphClient = clientService.graphAuthenticated( + this.configuration.server, + this.getToken + ) + + const drivesResponse = await graphClient.drives.listMyDrives('', 'driveType eq personal') + if (!drivesResponse.data) { + throw new Error('No personal space found') + } + return drivesResponse.data.value[0].id + } + } + }, computed: { ...mapGetters(['getToken', 'capabilities', 'configuration', 'newFileHandlers', 'user']), ...mapGetters('Files', ['files', 'currentFolder', 'publicLinkPassword']), @@ -268,16 +284,7 @@ export default defineComponent({ if (this.isPersonalLocation) { if (this.hasShareJail) { - const graphClient = clientService.graphAuthenticated( - this.configuration.server, - this.getToken - ) - const userResponse = await graphClient.users.getMe() - if (!userResponse.data) { - console.error('graph.user.getMe() has no data') - return - } - path = buildWebDavSpacesPath(userResponse.data.id, path || '') + path = buildWebDavSpacesPath(this.personalDriveId, path || '') } else { path = buildWebDavFilesPath(this.user.id, path) } @@ -400,16 +407,7 @@ export default defineComponent({ if (this.isPersonalLocation) { if (this.hasShareJail) { - const graphClient = clientService.graphAuthenticated( - this.configuration.server, - this.getToken - ) - const userResponse = await graphClient.users.getMe() - if (!userResponse.data) { - console.error('graph.user.getMe() has no data') - return - } - path = buildWebDavSpacesPath(userResponse.data.id, path || '') + path = buildWebDavSpacesPath(this.personalDriveId, path || '') } else { path = buildWebDavFilesPath(this.user.id, path) } @@ -506,16 +504,7 @@ export default defineComponent({ if (this.isPersonalLocation) { if (this.hasShareJail) { - const graphClient = clientService.graphAuthenticated( - this.configuration.server, - this.getToken - ) - const userResponse = await graphClient.users.getMe() - if (!userResponse.data) { - console.error('graph.user.getMe() has no data') - return - } - path = buildWebDavSpacesPath(userResponse.data.id, path || '') + path = buildWebDavSpacesPath(this.personalDriveId, path || '') } else { path = buildWebDavFilesPath(this.user.id, path) } @@ -597,16 +586,7 @@ export default defineComponent({ let path = pathUtil.join(this.currentPath, fileName) if (this.isPersonalLocation) { if (this.hasShareJail) { - const graphClient = clientService.graphAuthenticated( - this.configuration.server, - this.getToken - ) - const userResponse = await graphClient.users.getMe() - if (!userResponse.data) { - console.error('graph.user.getMe() has no data') - return - } - path = buildWebDavSpacesPath(userResponse.data.id, path || '') + path = buildWebDavSpacesPath(this.personalDriveId, path || '') } else { path = buildWebDavFilesPath(this.user.id, path) } diff --git a/packages/web-app-files/src/services/folder/spaces/loaderPersonal.ts b/packages/web-app-files/src/services/folder/spaces/loaderPersonal.ts index 32fde450654..f55422d5a9e 100644 --- a/packages/web-app-files/src/services/folder/spaces/loaderPersonal.ts +++ b/packages/web-app-files/src/services/folder/spaces/loaderPersonal.ts @@ -29,15 +29,15 @@ export class FolderLoaderSpacesPersonal implements FolderLoader { try { store.commit('Files/CLEAR_CURRENT_FILES_LIST') - const userResponse = yield graphClient.users.getMe() - if (!userResponse.data) { - throw new Error('graph.user.getMe() has no data') + const drivesResponse = yield graphClient.drives.listMyDrives('', 'driveType eq personal') + if (!drivesResponse.data) { + throw new Error('No personal space found') } let resources = yield fetchResources( clientService.owncloudSdk, buildWebDavSpacesPath( - userResponse.data.id, + drivesResponse.data.value[0].id, path || router.currentRoute.params.item || '' ), DavProperties.Default