Fix resolved loc (#3046)

Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
Denis Bykhov 2023-04-21 22:24:45 +06:00 committed by GitHub
parent fb240d0316
commit 52e57db99e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
44 changed files with 386 additions and 347 deletions

File diff suppressed because it is too large Load Diff

View File

@ -36,6 +36,7 @@
"@hcengineering/platform": "^0.6.8",
"@hcengineering/theme": "^0.6.2",
"@hcengineering/core": "^0.6.23",
"just-clone": "~6.2.0",
"svelte": "3.55.1",
"fast-equals": "^2.0.3"
},

View File

@ -158,6 +158,7 @@
<style lang="scss">
.panel-instance {
opacity: 0.5;
z-index: 401;
position: fixed;
background-color: transparent;

View File

@ -13,9 +13,10 @@
// limitations under the License.
//
import { writable, derived } from 'svelte/store'
import { Location as PlatformLocation } from './types'
import { derived, writable } from 'svelte/store'
import { closePopup } from './popups'
import justClone from 'just-clone'
import { Location as PlatformLocation } from './types'
export function locationToUrl (location: PlatformLocation): string {
let result = '/'
@ -103,12 +104,23 @@ export function getCurrentLocation (): PlatformLocation {
return parseLocation(window.location)
}
export function getCurrentResolvedLocation (): PlatformLocation {
return justClone(resolvedLocation)
}
const locationWritable = writable(getCurrentLocation())
window.addEventListener('popstate', () => {
locationWritable.set(getCurrentLocation())
})
export const location = derived(locationWritable, (loc) => loc)
export const resolvedLocationStore = writable(getCurrentLocation())
let resolvedLocation = getCurrentLocation()
export function setResolvedLocation (location: PlatformLocation): void {
resolvedLocation = location
resolvedLocationStore.set(justClone(location))
}
export function navigate (location: PlatformLocation, store = true): void {
closePopup()

View File

@ -12,8 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//
import type { Asset, IntlString } from '@hcengineering/platform'
import { Timestamp } from '@hcengineering/core'
import type { Asset, IntlString } from '@hcengineering/platform'
import { /* Metadata, Plugin, plugin, */ Resource /*, Service */ } from '@hcengineering/platform'
import { /* getContext, */ SvelteComponent } from 'svelte'
@ -28,7 +28,6 @@ export interface Location {
export interface ResolvedLocation {
loc: Location
shouldNavigate: boolean
defaultLocation: Location
}

View File

@ -1,10 +1,10 @@
<script lang="ts">
import core, { Ref, Space, WithLookup } from '@hcengineering/core'
import { Button, getCurrentLocation, navigate, location, TabList, Icon } from '@hcengineering/ui'
import { createQuery } from '@hcengineering/presentation'
import board from '../plugin'
import { Button, Icon, TabList, getCurrentResolvedLocation, location, navigate } from '@hcengineering/ui'
import { Viewlet } from '@hcengineering/view'
import { createEventDispatcher } from 'svelte'
import board from '../plugin'
export let spaceId: Ref<Space> | undefined
export let viewlets: WithLookup<Viewlet>[]
@ -19,7 +19,7 @@
})
function showMenu () {
const loc = getCurrentLocation()
const loc = getCurrentResolvedLocation()
loc.path[4] = space._id
navigate(loc)
}

View File

@ -18,8 +18,8 @@
import { AttachmentPresenter, FileDownload } from '@hcengineering/attachment-resources'
import { ChunterSpace } from '@hcengineering/chunter'
import { Doc, SortingOrder, getCurrentAccount } from '@hcengineering/core'
import { createQuery, getFileUrl, getClient } from '@hcengineering/presentation'
import { getCurrentLocation, showPopup, IconMoreV, Label, navigate, Icon, Menu } from '@hcengineering/ui'
import { createQuery, getClient, getFileUrl } from '@hcengineering/presentation'
import { Icon, IconMoreV, Label, Menu, getCurrentResolvedLocation, navigate, showPopup } from '@hcengineering/ui'
export let channel: ChunterSpace | undefined
const myAccId = getCurrentAccount()._id
@ -98,7 +98,7 @@
<div
class="showMoreAttachmentsButton"
on:click={() => {
const loc = getCurrentLocation()
const loc = getCurrentResolvedLocation()
loc.path[3] = 'fileBrowser'
loc.query = channel ? { spaceId: channel._id } : {}
navigate(loc)

View File

@ -16,11 +16,11 @@
import attachment, { Attachment } from '@hcengineering/attachment'
import { AttachmentRefInput } from '@hcengineering/attachment-resources'
import type { ChunterMessage, Message, ThreadMessage } from '@hcengineering/chunter'
import core, { generateId, getCurrentAccount, Ref, Space } from '@hcengineering/core'
import core, { Ref, Space, generateId, getCurrentAccount } from '@hcengineering/core'
import { LastView } from '@hcengineering/notification'
import { NotificationClientImpl } from '@hcengineering/notification-resources'
import { createQuery, getClient } from '@hcengineering/presentation'
import { getCurrentLocation, IconClose, Label, navigate } from '@hcengineering/ui'
import { IconClose, Label, getCurrentResolvedLocation, navigate } from '@hcengineering/ui'
import { afterUpdate, beforeUpdate, createEventDispatcher } from 'svelte'
import { createBacklinks } from '../backlinks'
import chunter from '../plugin'
@ -81,7 +81,7 @@
message = res[0]
if (!message) {
const loc = getCurrentLocation()
const loc = getCurrentResolvedLocation()
loc.path.length = 4
navigate(loc)
}

View File

@ -4,7 +4,14 @@ import { employeeByIdStore } from '@hcengineering/contact-resources'
import { Class, Client, Doc, getCurrentAccount, IdMap, Obj, Ref, Space, Timestamp } from '@hcengineering/core'
import { Asset } from '@hcengineering/platform'
import { getClient } from '@hcengineering/presentation'
import { getCurrentLocation, getPanelURI, location, Location, navigate, ResolvedLocation } from '@hcengineering/ui'
import {
getPanelURI,
location,
Location,
navigate,
ResolvedLocation,
getCurrentResolvedLocation
} from '@hcengineering/ui'
import view from '@hcengineering/view'
import { workbenchId } from '@hcengineering/workbench'
import { get, Unsubscriber, writable } from 'svelte/store'
@ -133,14 +140,14 @@ export function scrollAndHighLight (): void {
export async function getLink (doc: Doc): Promise<string> {
const fragment = await getTitle(doc)
const location = getCurrentLocation()
const location = getCurrentResolvedLocation()
return await Promise.resolve(
`${window.location.protocol}//${window.location.host}/${workbenchId}/${location.path[1]}/${chunterId}#${fragment}`
)
}
export async function getFragment (doc: Doc): Promise<Location> {
const loc = getCurrentLocation()
const loc = getCurrentResolvedLocation()
loc.path.length = 2
loc.fragment = undefined
loc.query = undefined
@ -213,7 +220,6 @@ async function generateLocation (loc: Location, shortLink: string): Promise<Reso
path: [appComponent, workspace, chunterId, doc.space],
fragment: doc._id
},
shouldNavigate: true,
defaultLocation: {
path: [appComponent, workspace, chunterId, doc.space],
fragment: doc._id
@ -230,7 +236,6 @@ async function generateLocation (loc: Location, shortLink: string): Promise<Reso
path: [appComponent, workspace],
fragment: getPanelURI(component, comment.attachedTo, comment.attachedToClass, 'content')
},
shouldNavigate: false,
defaultLocation: {
path: [appComponent, workspace],
fragment: getPanelURI(component, comment.attachedTo, comment.attachedToClass, 'content')
@ -244,7 +249,6 @@ async function generateLocation (loc: Location, shortLink: string): Promise<Reso
path: [appComponent, workspace, chunterId, doc.space, msg.attachedTo],
fragment: doc._id
},
shouldNavigate: true,
defaultLocation: {
path: [appComponent, workspace, chunterId, doc.space],
fragment: doc._id

View File

@ -30,7 +30,13 @@ import {
import { Client, Doc, getCurrentAccount, IdMap, ObjQueryType, Ref, Timestamp, toIdMap } from '@hcengineering/core'
import { createQuery, getClient } from '@hcengineering/presentation'
import { TemplateDataProvider } from '@hcengineering/templates'
import { DropdownIntlItem, getCurrentLocation, getPanelURI, Location, ResolvedLocation } from '@hcengineering/ui'
import {
DropdownIntlItem,
getCurrentResolvedLocation,
getPanelURI,
Location,
ResolvedLocation
} from '@hcengineering/ui'
import view, { Filter } from '@hcengineering/view'
import { FilterQuery } from '@hcengineering/view-resources'
import { get, writable } from 'svelte/store'
@ -180,7 +186,7 @@ export async function getContactChannel (value: Contact, provider: Ref<ChannelPr
}
export async function getContactLink (doc: Doc): Promise<Location> {
const loc = getCurrentLocation()
const loc = getCurrentResolvedLocation()
loc.path.length = 2
loc.fragment = undefined
loc.query = undefined
@ -213,7 +219,6 @@ async function generateLocation (loc: Location, id: Ref<Contact>): Promise<Resol
path: [appComponent, workspace],
fragment: getPanelURI(view.component.EditDoc, doc._id, doc._class, 'content')
},
shouldNavigate: false,
defaultLocation: {
path: [appComponent, workspace, contactId],
fragment: getPanelURI(view.component.EditDoc, doc._id, doc._class, 'content')

View File

@ -1,11 +1,11 @@
<script lang="ts">
import tags, { selectedTagElements, TagElement } from '@hcengineering/tags'
import { Component, getCurrentLocation, navigate } from '@hcengineering/ui'
import { Component, getCurrentResolvedLocation, navigate } from '@hcengineering/ui'
import recruit from '../plugin'
function onTag (tag: TagElement): void {
selectedTagElements.set([tag._id])
const loc = getCurrentLocation()
const loc = getCurrentResolvedLocation()
loc.path[2] = 'recruit'
loc.path[3] = 'candidates'
loc.path.length = 4

View File

@ -15,7 +15,7 @@
<script lang="ts">
import { Ref } from '@hcengineering/core'
import { recruitId, Vacancy } from '@hcengineering/recruit'
import { closeTooltip, getCurrentLocation, Icon, navigate, tooltip } from '@hcengineering/ui'
import { closeTooltip, getCurrentResolvedLocation, Icon, navigate, tooltip } from '@hcengineering/ui'
import recruit from '../plugin'
import VacancyApplicationsPopup from './VacancyApplicationsPopup.svelte'
@ -24,7 +24,7 @@
function click () {
closeTooltip()
const loc = getCurrentLocation()
const loc = getCurrentResolvedLocation()
loc.fragment = undefined
loc.query = undefined
loc.path[2] = recruitId

View File

@ -1,16 +1,16 @@
import contact, { getName } from '@hcengineering/contact'
import { Class, Client, Doc, Hierarchy, Ref } from '@hcengineering/core'
import { getClient } from '@hcengineering/presentation'
import { Applicant, Candidate, recruitId, Review, Vacancy, VacancyList } from '@hcengineering/recruit'
import { getCurrentLocation, getPanelURI, Location, ResolvedLocation } from '@hcengineering/ui'
import { Applicant, Candidate, Review, Vacancy, VacancyList, recruitId } from '@hcengineering/recruit'
import { Location, ResolvedLocation, getCurrentResolvedLocation, getPanelURI } from '@hcengineering/ui'
import view from '@hcengineering/view'
import contact, { getName } from '@hcengineering/contact'
import { workbenchId } from '@hcengineering/workbench'
import recruit from './plugin'
type RecruitDocument = Vacancy | Applicant | Review
export async function objectLinkProvider (doc: RecruitDocument): Promise<string> {
const location = getCurrentLocation()
const location = getCurrentResolvedLocation()
return await Promise.resolve(
`${window.location.protocol}//${window.location.host}/${workbenchId}/${
location.path[1]
@ -77,7 +77,6 @@ async function generateIdLocation (loc: Location, shortLink: string): Promise<Re
path: [appComponent, workspace],
fragment: getPanelURI(component, doc._id, _class, 'content')
},
shouldNavigate: false,
defaultLocation: {
path: defaultPath,
fragment: getPanelURI(component, doc._id, _class, 'content')
@ -127,7 +126,6 @@ async function generateLocation (loc: Location, shortLink: string): Promise<Reso
path: [appComponent, workspace],
fragment: getPanelURI(component, doc._id, doc._class, 'content')
},
shouldNavigate: false,
defaultLocation: {
path: defaultPath,
fragment: getPanelURI(component, doc._id, doc._class, 'content')
@ -136,7 +134,7 @@ async function generateLocation (loc: Location, shortLink: string): Promise<Reso
}
export async function getSequenceLink (doc: RecruitDocument): Promise<Location> {
const loc = getCurrentLocation()
const loc = getCurrentResolvedLocation()
loc.path.length = 2
loc.fragment = undefined
loc.query = undefined
@ -150,7 +148,7 @@ export async function getObjectLink (doc: Candidate | VacancyList): Promise<Loca
const _class = Hierarchy.mixinOrClass(doc)
const client = getClient()
const clazz = client.getHierarchy().getClass(_class)
const loc = getCurrentLocation()
const loc = getCurrentResolvedLocation()
loc.path.length = 2
loc.fragment = undefined
loc.query = undefined

View File

@ -13,24 +13,24 @@
// limitations under the License.
-->
<script lang="ts">
import { EmployeeAccount } from '@hcengineering/contact'
import { AccountRole, getCurrentAccount } from '@hcengineering/core'
import login, { loginId } from '@hcengineering/login'
import { setMetadata } from '@hcengineering/platform'
import presentation, { createQuery } from '@hcengineering/presentation'
import setting, { SettingsCategory } from '@hcengineering/setting'
import {
Component,
fetchMetadataLocalStorage,
getCurrentLocation,
Label,
location,
fetchMetadataLocalStorage,
getCurrentResolvedLocation,
navigate,
resolvedLocationStore,
setMetadataLocalStorage,
showPopup
} from '@hcengineering/ui'
import { onDestroy } from 'svelte'
import CategoryElement from './CategoryElement.svelte'
import login, { loginId } from '@hcengineering/login'
import { AccountRole, getCurrentAccount } from '@hcengineering/core'
import { EmployeeAccount } from '@hcengineering/contact'
import { setMetadata } from '@hcengineering/platform'
export let visibileNav = true
let category: SettingsCategory | undefined
@ -51,7 +51,7 @@
)
onDestroy(
location.subscribe(async (loc) => {
resolvedLocationStore.subscribe(async (loc) => {
categoryId = loc.path[3]
category = findCategory(categoryId)
})
@ -61,7 +61,7 @@
return categories.find((x) => x.name === name)
}
function selectCategory (id: string): void {
const loc = getCurrentLocation()
const loc = getCurrentResolvedLocation()
loc.path[3] = id
loc.path.length = 4
navigate(loc)
@ -69,7 +69,7 @@
function signOut (): void {
const tokens = fetchMetadataLocalStorage(login.metadata.LoginTokens)
if (tokens !== null) {
const loc = getCurrentLocation()
const loc = getCurrentResolvedLocation()
delete tokens[loc.path[1]]
setMetadataLocalStorage(login.metadata.LoginTokens, tokens)
}

View File

@ -17,7 +17,7 @@
import { AccountRole, getCurrentAccount } from '@hcengineering/core'
import { createQuery } from '@hcengineering/presentation'
import setting, { SettingsCategory } from '@hcengineering/setting'
import { Component, getCurrentLocation, Label, location, navigate } from '@hcengineering/ui'
import { Component, Label, getCurrentResolvedLocation, resolvedLocationStore, navigate } from '@hcengineering/ui'
import { onDestroy } from 'svelte'
import CategoryElement from './CategoryElement.svelte'
@ -45,14 +45,14 @@
}
onDestroy(
location.subscribe(async (loc) => {
resolvedLocationStore.subscribe(async (loc) => {
categoryId = loc.path[4]
category = findCategory(categoryId)
})
)
function selectCategory (id: string): void {
const loc = getCurrentLocation()
const loc = getCurrentResolvedLocation()
loc.path[4] = id
loc.path.length = 5
navigate(loc)

View File

@ -14,22 +14,21 @@
-->
<script lang="ts">
import { EmployeeAccount, formatName } from '@hcengineering/contact'
import { employeeByIdStore } from '@hcengineering/contact-resources'
import { Avatar, employeeByIdStore } from '@hcengineering/contact-resources'
import { getCurrentAccount } from '@hcengineering/core'
import login, { loginId } from '@hcengineering/login'
import { setMetadata } from '@hcengineering/platform'
import { Avatar } from '@hcengineering/contact-resources'
import setting, { settingId, SettingsCategory } from '@hcengineering/setting'
import presentation from '@hcengineering/presentation'
import setting, { SettingsCategory, settingId } from '@hcengineering/setting'
import {
closePopup,
fetchMetadataLocalStorage,
getCurrentLocation,
Icon,
Label,
closePopup,
fetchMetadataLocalStorage,
getCurrentResolvedLocation,
navigate,
setMetadataLocalStorage
} from '@hcengineering/ui'
import presentation from '@hcengineering/presentation'
// const client = getClient()
async function getItems (): Promise<SettingsCategory[]> {
@ -41,7 +40,7 @@
function selectCategory (sp: SettingsCategory): void {
closePopup()
const loc = getCurrentLocation()
const loc = getCurrentResolvedLocation()
loc.path[2] = settingId
loc.path[3] = sp.name
loc.path.length = 4
@ -51,7 +50,7 @@
function signOut (): void {
const tokens = fetchMetadataLocalStorage(login.metadata.LoginTokens)
if (tokens !== null) {
const loc = getCurrentLocation()
const loc = getCurrentResolvedLocation()
delete tokens[loc.path[1]]
setMetadataLocalStorage(login.metadata.LoginTokens, tokens)
}

View File

@ -15,7 +15,7 @@
<script lang="ts">
import { WithLookup } from '@hcengineering/core'
import { Component } from '@hcengineering/tracker'
import { getCurrentLocation, Icon, navigate, tooltip } from '@hcengineering/ui'
import { Icon, getCurrentResolvedLocation, navigate, tooltip } from '@hcengineering/ui'
import tracker from '../../plugin'
export let value: WithLookup<Component>
@ -32,7 +32,7 @@
onClick()
}
const loc = getCurrentLocation()
const loc = getCurrentResolvedLocation()
loc.path[4] = 'components'
loc.path[5] = value._id
loc.path.length = 6

View File

@ -17,12 +17,18 @@
import { IntlString } from '@hcengineering/platform'
import { createQuery } from '@hcengineering/presentation'
import { Component } from '@hcengineering/tracker'
import { closePopup, closeTooltip, getCurrentLocation, location, navigate } from '@hcengineering/ui'
import {
closePopup,
closeTooltip,
getCurrentResolvedLocation,
navigate,
resolvedLocationStore
} from '@hcengineering/ui'
import { onDestroy } from 'svelte'
import tracker from '../../plugin'
import { ComponentsViewMode } from '../../utils'
import EditComponent from './EditComponent.svelte'
import ComponentBrowser from './ComponentBrowser.svelte'
import EditComponent from './EditComponent.svelte'
export let label: IntlString = tracker.string.Components
export let query: DocumentQuery<Component> = {}
@ -33,7 +39,7 @@
let component: Component | undefined
onDestroy(
location.subscribe(async (loc) => {
resolvedLocationStore.subscribe(async (loc) => {
closeTooltip()
closePopup()
@ -56,7 +62,7 @@
<EditComponent
{component}
on:component={(evt) => {
const loc = getCurrentLocation()
const loc = getCurrentResolvedLocation()
loc.path[5] = evt.detail
navigate(loc)
}}

View File

@ -3,7 +3,7 @@
import { IntlString, translate } from '@hcengineering/platform'
import { createQuery } from '@hcengineering/presentation'
import { Issue } from '@hcengineering/tracker'
import { Button, IconDetails, IconDetailsFilled, location } from '@hcengineering/ui'
import { Button, IconDetails, IconDetailsFilled, resolvedLocationStore } from '@hcengineering/ui'
import view, { Viewlet } from '@hcengineering/view'
import {
FilterBar,
@ -53,7 +53,7 @@
let key = makeViewletKey()
onDestroy(
location.subscribe((loc) => {
resolvedLocationStore.subscribe((loc) => {
key = makeViewletKey(loc)
})
)

View File

@ -24,13 +24,13 @@
import {
Button,
EditBox,
getCurrentLocation,
IconMixin,
IconMoreH,
Label,
Spinner,
getCurrentResolvedLocation,
navigate,
showPopup,
Spinner
showPopup
} from '@hcengineering/ui'
import { ContextMenu, UpDownNavigator } from '@hcengineering/view-resources'
import { createEventDispatcher, onDestroy, onMount } from 'svelte'
@ -39,8 +39,8 @@
import IssueStatusActivity from '../IssueStatusActivity.svelte'
import ControlPanel from './ControlPanel.svelte'
import CopyToClipboard from './CopyToClipboard.svelte'
import SubIssues from './SubIssues.svelte'
import SubIssueSelector from './SubIssueSelector.svelte'
import SubIssues from './SubIssues.svelte'
export let _id: Ref<Issue>
export let _class: Ref<Class<Issue>>
@ -225,7 +225,7 @@
showTooltip={{ label: setting.string.ClassSetting }}
on:click={(ev) => {
ev.stopPropagation()
const loc = getCurrentLocation()
const loc = getCurrentResolvedLocation()
loc.path[2] = settingId
loc.path[3] = 'setting'
loc.path[4] = 'classes'

View File

@ -25,7 +25,7 @@
IconScaleFull,
Label,
closeTooltip,
getCurrentLocation,
getCurrentResolvedLocation,
navigate
} from '@hcengineering/ui'
import view, { Viewlet } from '@hcengineering/view'
@ -104,7 +104,7 @@
const filter = createFilter(tracker.class.Issue, 'attachedTo', [issue._id])
if (filter !== undefined) {
closeTooltip()
const loc = getCurrentLocation()
const loc = getCurrentResolvedLocation()
loc.fragment = undefined
loc.query = undefined
loc.path[2] = trackerId

View File

@ -13,19 +13,19 @@
// limitations under the License.
-->
<script lang="ts">
import { SortingOrder, WithLookup } from '@hcengineering/core'
import { Scrum } from '@hcengineering/tracker'
import {
Button,
deviceOptionsStore as deviceInfo,
getCurrentLocation,
Icon,
deviceOptionsStore as deviceInfo,
getCurrentResolvedLocation,
navigate,
showPopup
} from '@hcengineering/ui'
import tracker from '../../plugin'
import ScrumPopup from './ScrumPopup.svelte'
import Expanded from '../icons/Expanded.svelte'
import { SortingOrder, WithLookup } from '@hcengineering/core'
import { Scrum } from '@hcengineering/tracker'
import ScrumPopup from './ScrumPopup.svelte'
export let scrum: WithLookup<Scrum>
@ -44,7 +44,7 @@
container,
(value) => {
if (value != null) {
const loc = getCurrentLocation()
const loc = getCurrentResolvedLocation()
loc.path[5] = value._id
navigate(loc)
}

View File

@ -14,11 +14,11 @@
-->
<script lang="ts">
import { Scrum } from '@hcengineering/tracker'
import { getCurrentLocation, navigate } from '@hcengineering/ui'
import { getCurrentResolvedLocation, navigate } from '@hcengineering/ui'
export let value: Scrum
function navigateToScrum () {
const loc = getCurrentLocation()
const loc = getCurrentResolvedLocation()
loc.path[5] = value._id
loc.path.length = 6
navigate(loc)

View File

@ -15,8 +15,8 @@
<script lang="ts">
import { Ref } from '@hcengineering/core'
import { createQuery } from '@hcengineering/presentation'
import { Scrum, ScrumRecord, Project } from '@hcengineering/tracker'
import { closePopup, closeTooltip, location } from '@hcengineering/ui'
import { Project, Scrum, ScrumRecord } from '@hcengineering/tracker'
import { closePopup, closeTooltip, resolvedLocationStore } from '@hcengineering/ui'
import { onDestroy } from 'svelte'
import tracker from '../../plugin'
import ScrumRecordsView from './ScrumRecordsView.svelte'
@ -32,7 +32,7 @@
const scrumQuery = createQuery()
onDestroy(
location.subscribe(async (loc) => {
resolvedLocationStore.subscribe(async (loc) => {
closeTooltip()
closePopup()

View File

@ -17,7 +17,7 @@
import { IntlString } from '@hcengineering/platform'
import { createQuery } from '@hcengineering/presentation'
import { Sprint } from '@hcengineering/tracker'
import { Button, IconAdd, Label, SearchEdit, location, showPopup } from '@hcengineering/ui'
import { Button, IconAdd, Label, SearchEdit, resolvedLocationStore, showPopup } from '@hcengineering/ui'
import view, { Viewlet } from '@hcengineering/view'
import {
FilterBar,
@ -75,7 +75,7 @@
let key = makeViewletKey()
onDestroy(
location.subscribe((loc) => {
resolvedLocationStore.subscribe((loc) => {
key = makeViewletKey(loc)
})
)

View File

@ -15,7 +15,7 @@
<script lang="ts">
import { WithLookup } from '@hcengineering/core'
import { Sprint } from '@hcengineering/tracker'
import { getCurrentLocation, Icon, navigate, tooltip } from '@hcengineering/ui'
import { Icon, getCurrentResolvedLocation, navigate, tooltip } from '@hcengineering/ui'
import tracker from '../../plugin'
export let value: WithLookup<Sprint>
@ -32,7 +32,7 @@
onClick()
}
const loc = getCurrentLocation()
const loc = getCurrentResolvedLocation()
loc.path[4] = 'sprints'
loc.path[5] = value._id
loc.path.length = 6

View File

@ -17,7 +17,13 @@
import { IntlString } from '@hcengineering/platform'
import { createQuery } from '@hcengineering/presentation'
import { Sprint, Project } from '@hcengineering/tracker'
import { closePopup, closeTooltip, getCurrentLocation, location, navigate } from '@hcengineering/ui'
import {
closePopup,
closeTooltip,
getCurrentResolvedLocation,
navigate,
resolvedLocationStore
} from '@hcengineering/ui'
import { onDestroy } from 'svelte'
import tracker from '../../plugin'
import { SprintViewMode } from '../../utils'
@ -33,7 +39,7 @@
let sprint: Sprint | undefined
onDestroy(
location.subscribe(async (loc) => {
resolvedLocationStore.subscribe(async (loc) => {
closeTooltip()
closePopup()
@ -56,7 +62,7 @@
<EditSprint
{sprint}
on:sprint={(evt) => {
const loc = getCurrentLocation()
const loc = getCurrentResolvedLocation()
loc.path[5] = evt.detail
navigate(loc)
}}

View File

@ -18,20 +18,20 @@
import notification from '@hcengineering/notification'
import { Panel } from '@hcengineering/panel'
import { getResource } from '@hcengineering/platform'
import presentation, { createQuery, getClient, MessageViewer } from '@hcengineering/presentation'
import presentation, { MessageViewer, createQuery, getClient } from '@hcengineering/presentation'
import setting, { settingId } from '@hcengineering/setting'
import tags from '@hcengineering/tags'
import type { IssueTemplate, IssueTemplateChild, Project } from '@hcengineering/tracker'
import {
Button,
EditBox,
getCurrentLocation,
IconAttachment,
IconEdit,
IconMoreH,
Label,
navigate,
Scroller,
getCurrentResolvedLocation,
navigate,
showPopup
} from '@hcengineering/ui'
import { ContextMenu, UpDownNavigator } from '@hcengineering/view-resources'
@ -279,7 +279,7 @@
showTooltip={{ label: setting.string.ClassSetting }}
on:click={(ev) => {
ev.stopPropagation()
const loc = getCurrentLocation()
const loc = getCurrentResolvedLocation()
loc.path[2] = settingId
loc.path[3] = 'setting'
loc.path[4] = 'classes'

View File

@ -3,7 +3,7 @@
import { IntlString, translate } from '@hcengineering/platform'
import { createQuery } from '@hcengineering/presentation'
import { IssueTemplate } from '@hcengineering/tracker'
import { Button, IconAdd, IconDetails, IconDetailsFilled, location, showPopup } from '@hcengineering/ui'
import { Button, IconAdd, IconDetails, IconDetailsFilled, resolvedLocationStore, showPopup } from '@hcengineering/ui'
import view, { Viewlet } from '@hcengineering/view'
import {
FilterBar,
@ -51,7 +51,7 @@
let key = makeViewletKey()
onDestroy(
location.subscribe((loc) => {
resolvedLocationStore.subscribe((loc) => {
key = makeViewletKey(loc)
})
)

View File

@ -1,7 +1,7 @@
import { Doc, DocumentUpdate, Ref, RelatedDocument, TxOperations } from '@hcengineering/core'
import { getClient } from '@hcengineering/presentation'
import { Component, Issue, Project, Sprint, trackerId } from '@hcengineering/tracker'
import { getCurrentLocation, getPanelURI, Location, ResolvedLocation } from '@hcengineering/ui'
import { Location, ResolvedLocation, getPanelURI, getCurrentResolvedLocation } from '@hcengineering/ui'
import { workbenchId } from '@hcengineering/workbench'
import { writable } from 'svelte/store'
import tracker from './plugin'
@ -44,7 +44,7 @@ export async function issueIdProvider (doc: Doc): Promise<string> {
}
export async function issueLinkFragmentProvider (doc: Doc): Promise<Location> {
const loc = getCurrentLocation()
const loc = getCurrentResolvedLocation()
loc.path.length = 2
loc.fragment = undefined
loc.query = undefined
@ -63,7 +63,7 @@ export async function issueLinkProvider (doc: Doc): Promise<string> {
}
export function generateIssueShortLink (issueId: string): string {
const location = getCurrentLocation()
const location = getCurrentResolvedLocation()
return `${window.location.protocol}//${window.location.host}/${workbenchId}/${location.path[1]}/${trackerId}/${issueId}`
}
@ -94,7 +94,6 @@ export async function generateIssueLocation (loc: Location, issueId: string): Pr
path: [appComponent, workspace],
fragment: generateIssuePanelUri(issue)
},
shouldNavigate: false,
defaultLocation: {
path: [appComponent, workspace, trackerId, project._id, 'issues'],
fragment: generateIssuePanelUri(issue)

View File

@ -15,9 +15,9 @@
<script lang="ts">
import core, { Class, Doc, Ref } from '@hcengineering/core'
import { IntlString } from '@hcengineering/platform'
import { AttributesBar, getAttribute, getClient, KeyedAttribute } from '@hcengineering/presentation'
import { AttributesBar, KeyedAttribute, getAttribute, getClient } from '@hcengineering/presentation'
import setting, { settingId } from '@hcengineering/setting'
import { Button, getCurrentLocation, Label, navigate } from '@hcengineering/ui'
import { Button, Label, getCurrentResolvedLocation, navigate } from '@hcengineering/ui'
import { getFiltredKeys, isCollectionAttr } from '../utils'
export let object: Doc | Record<string, any>
@ -80,7 +80,7 @@
showTooltip={{ label: setting.string.ClassSetting }}
on:click={(ev) => {
ev.stopPropagation()
const loc = getCurrentLocation()
const loc = getCurrentResolvedLocation()
loc.path[2] = settingId
loc.path[3] = 'setting'
loc.path[4] = 'classes'

View File

@ -1,12 +1,12 @@
<script lang="ts">
import { Card, getClient } from '@hcengineering/presentation'
import view from '../../plugin'
import { EditBox, getCurrentLocation, Button } from '@hcengineering/ui'
import { Class, Doc, Ref } from '@hcengineering/core'
import preference from '@hcengineering/preference'
import { Card, getClient } from '@hcengineering/presentation'
import { Button, EditBox, getCurrentResolvedLocation } from '@hcengineering/ui'
import { ViewOptions } from '@hcengineering/view'
import { createEventDispatcher } from 'svelte'
import { filterStore } from '../../filter'
import { ViewOptions } from '@hcengineering/view'
import { Class, Doc, Ref } from '@hcengineering/core'
import view from '../../plugin'
import { getActiveViewletId } from '../../utils'
export let viewOptions: ViewOptions | undefined = undefined
@ -16,7 +16,7 @@
const client = getClient()
async function saveFilter () {
const loc = getCurrentLocation()
const loc = getCurrentResolvedLocation()
loc.fragment = undefined
loc.query = undefined
const filters = JSON.stringify($filterStore)

View File

@ -11,7 +11,7 @@ import core, {
} from '@hcengineering/core'
import { getResource } from '@hcengineering/platform'
import { LiveQuery, createQuery, getClient } from '@hcengineering/presentation'
import { AnyComponent, getCurrentLocation, locationToUrl } from '@hcengineering/ui'
import { AnyComponent, locationToUrl, getCurrentResolvedLocation } from '@hcengineering/ui'
import { Filter, FilterMode, KeyFilter } from '@hcengineering/view'
import { get, writable } from 'svelte/store'
import view from './plugin'
@ -198,7 +198,7 @@ export function createFilter (_class: Ref<Class<Doc>>, key: string, value: any[]
}
export function getFilterKey (_class: Ref<Class<Doc>>): string {
const loc = getCurrentLocation()
const loc = getCurrentResolvedLocation()
loc.fragment = undefined
loc.query = undefined
return 'filter' + locationToUrl(loc) + _class

View File

@ -45,7 +45,7 @@ import { AttributeCategory, createQuery, getAttributePresenterClass, KeyedAttrib
import {
AnyComponent,
ErrorPresenter,
getCurrentLocation,
getCurrentResolvedLocation,
getPanelURI,
getPlatformColorForText,
Location,
@ -482,7 +482,7 @@ export function categorizeFields (
}
export function makeViewletKey (loc?: Location): string {
loc = loc != null ? { path: loc.path } : getCurrentLocation()
loc = loc != null ? { path: loc.path } : getCurrentResolvedLocation()
loc.fragment = undefined
loc.query = undefined
return 'viewlet' + locationToUrl(loc)
@ -861,7 +861,7 @@ export async function getObjectLinkFragment (
return res
}
}
const loc = getCurrentLocation()
const loc = getCurrentResolvedLocation()
loc.fragment = getPanelURI(component, object._id, Hierarchy.mixinOrClass(object), 'content')
return loc
}

View File

@ -11,7 +11,7 @@ import core, {
} from '@hcengineering/core'
import { getResource } from '@hcengineering/platform'
import { LiveQuery, createQuery, getAttributePresenterClass, getClient } from '@hcengineering/presentation'
import { getCurrentLocation, locationToUrl } from '@hcengineering/ui'
import { locationToUrl, getCurrentResolvedLocation } from '@hcengineering/ui'
import {
DropdownViewOption,
ToggleViewOption,
@ -42,7 +42,7 @@ export function isDropdownType (viewOption: ViewOptionModel): viewOption is Drop
export function makeViewOptionsKey (viewlet: Ref<Viewlet>, variant?: string): string {
const prefix = viewlet + (variant !== undefined ? `-${variant}` : '')
const loc = getCurrentLocation()
const loc = getCurrentResolvedLocation()
loc.fragment = undefined
loc.query = undefined
return `viewOptions:${prefix}:${locationToUrl(loc)}`

View File

@ -18,22 +18,26 @@
import login, { loginId } from '@hcengineering/login'
import { setMetadata } from '@hcengineering/platform'
import presentation, { createQuery } from '@hcengineering/presentation'
import setting, { settingId, SettingsCategory } from '@hcengineering/setting'
import { Action, Component, fetchMetadataLocalStorage } from '@hcengineering/ui'
import setting, { SettingsCategory, settingId } from '@hcengineering/setting'
import {
Action,
Component,
Menu,
closePanel,
closePopup,
deviceOptionsStore as deviceInfo,
fetchMetadataLocalStorage,
getCurrentLocation,
navigate,
setMetadataLocalStorage,
showPopup,
Menu,
getCurrentResolvedLocation,
locationToUrl,
deviceOptionsStore as deviceInfo
navigate,
resolvedLocationStore,
setMetadataLocalStorage,
showPopup
} from '@hcengineering/ui'
import view from '@hcengineering/view'
import HelpAndSupport from './HelpAndSupport.svelte'
import workbench from '../plugin'
import HelpAndSupport from './HelpAndSupport.svelte'
import SelectWorkspaceMenu from './SelectWorkspaceMenu.svelte'
let items: SettingsCategory[] = []
@ -66,7 +70,7 @@
function selectCategory (sp: SettingsCategory): void {
closePopup()
closePanel()
const loc = getCurrentLocation()
const loc = getCurrentResolvedLocation()
loc.path[2] = settingId
loc.path[3] = sp.name
loc.path.length = 4
@ -107,7 +111,7 @@
}
function getURLCategory (sp: SettingsCategory): string {
const loc = getCurrentLocation()
const loc = getCurrentResolvedLocation()
loc.path[2] = settingId
loc.path[3] = sp.name
loc.path.length = 4
@ -175,7 +179,7 @@
<!-- svelte-ignore a11y-click-events-have-key-events -->
<svelte:component this={Menu} bind:this={menu} {actions} {addClass} on:close>
<svelte:fragment slot="header">
<div class="p-1 ml-2 overflow-label fs-bold caption-color">{getCurrentLocation().path[1]}</div>
<div class="p-1 ml-2 overflow-label fs-bold caption-color">{$resolvedLocationStore.path[1]}</div>
<div
class="ap-menuHeader mb-2"
on:mousemove={() => {

View File

@ -1,8 +1,10 @@
<script lang="ts">
import { getClient } from '@hcengineering/presentation'
import setting, { settingId } from '@hcengineering/setting'
import {
Button,
closePopup,
getCurrentLocation,
getCurrentResolvedLocation,
Icon,
IconArrowLeft,
Label,
@ -11,13 +13,11 @@
Scroller,
topSP
} from '@hcengineering/ui'
import setting, { settingId } from '@hcengineering/setting'
import view, { Action, ActionCategory } from '@hcengineering/view'
import { getClient } from '@hcengineering/presentation'
import RightArrowIcon from './icons/Collapsed.svelte'
import KeyboardIcon from './icons/Keyboard.svelte'
import DocumentationIcon from './icons/Documentation.svelte'
import workbench from '../plugin'
import RightArrowIcon from './icons/Collapsed.svelte'
import DocumentationIcon from './icons/Documentation.svelte'
import KeyboardIcon from './icons/Keyboard.svelte'
let shortcuts = false
let actions: Action[] = []
@ -27,7 +27,7 @@
function navigateToSettings () {
closePopup()
const loc = getCurrentLocation()
const loc = getCurrentResolvedLocation()
loc.path[2] = loc.path[3] = settingId
loc.path.length = 4
navigate(loc)

View File

@ -14,11 +14,9 @@
-->
<script lang="ts">
import type { IntlString } from '@hcengineering/platform'
import { getCurrentLocation, Label } from '@hcengineering/ui'
import { Label, resolvedLocationStore } from '@hcengineering/ui'
export let label: IntlString
const loc = getCurrentLocation()
</script>
<div class="antiNav-header">
@ -26,6 +24,6 @@
<Label {label} />
</span>
<span class="bottom overflow-label">
{loc.path[1]}
{$resolvedLocationStore.path[1]}
</span>
</div>

View File

@ -23,10 +23,12 @@
SortingQuery,
Space
} from '@hcengineering/core'
import { IntlString } from '@hcengineering/platform'
import presentation, { createQuery, getClient } from '@hcengineering/presentation'
import {
AnyComponent,
Button,
getCurrentLocation,
getCurrentResolvedLocation,
Icon,
Label,
navigate,
@ -34,10 +36,8 @@
SearchEdit,
showPopup
} from '@hcengineering/ui'
import presentation, { createQuery, getClient } from '@hcengineering/presentation'
import plugin from '../plugin'
import { FilterBar, FilterButton, SpacePresenter } from '@hcengineering/view-resources'
import { IntlString } from '@hcengineering/platform'
import plugin from '../plugin'
import { classIcon } from '../utils'
export let _class: Ref<Class<Space>>
@ -106,7 +106,7 @@
}
async function view (space: Space): Promise<void> {
const loc = getCurrentLocation()
const loc = getCurrentResolvedLocation()
loc.path[3] = space._id
navigate(loc)
}

View File

@ -24,7 +24,7 @@
SearchEdit,
TabList,
deviceOptionsStore as deviceInfo,
location,
resolvedLocationStore,
showPopup
} from '@hcengineering/ui'
import { ViewOptions, Viewlet } from '@hcengineering/view'
@ -70,7 +70,7 @@
let key = makeViewletKey()
onDestroy(
location.subscribe((loc) => {
resolvedLocationStore.subscribe((loc) => {
key = makeViewletKey(loc)
})
)

View File

@ -16,7 +16,7 @@
import core, { Class, Doc, Ref, Space, WithLookup } from '@hcengineering/core'
import { IntlString } from '@hcengineering/platform'
import { getClient } from '@hcengineering/presentation'
import { AnyComponent, Component, location } from '@hcengineering/ui'
import { AnyComponent, Component, resolvedLocationStore } from '@hcengineering/ui'
import view, { Viewlet } from '@hcengineering/view'
import {
activeViewlet,
@ -47,7 +47,7 @@
let key = makeViewletKey()
onDestroy(
location.subscribe((loc) => {
resolvedLocationStore.subscribe((loc) => {
key = makeViewletKey(loc)
})
)

View File

@ -27,7 +27,7 @@
SearchEdit,
TabList,
deviceOptionsStore as deviceInfo,
location,
resolvedLocationStore,
showPopup
} from '@hcengineering/ui'
import view, { Viewlet, ViewletDescriptor, ViewletPreference } from '@hcengineering/view'
@ -83,7 +83,7 @@
let key = makeViewletKey()
onDestroy(
location.subscribe((loc) => {
resolvedLocationStore.subscribe((loc) => {
key = makeViewletKey(loc)
})
)

View File

@ -46,6 +46,7 @@
openPanel,
popupstore,
resizeObserver,
setResolvedLocation,
showPopup
} from '@hcengineering/ui'
import view from '@hcengineering/view'
@ -266,14 +267,11 @@
async function syncLoc (loc: Location): Promise<void> {
const originalLoc = JSON.stringify(loc)
// resolve short links
const resolvedLocation = await resolveShortLink(loc)
if (resolvedLocation && !areLocationsEqual(loc, resolvedLocation.loc)) {
loc = mergeLoc(loc, resolvedLocation)
if (resolvedLocation.shouldNavigate) {
navigate(loc)
return
}
const resolvedLoc = await resolveShortLink(loc)
if (resolvedLoc && !areLocationsEqual(loc, resolvedLoc.loc)) {
loc = mergeLoc(loc, resolvedLoc)
}
setResolvedLocation(loc)
const app = loc.path[2]
let space = loc.path[3] as Ref<Space>
let special = loc.path[4]

View File

@ -20,7 +20,15 @@
import { getResource } from '@hcengineering/platform'
import preference from '@hcengineering/preference'
import { getClient } from '@hcengineering/presentation'
import { Action, IconAdd, IconEdit, IconSearch, getCurrentLocation, navigate, showPopup } from '@hcengineering/ui'
import {
Action,
IconAdd,
IconEdit,
IconSearch,
navigate,
getCurrentResolvedLocation,
showPopup
} from '@hcengineering/ui'
import {
NavLink,
TreeItem,
@ -58,7 +66,7 @@
label: plugin.string.BrowseSpaces,
icon: IconSearch,
action: async (_id: Ref<Doc>): Promise<void> => {
const loc = getCurrentLocation()
const loc = getCurrentResolvedLocation()
loc.path[3] = 'spaceBrowser'
loc.path.length = 4
dispatch('open')