import { observable } from 'mobx' ; import type { UserInfoResource } from '@cloudbeaver/core-authentication' ; import { uuid } from '@cloudbeaver/core-utils' ; import type { ITab , ITabOptions } from './ITab' ; import type { NavigationTabsService } from './NavigationTabsService' ; export interface ITabNavigationContext { readonly isNewlyCreated : boolean ; readonly handlerPriority : number ; readonly tab : ITab | null ; openNewTab : < T = any > ( options : ITabOptions < T > ) => ITab < T > ; registerTab : ( tab : ITab ) => void ; } export class TabNavigationContext implements ITabNavigationContext { get isNewlyCreated ( ) : boolean { return this . _isNewlyCreated ; } get handlerPriority ( ) : number { return this . _handlerPriority ; } get tab ( ) : ITab < any > | null { return this . _tab ; } private _isNewlyCreated = false ; private _handlerPriority = 0 ; private _tab : ITab | null = null ; constructor ( private navigationTabsService , private userInfoResource ) { } openNewTab < T = any > ( options ) { this . _tab = observable ( { id : uuid ( ) , userId : this . userInfoResource . getId ( ) , restored : true , ... options , } ) ; this . _isNewlyCreated = true ; this . navigationTabsService . openTab ( this . _tab , true ) ; return this . _tab ; } registerTab ( tab ) { this . _tab = tab ; } }