UBERF-9173 Fix links navigation (#7715)

Signed-off-by: Alexander Onnikov <Alexander.Onnikov@xored.com>
This commit is contained in:
Alexander Onnikov 2025-01-20 15:24:39 +07:00 committed by GitHub
parent 46084e0c82
commit 2613e625c9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 21 additions and 8 deletions

View File

@ -13,7 +13,8 @@
// limitations under the License. // limitations under the License.
--> -->
<script lang="ts"> <script lang="ts">
import { closePopup, closeTooltip, navigate, parseLocation } from '@hcengineering/ui' import { getMetadata } from '@hcengineering/platform'
import uiPlugin, { closePopup, closeTooltip, navigate, parseLocation } from '@hcengineering/ui'
export let href: string | undefined export let href: string | undefined
export let disabled = false export let disabled = false
@ -43,11 +44,16 @@
closeTooltip() closeTooltip()
try { try {
const url = new URL(href) const url = new URL(href)
if (url.origin === window.location.origin) { if (url.origin === window.location.origin) {
const loc = parseLocation(url)
const routes = getMetadata(uiPlugin.metadata.Routes)
const app = routes?.get(loc.path[0])
if (app !== undefined) {
e.preventDefault() e.preventDefault()
e.stopPropagation() e.stopPropagation()
navigate(parseLocation(url)) navigate(loc)
}
} }
} catch {} } catch {}
} }

View File

@ -15,7 +15,7 @@
<script lang="ts"> <script lang="ts">
import { getMetadata } from '@hcengineering/platform' import { getMetadata } from '@hcengineering/platform'
import { MarkupMark, MarkupMarkType } from '@hcengineering/text' import { MarkupMark, MarkupMarkType } from '@hcengineering/text'
import { navigate, parseLocation } from '@hcengineering/ui' import uiPlugin, { navigate, parseLocation } from '@hcengineering/ui'
import presentation from '../../plugin' import presentation from '../../plugin'
@ -29,8 +29,15 @@
const frontUrl = getMetadata(presentation.metadata.FrontUrl) ?? window.location.origin const frontUrl = getMetadata(presentation.metadata.FrontUrl) ?? window.location.origin
if (url.origin === frontUrl) { if (url.origin === frontUrl) {
const loc = parseLocation(url)
const routes = getMetadata(uiPlugin.metadata.Routes)
const app = routes?.get(loc.path[0])
if (app !== undefined) {
e.preventDefault() e.preventDefault()
navigate(parseLocation(url)) e.stopPropagation()
navigate(loc)
}
} }
} }
} catch (err) { } catch (err) {