From 2e028e913e944bd87c379f20079b4d517d97ec88 Mon Sep 17 00:00:00 2001 From: Denis Bykhov Date: Fri, 1 Mar 2024 00:13:46 +0600 Subject: [PATCH] Fix guests links (#4839) Signed-off-by: Denis Bykhov --- plugins/guest-resources/src/components/Guest.svelte | 3 +++ plugins/guest-resources/src/utils.ts | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/plugins/guest-resources/src/components/Guest.svelte b/plugins/guest-resources/src/components/Guest.svelte index 8b323138bf..bfdd67fba8 100644 --- a/plugins/guest-resources/src/components/Guest.svelte +++ b/plugins/guest-resources/src/components/Guest.svelte @@ -56,6 +56,9 @@ const link = await client.findOne(guest.class.PublicLink, { _id: decoded.linkId }) if (link == null) return false restrictionStore.set(link.restrictions) + const mergedLoc = link.location + mergedLoc.path[0] = loc.path[0] + mergedLoc.path[1] = loc.path[1] await doSyncLoc(link.location) return true } diff --git a/plugins/guest-resources/src/utils.ts b/plugins/guest-resources/src/utils.ts index 5b68c58d78..8ad04dfb9a 100644 --- a/plugins/guest-resources/src/utils.ts +++ b/plugins/guest-resources/src/utils.ts @@ -6,6 +6,7 @@ import presentation from '@hcengineering/presentation' import { fetchMetadataLocalStorage, getCurrentLocation, navigate } from '@hcengineering/ui' import view from '@hcengineering/view' import { getObjectLinkFragment } from '@hcengineering/view-resources' +import { workbenchId } from '@hcengineering/workbench' export async function checkAccess (doc: Doc): Promise { const loc = getCurrentLocation() @@ -18,13 +19,15 @@ export async function checkAccess (doc: Doc): Promise { const clientFactory = await getResource(client.function.GetClient) const _client = await clientFactory(token, endpoint) - const res = _client.findOne(doc._class, { _id: doc._id }) + const res = await _client.findOne(doc._class, { _id: doc._id }) const hierarchy = _client.getHierarchy() await _client.close() if (res !== undefined) { const panelComponent = hierarchy.classHierarchyMixin(doc._class, view.mixin.ObjectPanel) const comp = panelComponent?.component ?? view.component.EditDoc const loc = await getObjectLinkFragment(hierarchy, doc, {}, comp) + loc.path[0] = workbenchId + loc.path[1] = ws // We have access, let's set correct tokens and redirect) setMetadata(presentation.metadata.Token, token) navigate(loc)