mirror of
https://github.com/hcengineering/platform.git
synced 2025-05-11 01:40:32 +00:00
Fix thread open (#8344)
Signed-off-by: Kristina Fefelova <kristin.fefelova@gmail.com>
This commit is contained in:
parent
d9316aa8da
commit
6bf3ecd30a
@ -24,17 +24,15 @@ import type {
|
||||
ApplicationNavModel,
|
||||
HiddenApplication,
|
||||
SpaceView,
|
||||
TxSidebarEvent,
|
||||
ViewConfiguration,
|
||||
Widget,
|
||||
WidgetPreference,
|
||||
WidgetTab,
|
||||
WidgetType,
|
||||
SidebarEvent,
|
||||
WorkbenchTab
|
||||
} from '@hcengineering/workbench'
|
||||
import { type AnyComponent } from '@hcengineering/ui/src/types'
|
||||
import core, { TClass, TDoc, TTx } from '@hcengineering/model-core'
|
||||
import core, { TClass, TDoc } from '@hcengineering/model-core'
|
||||
import presentation from '@hcengineering/model-presentation'
|
||||
|
||||
import workbench from './plugin'
|
||||
@ -97,12 +95,6 @@ export class TWidgetPreference extends TPreference implements WidgetPreference {
|
||||
enabled!: boolean
|
||||
}
|
||||
|
||||
@Model(workbench.class.TxSidebarEvent, core.class.Doc)
|
||||
export class TTxSidebarEvent extends TTx implements TxSidebarEvent {
|
||||
event!: SidebarEvent
|
||||
params!: Record<string, any>
|
||||
}
|
||||
|
||||
@Model(workbench.class.WorkbenchTab, preference.class.Preference)
|
||||
@UX(workbench.string.Tab)
|
||||
export class TWorkbenchTab extends TPreference implements WorkbenchTab {
|
||||
@ -120,7 +112,6 @@ export function createModel (builder: Builder): void {
|
||||
TApplicationNavModel,
|
||||
TWidget,
|
||||
TWidgetPreference,
|
||||
TTxSidebarEvent,
|
||||
TWorkbenchTab
|
||||
)
|
||||
|
||||
|
@ -13,14 +13,12 @@
|
||||
// limitations under the License.
|
||||
-->
|
||||
<script lang="ts">
|
||||
import { Tx } from '@hcengineering/core'
|
||||
import { addTxListener, createQuery, getClient, removeTxListener } from '@hcengineering/presentation'
|
||||
import { createQuery, getClient } from '@hcengineering/presentation'
|
||||
import { panelstore } from '@hcengineering/ui'
|
||||
import { OpenSidebarWidgetParams, SidebarEvent, TxSidebarEvent, WidgetPreference } from '@hcengineering/workbench'
|
||||
import { onMount } from 'svelte'
|
||||
import { WidgetPreference } from '@hcengineering/workbench'
|
||||
|
||||
import workbench from '../../plugin'
|
||||
import { createWidgetTab, openWidget, sidebarStore, SidebarVariant } from '../../sidebar'
|
||||
import { sidebarStore, SidebarVariant } from '../../sidebar'
|
||||
import SidebarExpanded from './SidebarExpanded.svelte'
|
||||
import SidebarMini from './SidebarMini.svelte'
|
||||
|
||||
@ -36,29 +34,6 @@
|
||||
|
||||
$: mini = $sidebarStore.variant === SidebarVariant.MINI
|
||||
$: if ((!mini || mini) && $panelstore.panel?.refit !== undefined) $panelstore.panel.refit()
|
||||
|
||||
function txListener (txes: Tx[]): void {
|
||||
const evt = txes.findLast(
|
||||
(it) => it._class === workbench.class.TxSidebarEvent && evt.event === SidebarEvent.OpenWidget
|
||||
) as TxSidebarEvent
|
||||
if (evt !== undefined) {
|
||||
const params = evt.params as OpenSidebarWidgetParams
|
||||
const widget = client.getModel().findAllSync(workbench.class.Widget, { _id: params.widget })[0]
|
||||
if (widget === undefined) return
|
||||
if (params.tab !== undefined) {
|
||||
createWidgetTab(widget, params.tab)
|
||||
} else {
|
||||
openWidget(widget)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
onMount(() => {
|
||||
addTxListener(txListener)
|
||||
return () => {
|
||||
removeTxListener(txListener)
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
<div id="sidebar" class="antiPanel-application vertical sidebar-container" class:mini={mini || $sidebarStore.float}>
|
||||
|
@ -73,7 +73,10 @@
|
||||
})
|
||||
|
||||
onMount(() => {
|
||||
closeWrongTabs(getCurrentLocation())
|
||||
// We need to wait for location to be updated
|
||||
setTimeout(() => {
|
||||
closeWrongTabs(getCurrentLocation())
|
||||
}, 100)
|
||||
})
|
||||
|
||||
onDestroy(() => {
|
||||
|
@ -25,7 +25,6 @@ import type {
|
||||
ApplicationNavModel,
|
||||
HiddenApplication,
|
||||
SpaceView,
|
||||
TxSidebarEvent,
|
||||
Widget,
|
||||
WidgetPreference,
|
||||
WidgetTab,
|
||||
@ -43,7 +42,6 @@ export const workbenchPlugin = plugin(workbenchId, {
|
||||
HiddenApplication: '' as Ref<Class<HiddenApplication>>,
|
||||
Widget: '' as Ref<Class<Widget>>,
|
||||
WidgetPreference: '' as Ref<Class<WidgetPreference>>,
|
||||
TxSidebarEvent: '' as Ref<Class<TxSidebarEvent<Record<string, any>>>>,
|
||||
WorkbenchTab: '' as Ref<Class<WorkbenchTab>>
|
||||
},
|
||||
mixin: {
|
||||
|
@ -14,7 +14,7 @@
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
import type { AccountRole, AccountUuid, Class, Doc, DocumentQuery, Obj, Ref, Space, Tx } from '@hcengineering/core'
|
||||
import type { AccountRole, AccountUuid, Class, Doc, DocumentQuery, Obj, Ref, Space } from '@hcengineering/core'
|
||||
import { DocNotifyContext, InboxNotification } from '@hcengineering/notification'
|
||||
import type { Asset, IntlString, Resource } from '@hcengineering/platform'
|
||||
import type { Preference } from '@hcengineering/preference'
|
||||
@ -96,23 +96,6 @@ export interface WidgetTab {
|
||||
readonly?: boolean
|
||||
}
|
||||
|
||||
/** @public */
|
||||
export enum SidebarEvent {
|
||||
OpenWidget = 'openWidget'
|
||||
}
|
||||
|
||||
/** @public */
|
||||
export interface OpenSidebarWidgetParams {
|
||||
widget: Ref<Widget>
|
||||
tab?: WidgetTab
|
||||
}
|
||||
|
||||
/** @public */
|
||||
export interface TxSidebarEvent<T extends Record<string, any> = Record<string, any>> extends Tx {
|
||||
event: SidebarEvent
|
||||
params: T
|
||||
}
|
||||
|
||||
/** @public */
|
||||
export interface WorkbenchTab extends Preference {
|
||||
attachedTo: AccountUuid
|
||||
|
Loading…
Reference in New Issue
Block a user