mirror of
https://github.com/hcengineering/platform.git
synced 2025-04-23 16:56:07 +00:00
UBER-528: Fix desktop navigation (#3450)
Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
This commit is contained in:
parent
54b74caf63
commit
7d5a257f1c
@ -114,7 +114,7 @@ declare global {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
const embeddedPlatform = window.embeddedPlatform ?? false
|
const embeddedPlatform = window.embeddedPlatform ?? false
|
||||||
const locationWritable = writable(embeddedPlatform ? { path: [] } : getRawCurrentLocation())
|
const locationWritable = writable(getRawCurrentLocation())
|
||||||
|
|
||||||
console.log('embeddedPlatform', window.embeddedPlatform)
|
console.log('embeddedPlatform', window.embeddedPlatform)
|
||||||
|
|
||||||
@ -124,7 +124,15 @@ if (!embeddedPlatform) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export const location = embeddedPlatform ? locationWritable : derived(locationWritable, (loc) => loc)
|
export const location = derived(locationWritable, (loc) => justClone(loc))
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
|
export function getLocation (): PlatformLocation {
|
||||||
|
return justClone(get(location))
|
||||||
|
}
|
||||||
|
|
||||||
export const resolvedLocationStore = writable(getRawCurrentLocation())
|
export const resolvedLocationStore = writable(getRawCurrentLocation())
|
||||||
let resolvedLocation = getRawCurrentLocation()
|
let resolvedLocation = getRawCurrentLocation()
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { get, writable } from 'svelte/store'
|
import { writable } from 'svelte/store'
|
||||||
import { location, navigate } from './location'
|
import { getLocation, navigate } from './location'
|
||||||
import { AnyComponent, PopupAlignment } from './types'
|
import { AnyComponent, PopupAlignment } from './types'
|
||||||
|
|
||||||
export interface PanelProps {
|
export interface PanelProps {
|
||||||
@ -29,7 +29,7 @@ export function showPanel (
|
|||||||
rightSection?: AnyComponent
|
rightSection?: AnyComponent
|
||||||
): void {
|
): void {
|
||||||
openPanel(component, _id, _class, element, rightSection)
|
openPanel(component, _id, _class, element, rightSection)
|
||||||
const loc = get(location)
|
const loc = getLocation()
|
||||||
if (loc.fragment !== currentLocation) {
|
if (loc.fragment !== currentLocation) {
|
||||||
loc.fragment = currentLocation
|
loc.fragment = currentLocation
|
||||||
navigate(loc)
|
navigate(loc)
|
||||||
@ -58,7 +58,7 @@ export function closePanel (shoulRedirect: boolean = true): void {
|
|||||||
return { panel: undefined }
|
return { panel: undefined }
|
||||||
})
|
})
|
||||||
if (shoulRedirect) {
|
if (shoulRedirect) {
|
||||||
const loc = get(location)
|
const loc = getLocation()
|
||||||
loc.fragment = undefined
|
loc.fragment = undefined
|
||||||
currentLocation = undefined
|
currentLocation = undefined
|
||||||
navigate(loc)
|
navigate(loc)
|
||||||
|
@ -17,9 +17,8 @@
|
|||||||
import contact, { Employee, EmployeeAccount } from '@hcengineering/contact'
|
import contact, { Employee, EmployeeAccount } from '@hcengineering/contact'
|
||||||
import core, { Class, getCurrentAccount, Ref, Space } from '@hcengineering/core'
|
import core, { Class, getCurrentAccount, Ref, Space } from '@hcengineering/core'
|
||||||
import { getClient } from '@hcengineering/presentation'
|
import { getClient } from '@hcengineering/presentation'
|
||||||
import { Label, Loading, location, navigate, TabList, SearchEdit } from '@hcengineering/ui'
|
import { Label, Loading, navigate, TabList, SearchEdit, getLocation } from '@hcengineering/ui'
|
||||||
import view from '@hcengineering/view'
|
import view from '@hcengineering/view'
|
||||||
import { get } from 'svelte/store'
|
|
||||||
import { dateFileBrowserFilters, FileBrowserSortMode, fileTypeFileBrowserFilters, sortModeToOptionObject } from '..'
|
import { dateFileBrowserFilters, FileBrowserSortMode, fileTypeFileBrowserFilters, sortModeToOptionObject } from '..'
|
||||||
import attachment from '../plugin'
|
import attachment from '../plugin'
|
||||||
import AttachmentsGalleryView from './AttachmentsGalleryView.svelte'
|
import AttachmentsGalleryView from './AttachmentsGalleryView.svelte'
|
||||||
@ -30,11 +29,11 @@
|
|||||||
export let withHeader: boolean = true
|
export let withHeader: boolean = true
|
||||||
|
|
||||||
const client = getClient()
|
const client = getClient()
|
||||||
const loc = get(location)
|
const loc = getLocation()
|
||||||
const spaceId: Ref<Space> | undefined = loc.query?.spaceId as Ref<Space> | undefined
|
const spaceId: Ref<Space> | undefined = loc.query?.spaceId as Ref<Space> | undefined
|
||||||
|
|
||||||
$: if (spaceId !== undefined) {
|
$: if (spaceId !== undefined) {
|
||||||
const loc = get(location)
|
const loc = getLocation()
|
||||||
loc.query = undefined
|
loc.query = undefined
|
||||||
navigate(loc)
|
navigate(loc)
|
||||||
}
|
}
|
||||||
|
@ -18,8 +18,7 @@
|
|||||||
import { ChunterMessage, ChunterSpace, Message } from '@hcengineering/chunter'
|
import { ChunterMessage, ChunterSpace, Message } from '@hcengineering/chunter'
|
||||||
import { Ref, Space, generateId, getCurrentAccount } from '@hcengineering/core'
|
import { Ref, Space, generateId, getCurrentAccount } from '@hcengineering/core'
|
||||||
import { createQuery, getClient } from '@hcengineering/presentation'
|
import { createQuery, getClient } from '@hcengineering/presentation'
|
||||||
import { location, navigate } from '@hcengineering/ui'
|
import { getLocation, navigate } from '@hcengineering/ui'
|
||||||
import { get } from 'svelte/store'
|
|
||||||
import { createBacklinks } from '../backlinks'
|
import { createBacklinks } from '../backlinks'
|
||||||
import chunter from '../plugin'
|
import chunter from '../plugin'
|
||||||
import Channel from './Channel.svelte'
|
import Channel from './Channel.svelte'
|
||||||
@ -59,7 +58,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function openThread (_id: Ref<Message>) {
|
function openThread (_id: Ref<Message>) {
|
||||||
const loc = get(location)
|
const loc = getLocation()
|
||||||
loc.path[4] = _id
|
loc.path[4] = _id
|
||||||
navigate(loc)
|
navigate(loc)
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ import { NotificationClientImpl } from '@hcengineering/notification-resources'
|
|||||||
import { IntlString, Resources, translate } from '@hcengineering/platform'
|
import { IntlString, Resources, translate } from '@hcengineering/platform'
|
||||||
import preference from '@hcengineering/preference'
|
import preference from '@hcengineering/preference'
|
||||||
import { MessageBox, getClient } from '@hcengineering/presentation'
|
import { MessageBox, getClient } from '@hcengineering/presentation'
|
||||||
import { location, navigate, showPopup } from '@hcengineering/ui'
|
import { getLocation, navigate, showPopup } from '@hcengineering/ui'
|
||||||
import ChannelHeader from './components/ChannelHeader.svelte'
|
import ChannelHeader from './components/ChannelHeader.svelte'
|
||||||
import ChannelPresenter from './components/ChannelPresenter.svelte'
|
import ChannelPresenter from './components/ChannelPresenter.svelte'
|
||||||
import ChannelView from './components/ChannelView.svelte'
|
import ChannelView from './components/ChannelView.svelte'
|
||||||
@ -57,7 +57,7 @@ import TxCommentCreate from './components/activity/TxCommentCreate.svelte'
|
|||||||
import TxMessageCreate from './components/activity/TxMessageCreate.svelte'
|
import TxMessageCreate from './components/activity/TxMessageCreate.svelte'
|
||||||
|
|
||||||
import notification from '@hcengineering/notification'
|
import notification from '@hcengineering/notification'
|
||||||
import { get, writable } from 'svelte/store'
|
import { writable } from 'svelte/store'
|
||||||
import { updateBacklinksList } from './backlinks'
|
import { updateBacklinksList } from './backlinks'
|
||||||
import { getDmName, getLink, getTitle, resolveLocation } from './utils'
|
import { getDmName, getLink, getTitle, resolveLocation } from './utils'
|
||||||
|
|
||||||
@ -179,7 +179,7 @@ export async function ArchiveChannel (channel: Channel, evt: any, afterArchive?:
|
|||||||
client.update(channel, { archived: true })
|
client.update(channel, { archived: true })
|
||||||
if (afterArchive != null) afterArchive()
|
if (afterArchive != null) afterArchive()
|
||||||
|
|
||||||
const loc = get(location)
|
const loc = getLocation()
|
||||||
if (loc.path[3] === channel._id) {
|
if (loc.path[3] === channel._id) {
|
||||||
loc.path.length = 3
|
loc.path.length = 3
|
||||||
navigate(loc)
|
navigate(loc)
|
||||||
|
@ -6,7 +6,7 @@ import { Asset } from '@hcengineering/platform'
|
|||||||
import { getClient } from '@hcengineering/presentation'
|
import { getClient } from '@hcengineering/presentation'
|
||||||
import {
|
import {
|
||||||
getPanelURI,
|
getPanelURI,
|
||||||
location,
|
getLocation,
|
||||||
Location,
|
Location,
|
||||||
navigate,
|
navigate,
|
||||||
ResolvedLocation,
|
ResolvedLocation,
|
||||||
@ -89,7 +89,7 @@ export function getDay (time: Timestamp): Timestamp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function openMessageFromSpecial (message: ChunterMessage): void {
|
export function openMessageFromSpecial (message: ChunterMessage): void {
|
||||||
const loc = get(location)
|
const loc = getLocation()
|
||||||
|
|
||||||
if (message.attachedToClass === chunter.class.ChunterSpace) {
|
if (message.attachedToClass === chunter.class.ChunterSpace) {
|
||||||
loc.path.length = 4
|
loc.path.length = 4
|
||||||
@ -103,7 +103,7 @@ export function openMessageFromSpecial (message: ChunterMessage): void {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function navigateToSpecial (specialId: string): void {
|
export function navigateToSpecial (specialId: string): void {
|
||||||
const loc = get(location)
|
const loc = getLocation()
|
||||||
loc.path[2] = chunterId
|
loc.path[2] = chunterId
|
||||||
loc.path[3] = specialId
|
loc.path[3] = specialId
|
||||||
navigate(loc)
|
navigate(loc)
|
||||||
|
@ -16,8 +16,7 @@
|
|||||||
import core, { Class, Doc, Obj, Ref } from '@hcengineering/core'
|
import core, { Class, Doc, Obj, Ref } from '@hcengineering/core'
|
||||||
import { IntlString } from '@hcengineering/platform'
|
import { IntlString } from '@hcengineering/platform'
|
||||||
import { createQuery, getClient } from '@hcengineering/presentation'
|
import { createQuery, getClient } from '@hcengineering/presentation'
|
||||||
import { AnySvelteComponent, location, Icon, Label, navigate } from '@hcengineering/ui'
|
import { AnySvelteComponent, getLocation, Icon, Label, navigate } from '@hcengineering/ui'
|
||||||
import { get } from 'svelte/store'
|
|
||||||
import setting from '../plugin'
|
import setting from '../plugin'
|
||||||
import { filterDescendants } from '../utils'
|
import { filterDescendants } from '../utils'
|
||||||
import ClassAttributes from './ClassAttributes.svelte'
|
import ClassAttributes from './ClassAttributes.svelte'
|
||||||
@ -33,14 +32,14 @@
|
|||||||
| undefined
|
| undefined
|
||||||
export let withoutHeader = false
|
export let withoutHeader = false
|
||||||
|
|
||||||
const loc = get(location)
|
const loc = getLocation()
|
||||||
const client = getClient()
|
const client = getClient()
|
||||||
const hierarchy = client.getHierarchy()
|
const hierarchy = client.getHierarchy()
|
||||||
|
|
||||||
let _class: Ref<Class<Doc>> | undefined = ofClass ?? (loc.query?._class as Ref<Class<Doc>> | undefined)
|
let _class: Ref<Class<Doc>> | undefined = ofClass ?? (loc.query?._class as Ref<Class<Doc>> | undefined)
|
||||||
|
|
||||||
$: if (_class !== undefined && ofClass === undefined) {
|
$: if (_class !== undefined && ofClass === undefined) {
|
||||||
const loc = get(location)
|
const loc = getLocation()
|
||||||
loc.query = undefined
|
loc.query = undefined
|
||||||
navigate(loc)
|
navigate(loc)
|
||||||
}
|
}
|
||||||
|
@ -41,6 +41,7 @@
|
|||||||
deviceOptionsStore as deviceInfo,
|
deviceOptionsStore as deviceInfo,
|
||||||
getCurrentLocation,
|
getCurrentLocation,
|
||||||
location,
|
location,
|
||||||
|
getLocation,
|
||||||
navigate,
|
navigate,
|
||||||
openPanel,
|
openPanel,
|
||||||
popupstore,
|
popupstore,
|
||||||
@ -59,7 +60,6 @@
|
|||||||
} from '@hcengineering/view-resources'
|
} from '@hcengineering/view-resources'
|
||||||
import type { Application, NavigatorModel, SpecialNavModel, ViewConfiguration } from '@hcengineering/workbench'
|
import type { Application, NavigatorModel, SpecialNavModel, ViewConfiguration } from '@hcengineering/workbench'
|
||||||
import { getContext, onDestroy, onMount, tick } from 'svelte'
|
import { getContext, onDestroy, onMount, tick } from 'svelte'
|
||||||
import { get } from 'svelte/store'
|
|
||||||
import { subscribeMobile } from '../mobile'
|
import { subscribeMobile } from '../mobile'
|
||||||
import workbench from '../plugin'
|
import workbench from '../plugin'
|
||||||
import { workspacesStore } from '../utils'
|
import { workspacesStore } from '../utils'
|
||||||
@ -423,7 +423,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function closeAside (): void {
|
function closeAside (): void {
|
||||||
const loc = get(location)
|
const loc = getLocation()
|
||||||
loc.path.length = 4
|
loc.path.length = 4
|
||||||
checkOnHide()
|
checkOnHide()
|
||||||
navigate(loc)
|
navigate(loc)
|
||||||
|
Loading…
Reference in New Issue
Block a user