diff --git a/packages/ui/src/components/internal/Root.svelte b/packages/ui/src/components/internal/Root.svelte index d1337e7e1c..7e4da932d6 100644 --- a/packages/ui/src/components/internal/Root.svelte +++ b/packages/ui/src/components/internal/Root.svelte @@ -3,7 +3,7 @@ import { onDestroy } from 'svelte' import type { AnyComponent } from '../../types' // import { applicationShortcutKey } from '../../utils' - import { getCurrentLocation, location, navigate } from '../../location' + import { getCurrentLocation, location, navigate, locationStorageKeyId } from '../../location' import { Theme } from '@hcengineering/theme' import Component from '../Component.svelte' @@ -35,9 +35,9 @@ } if (application === undefined) { - let last = loc.path[1] !== undefined ? localStorage.getItem(`platform_last_loc_${loc.path[1]}`) : null + let last = loc.path[1] !== undefined ? localStorage.getItem(`${locationStorageKeyId}_${loc.path[1]}`) : null if (last === null) { - last = localStorage.getItem('platform_last_loc') + last = localStorage.getItem(locationStorageKeyId) } let useDefault = true if (last !== null) { diff --git a/packages/ui/src/index.ts b/packages/ui/src/index.ts index d012d24174..e7192a3de2 100644 --- a/packages/ui/src/index.ts +++ b/packages/ui/src/index.ts @@ -40,7 +40,7 @@ export type { export { themeStore } from '@hcengineering/theme' // export { applicationShortcutKey } from './utils' -export { getCurrentLocation, locationToUrl, navigate, location } from './location' +export { getCurrentLocation, locationToUrl, navigate, location, setLocationStorageKey } from './location' export { default as EditBox } from './components/EditBox.svelte' export { default as Label } from './components/Label.svelte' diff --git a/packages/ui/src/location.ts b/packages/ui/src/location.ts index e8c3cef6e6..8a2659a5fc 100644 --- a/packages/ui/src/location.ts +++ b/packages/ui/src/location.ts @@ -148,6 +148,15 @@ export function getCurrentLocation (): PlatformLocation { return getRawCurrentLocation() } +/** + * @public + */ +export let locationStorageKeyId = 'platform_last_loc' + +export function setLocationStorageKey (storageKey: string): void { + locationStorageKeyId = storageKey +} + export function navigate (location: PlatformLocation, store = true): boolean { closePopup() const cur = locationToUrl(getCurrentLocation()) @@ -157,9 +166,9 @@ export function navigate (location: PlatformLocation, store = true): boolean { if (!embeddedPlatform) { history.pushState(null, '', url) } - localStorage.setItem('platform_last_loc', JSON.stringify(location)) + localStorage.setItem(locationStorageKeyId, JSON.stringify(location)) if (location.path[1] !== undefined) { - localStorage.setItem(`platform_last_loc_${location.path[1]}`, JSON.stringify(location)) + localStorage.setItem(`${locationStorageKeyId}_${location.path[1]}`, JSON.stringify(location)) } } locationWritable.set(location) diff --git a/plugins/login-resources/src/utils.ts b/plugins/login-resources/src/utils.ts index fb1415444a..14f9efedae 100644 --- a/plugins/login-resources/src/utils.ts +++ b/plugins/login-resources/src/utils.ts @@ -29,7 +29,8 @@ import { fetchMetadataLocalStorage, getCurrentLocation, navigate, - setMetadataLocalStorage + setMetadataLocalStorage, + locationStorageKeyId } from '@hcengineering/ui' import { workbenchId } from '@hcengineering/workbench' @@ -333,7 +334,7 @@ export function navigateToWorkspace (workspace: string, loginInfo?: WorkspaceLog // Json parse error could be ignored } } - const last = localStorage.getItem(`platform_last_loc_${workspace}`) + const last = localStorage.getItem(`${locationStorageKeyId}_${workspace}`) if (last !== null) { navigate(JSON.parse(last)) } else { diff --git a/plugins/workbench-resources/src/components/SelectWorkspaceMenu.svelte b/plugins/workbench-resources/src/components/SelectWorkspaceMenu.svelte index 32c6f77bfd..64dbeeb533 100644 --- a/plugins/workbench-resources/src/components/SelectWorkspaceMenu.svelte +++ b/plugins/workbench-resources/src/components/SelectWorkspaceMenu.svelte @@ -25,7 +25,8 @@ navigate, resolvedLocationStore, setMetadataLocalStorage, - IconCheck + IconCheck, + locationStorageKeyId } from '@hcengineering/ui' import { workbenchId } from '@hcengineering/workbench' import { onMount } from 'svelte' @@ -72,7 +73,7 @@ closePopup() closePopup() if (ws !== getCurrentLocation().path[1]) { - const last = localStorage.getItem(`platform_last_loc_${ws}`) + const last = localStorage.getItem(`${locationStorageKeyId}_${ws}`) if (last !== null) { navigate(JSON.parse(last)) } else navigate({ path: [workbenchId, ws] }) diff --git a/plugins/workbench-resources/src/components/Workbench.svelte b/plugins/workbench-resources/src/components/Workbench.svelte index f383677b40..e3b5b56dbd 100644 --- a/plugins/workbench-resources/src/components/Workbench.svelte +++ b/plugins/workbench-resources/src/components/Workbench.svelte @@ -21,6 +21,7 @@ import { IntlString, broadcastEvent, getMetadata, getResource } from '@hcengineering/platform' import { ActionContext, createQuery, getClient } from '@hcengineering/presentation' import setting from '@hcengineering/setting' + import { locationStorageKeyId } from '@hcengineering/ui' import { AnyComponent, CompAndProps, @@ -107,7 +108,7 @@ let panelInstance: PanelInstance let popupInstance: Popup - let visibileNav: boolean = true + let visibileNav: boolean = getMetadata(workbench.metadata.NavigationExpandedDefault) ?? true async function toggleNav (): Promise { visibileNav = !visibileNav closeTooltip() @@ -288,7 +289,7 @@ const fragment = loc.fragment let navigateDone = false if (app === undefined) { - const last = localStorage.getItem(`platform_last_loc_${loc.path[1]}`) + const last = localStorage.getItem(`${locationStorageKeyId}_${loc.path[1]}`) if (last != null) { const lastValue = JSON.parse(last) navigateDone = navigate(lastValue) @@ -332,7 +333,7 @@ space === undefined && ((navigatorModel?.spaces?.length ?? 0) > 0 || (navigatorModel?.specials?.length ?? 0) > 0) ) { - const last = localStorage.getItem(`platform_last_loc_${app}`) + const last = localStorage.getItem(`${locationStorageKeyId}_${app}`) if (last !== null) { const newLocation: Location = JSON.parse(last) if (newLocation.path[3] != null) { @@ -363,7 +364,7 @@ } } if (app !== undefined) { - localStorage.setItem(`platform_last_loc_${app}`, originalLoc) + localStorage.setItem(`${locationStorageKeyId}_${app}`, originalLoc) } currentQuery = loc.query if (fragment !== currentFragment) { @@ -514,8 +515,10 @@ visibileNav = false navFloat = true } else if ($deviceInfo.docWidth > 1024 && navFloat) { - navFloat = false - visibileNav = true + if (getMetadata(workbench.metadata.NavigationExpandedDefault) === undefined) { + navFloat = false + visibileNav = true + } } const checkOnHide = (): void => { if (visibileNav && $deviceInfo.docWidth <= 1024) visibileNav = false diff --git a/plugins/workbench/src/index.ts b/plugins/workbench/src/index.ts index b942dd0001..111afb98e0 100644 --- a/plugins/workbench/src/index.ts +++ b/plugins/workbench/src/index.ts @@ -139,7 +139,9 @@ export default plugin(workbenchId, { ExcludedApplications: '' as Metadata[]>, DefaultApplication: '' as Metadata, DefaultSpace: '' as Metadata>, - DefaultSpecial: '' as Metadata + DefaultSpecial: '' as Metadata, + // Default for navigation expanded state + NavigationExpandedDefault: '' as Metadata }, actionImpl: { Navigate: '' as ViewAction<{ diff --git a/server/backup/src/index.ts b/server/backup/src/index.ts index c60b5d4005..d0179841e0 100644 --- a/server/backup/src/index.ts +++ b/server/backup/src/index.ts @@ -625,9 +625,8 @@ export async function restore ( model: 'upgrade' })) as unknown as CoreClient & BackupClient - try { - for (const c of domains) { - console.log('loading server changeset for', c) + async function processDomain (c: Domain): Promise { + try { const changeset = await loadDigest(storage, snapshots, c, date) // We need to load full changeset from server const serverChangeset = new Map, string>() @@ -798,6 +797,23 @@ export async function restore ( await connection.clean(c, part) } } + return true + } catch (err: any) { + console.log('error', err) + return false + } + } + + try { + for (const c of domains) { + console.log('loading server changeset for', c) + let retry = 3 + while (retry > 0) { + retry-- + if (await processDomain(c)) { + break + } + } } } finally { await connection.close() diff --git a/server/elastic/src/backup.ts b/server/elastic/src/backup.ts index 1d0406d5cb..5f636e6798 100644 --- a/server/elastic/src/backup.ts +++ b/server/elastic/src/backup.ts @@ -130,7 +130,7 @@ class ElasticDataAdapter implements DbAdapter { if (e?.meta?.body?.error?.type === 'index_not_found_exception') { return undefined } - console.error(e) + console.error('elastic error:', e) throw new PlatformError(e) } },