UBER-532: Copy issue URL works wrong (#3529)

Signed-off-by: Maxim Karmatskikh <mkarmatskih@gmail.com>
This commit is contained in:
Maksim Karmatskikh 2023-08-02 10:42:43 +06:00 committed by GitHub
parent 3c376696f6
commit 1d064072c2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 42 additions and 26 deletions

View File

@ -17,6 +17,10 @@
import { CheckBox, Component, navigate, parseLocation } from '@hcengineering/ui'
import view from '@hcengineering/view'
import { getMetadata } from '@hcengineering/platform'
import presentation from '../../plugin'
export let nodes: NodeListOf<any>
function prevName (pos: number, nodes: NodeListOf<any>): string | undefined {
@ -29,6 +33,21 @@
}
return nodes[pos - 1]?.nodeName
}
function handleLink (node: HTMLElement, e: MouseEvent) {
try {
const href = node.getAttribute('href')
if (href) {
const url = new URL(href)
const frontUrl = getMetadata(presentation.metadata.FrontUrl) ?? window.location.origin
if (url.origin === frontUrl) {
e.preventDefault()
navigate(parseLocation(url))
}
}
} catch {}
}
</script>
{#if nodes}
@ -81,20 +100,9 @@
{:else if node.nodeName === 'DIV'}
<div><svelte:self nodes={node.childNodes} /></div>
{:else if node.nodeName === 'A'}
<a
href={node.getAttribute('href')}
target={node.getAttribute('target')}
on:click={(e) => {
try {
const url = new URL(node.getAttribute('href'))
if (url.origin === window.location.origin) {
e.preventDefault()
navigate(parseLocation(url))
}
} catch {}
}}><svelte:self nodes={node.childNodes} /></a
>
<a href={node.getAttribute('href')} target={node.getAttribute('target')} on:click={(e) => handleLink(node, e)}>
<svelte:self nodes={node.childNodes} />
</a>
{:else if node.nodeName === 'LABEL'}
<svelte:self nodes={node.childNodes} />
{:else if node.nodeName === 'INPUT'}

View File

@ -15,7 +15,8 @@
<script lang="ts">
import { AccountRole, getCurrentAccount, Timestamp } from '@hcengineering/core'
import { loginId } from '@hcengineering/login'
import { copyTextToClipboard, createQuery } from '@hcengineering/presentation'
import { getMetadata } from '@hcengineering/platform'
import presentation, { copyTextToClipboard, createQuery } from '@hcengineering/presentation'
import setting from '@hcengineering/setting'
import {
Button,
@ -79,7 +80,10 @@
loc.fragment = undefined
const url = locationToUrl(loc)
link = document.location.origin + url
const frontUrl = getMetadata(presentation.metadata.FrontUrl)
const host = frontUrl ?? document.location.origin
link = host + url
loading = false
}

View File

@ -1,6 +1,7 @@
import contact, { getName } from '@hcengineering/contact'
import { Class, Client, Doc, Hierarchy, Ref } from '@hcengineering/core'
import { getClient } from '@hcengineering/presentation'
import presentation, { getClient } from '@hcengineering/presentation'
import { getMetadata } from '@hcengineering/platform'
import { Applicant, Candidate, Review, Vacancy, VacancyList, recruitId } from '@hcengineering/recruit'
import { Location, ResolvedLocation, getCurrentResolvedLocation, getPanelURI } from '@hcengineering/ui'
import view from '@hcengineering/view'
@ -11,11 +12,9 @@ type RecruitDocument = Vacancy | Applicant | Review
export async function objectLinkProvider (doc: RecruitDocument): Promise<string> {
const location = getCurrentResolvedLocation()
return await Promise.resolve(
`${window.location.protocol}//${window.location.host}/${workbenchId}/${
location.path[1]
}/${recruitId}/${await getSequenceId(doc)}`
)
const frontUrl = getMetadata(presentation.metadata.FrontUrl) ?? window.location.origin
const url = `${frontUrl}/${workbenchId}/${location.path[1]}/${recruitId}/${await getSequenceId(doc)}`
return url
}
function isShortId (shortLink: string): boolean {

View File

@ -1,5 +1,6 @@
<script lang="ts">
import { copyTextToClipboard, createQuery } from '@hcengineering/presentation'
import presentation, { copyTextToClipboard, createQuery } from '@hcengineering/presentation'
import { getMetadata } from '@hcengineering/platform'
import { Issue, IssueStatus } from '@hcengineering/tracker'
import view from '@hcengineering/view'
import {
@ -77,8 +78,9 @@
const handleIssueOpened = () => {
if (params?.issueUrl) {
const url = new URL(params?.issueUrl)
const frontUrl = getMetadata(presentation.metadata.FrontUrl) ?? window.location.origin
if (url.origin === window.location.origin) {
if (url.origin === frontUrl) {
navigate(parseLocation(url))
}
}

View File

@ -1,5 +1,6 @@
import { Doc, DocumentUpdate, Ref, RelatedDocument, TxOperations } from '@hcengineering/core'
import { getClient } from '@hcengineering/presentation'
import presentation, { getClient } from '@hcengineering/presentation'
import { getMetadata } from '@hcengineering/platform'
import { Component, Issue, Project, Milestone, trackerId } from '@hcengineering/tracker'
import { Location, ResolvedLocation, getPanelURI, getCurrentResolvedLocation } from '@hcengineering/ui'
import { workbenchId } from '@hcengineering/workbench'
@ -64,7 +65,9 @@ export async function issueLinkProvider (doc: Doc): Promise<string> {
export function generateIssueShortLink (issueId: string): string {
const location = getCurrentResolvedLocation()
return `${window.location.protocol}//${window.location.host}/${workbenchId}/${location.path[1]}/${trackerId}/${issueId}`
const frontUrl = getMetadata(presentation.metadata.FrontUrl)
const protocolAndHost = frontUrl ?? `${window.location.protocol}//${window.location.host}`
return `${protocolAndHost}/${workbenchId}/${location.path[1]}/${trackerId}/${issueId}`
}
export async function generateIssueLocation (loc: Location, issueId: string): Promise<ResolvedLocation | undefined> {