diff --git a/plugins/document-resources/src/components/NewDocumentHeader.svelte b/plugins/document-resources/src/components/NewDocumentHeader.svelte index 3db2d8fc46..83fb505561 100644 --- a/plugins/document-resources/src/components/NewDocumentHeader.svelte +++ b/plugins/document-resources/src/components/NewDocumentHeader.svelte @@ -36,11 +36,13 @@ const client = getClient() const query = createQuery() + const me = getCurrentAccount() + let loading = true let hasTeamspace = false query.query( document.class.Teamspace, - { archived: false }, + { archived: false, members: me._id }, (res) => { hasTeamspace = res.length > 0 loading = false @@ -73,7 +75,7 @@ } } - const dropdownItems = hasAccountRole(getCurrentAccount(), AccountRole.User) + const dropdownItems = hasAccountRole(me, AccountRole.User) ? [ { id: document.string.CreateDocument, label: document.string.CreateDocument }, { id: document.string.CreateTeamspace, label: document.string.CreateTeamspace } diff --git a/plugins/drive-resources/src/components/CreateFolder.svelte b/plugins/drive-resources/src/components/CreateFolder.svelte index 9e9dda5105..e386281434 100644 --- a/plugins/drive-resources/src/components/CreateFolder.svelte +++ b/plugins/drive-resources/src/components/CreateFolder.svelte @@ -28,8 +28,8 @@ return name === '' } - export let space: Ref - export let parent: Ref + export let space: Ref | undefined + export let parent: Ref | undefined const id: Ref = generateId() @@ -48,6 +48,10 @@ } async function create (): Promise { + if (_space === undefined) { + return + } + let path: Ref[] = [] if (_parent != null && _parent !== drive.ids.Root) { @@ -60,7 +64,7 @@ await client.createDoc( drive.class.Folder, - space, + _space, { name: getTitle(name), parent: _parent ?? drive.ids.Root, diff --git a/plugins/drive-resources/src/components/DriveSpaceHeader.svelte b/plugins/drive-resources/src/components/DriveSpaceHeader.svelte index d82fec057f..46a54f693f 100644 --- a/plugins/drive-resources/src/components/DriveSpaceHeader.svelte +++ b/plugins/drive-resources/src/components/DriveSpaceHeader.svelte @@ -25,13 +25,15 @@ export let currentSpace: Ref | undefined export let currentFragment: string | undefined + const me = getCurrentAccount() + const query = createQuery() let loading = true let hasDrive = false query.query( drive.class.Drive, - { archived: false }, + { archived: false, members: me._id }, (res) => { hasDrive = res.length > 0 loading = false @@ -56,9 +58,7 @@ } async function handleCreateFolder (): Promise { - if (currentSpace !== undefined) { - await createFolder(currentSpace, parent, true) - } + await createFolder(currentSpace, parent, true) } async function handleUploadFile (): Promise { @@ -67,7 +67,7 @@ } } - const dropdownItems = hasAccountRole(getCurrentAccount(), AccountRole.User) + const dropdownItems = hasAccountRole(me, AccountRole.User) ? [ { id: drive.string.CreateDrive, label: drive.string.CreateDrive, icon: drive.icon.Drive }, { id: drive.string.CreateFolder, label: drive.string.CreateFolder, icon: drive.icon.Folder }, diff --git a/plugins/drive-resources/src/utils.ts b/plugins/drive-resources/src/utils.ts index 474e3fc949..c69a9d3098 100644 --- a/plugins/drive-resources/src/utils.ts +++ b/plugins/drive-resources/src/utils.ts @@ -31,7 +31,7 @@ async function navigateToDoc (_id: Ref, _class: Ref>): Promise, parent: Ref, open = false): Promise { +export async function createFolder (space: Ref | undefined, parent: Ref, open = false): Promise { showPopup(CreateFolder, { space, parent }, 'top', async (id) => { if (open && id !== undefined && id !== null) { await navigateToDoc(id, drive.class.Folder)