Short link fixes (#2744)

Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
Denis Bykhov 2023-03-16 09:44:21 +06:00 committed by GitHub
parent 0c1b13f5e7
commit 032f632105
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 54 additions and 29 deletions

View File

@ -212,7 +212,7 @@ async function generateLocation (loc: Location, shortLink: string): Promise<Loca
const panelComponent = hierarchy.as(targetClass, view.mixin.ObjectPanel)
const component = panelComponent.component ?? view.component.EditDoc
return {
path: [appComponent, workspace, chunterId],
path: [appComponent, workspace],
fragment: getPanelURI(component, comment.attachedTo, comment.attachedToClass, 'content')
}
}

View File

@ -13,13 +13,28 @@
// limitations under the License.
-->
<script lang="ts">
import { Organization } from '@hcengineering/contact'
import { Avatar } from '@hcengineering/presentation'
import { closePanel, closePopup, closeTooltip, getCurrentLocation, Label, navigate } from '@hcengineering/ui'
import attachment from '@hcengineering/attachment'
import { Channel, Organization } from '@hcengineering/contact'
import { Avatar, createQuery } from '@hcengineering/presentation'
import { Component, Label } from '@hcengineering/ui'
import { DocNavLink } from '@hcengineering/view-resources'
import contact from '../plugin'
import ChannelsEditor from './ChannelsEditor.svelte'
export let organization: Organization
export let disabled: boolean = false
let channels: Channel[] = []
const channelsQuery = createQuery()
channelsQuery.query(
contact.class.Channel,
{
attachedTo: organization._id
},
(res) => {
channels = res
}
)
</script>
<div class="flex-col h-full card-container">
@ -29,26 +44,29 @@
</div>
{#if organization}
<!-- svelte-ignore a11y-click-events-have-key-events -->
<div
class="name lines-limit-2"
class:over-underline={!disabled}
on:click={() => {
if (!disabled) {
closeTooltip()
closePopup()
closePanel()
const loc = getCurrentLocation()
loc.path[3] = organization._id
loc.path.length = 4
navigate(loc)
}
}}
>
{organization.name}
<DocNavLink object={organization} disableClick={disabled}>
<div class="name lines-limit-2">
{organization.name}
</div>
</DocNavLink>
<div class="footer flex flex-reverse flex-grow">
<div class="flex-center flex-wrap">
<Component
is={attachment.component.AttachmentsPresenter}
props={{ value: organization.attachments, object: organization, size: 'medium', showCounter: true }}
/>
</div>
{#if channels[0]}
<div class="flex flex-grow">
<ChannelsEditor
attachedTo={channels[0].attachedTo}
attachedClass={channels[0].attachedToClass}
length={'short'}
editable={false}
/>
</div>
{/if}
</div>
{#if organization}
<span class="label">{organization.name}</span>
{/if}
{/if}
</div>

View File

@ -220,7 +220,7 @@ async function generateLocation (loc: Location, shortLink: string): Promise<Loca
const appComponent = loc.path[0] ?? ''
const workspace = loc.path[1] ?? ''
return {
path: [appComponent, workspace, contactId],
path: [appComponent, workspace],
fragment: getPanelURI(view.component.EditDoc, doc._id, doc._class, 'content')
}
}

View File

@ -69,7 +69,7 @@ async function generateLocation (loc: Location, shortLink: string): Promise<Loca
const panelComponent = hierarchy.as(targetClass, view.mixin.ObjectPanel)
const component = panelComponent.component ?? view.component.EditDoc
return {
path: [appComponent, workspace, recruitId],
path: [appComponent, workspace],
fragment: getPanelURI(component, doc._id, doc._class, 'content')
}
}

View File

@ -35,6 +35,7 @@
loc.path[4] = 'projects'
loc.path[5] = value._id
loc.path.length = 6
loc.fragment = undefined
navigate(loc)
}
</script>

View File

@ -78,7 +78,7 @@ export async function generateIssueLocation (loc: Location, issueId: string): Pr
const appComponent = loc.path[0] ?? ''
const workspace = loc.path[1] ?? ''
return {
path: [appComponent, workspace, trackerId, team._id, 'issues'],
path: [appComponent, workspace],
fragment: generateIssuePanelUri(issue)
}
}

View File

@ -220,11 +220,17 @@
// resolve short links
const resolvedLocation = await resolveShortLink(loc)
if (resolvedLocation && !areLocationsEqual(loc, resolvedLocation)) {
loc.path[2] = app = resolvedLocation.path[2] ?? app
loc.path[3] = space = (resolvedLocation.path[3] as Ref<Space>) ?? space
if (app !== resolvedLocation.path[2] && resolvedLocation.path[2] !== undefined) {
loc.path[2] = app = resolvedLocation.path[2] ?? app
loc.path[3] = space = (resolvedLocation.path[3] as Ref<Space>) ?? space
loc.path[4] = special = resolvedLocation.path[4] ?? special
} else if (space !== (resolvedLocation.path[3] as Ref<Space>) && resolvedLocation.path[3] !== undefined) {
loc.path[3] = space = (resolvedLocation.path[3] as Ref<Space>) ?? space
loc.path[4] = special = resolvedLocation.path[4] ?? special
}
loc.path[4] = special = resolvedLocation.path[4] ?? special
loc.fragment = fragment = resolvedLocation.fragment ?? fragment
navigate(resolvedLocation, false)
navigate(loc, false)
}
if (currentAppAlias !== app) {