// // Copyright © 2020, 2021 Anticrm Platform Contributors. // // Licensed under the Eclipse Public License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. You may // obtain a copy of the License at https://www.eclipse.org/legal/epl-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // // See the License for the specific language governing permissions and // limitations under the License. // import type { AccountRole, Class, Doc, Mixin, Obj, Ref, Space, Tx } from '@hcengineering/core' import { DocNotifyContext, InboxNotification } from '@hcengineering/notification' import type { Asset, IntlString, Metadata, Plugin, Resource } from '@hcengineering/platform' import { plugin } from '@hcengineering/platform' import type { Preference } from '@hcengineering/preference' import { AnyComponent, type AnySvelteComponent, ComponentExtensionId, Location, ResolvedLocation } from '@hcengineering/ui' import { ViewAction } from '@hcengineering/view' /** * @public */ export interface LocationData { objectId?: Ref objectClass?: Ref> name?: string nameIntl?: IntlString icon?: Asset iconComponent?: AnyComponent iconProps?: Record } export interface Application extends Doc { label: IntlString alias: string icon: Asset hidden: boolean position?: 'top' | 'mid' // Also attached ApplicationNavModel will be joined after this one main. navigatorModel?: NavigatorModel aside?: AnyComponent locationResolver?: Resource<(loc: Location) => Promise> locationDataResolver?: Resource<(loc: Location) => Promise> // Component will be displayed in case navigator model is not defined, or nothing is selected in navigator model component?: AnyComponent navHeaderComponent?: AnyComponent accessLevel?: AccountRole navFooterComponent?: AnyComponent } export enum WidgetType { Fixed = 'fixed', // Fixed sidebar are always visible Flexible = 'flexible', // Flexible sidebar are visible only in special cases (during the meeting, etc.) Configurable = 'configurable ' // Configurable might be fixed in sidebar by user in preferences } export interface Widget extends Doc { label: IntlString icon: Asset type: WidgetType component: AnyComponent tabComponent?: AnyComponent switcherComponent?: AnyComponent headerLabel?: IntlString closeIfNoTabs?: boolean onTabClose?: Resource<(tab: WidgetTab) => Promise> } export interface WidgetPreference extends Preference { enabled: boolean } export interface WidgetTab { id: string name?: string label?: IntlString icon?: Asset | AnySvelteComponent iconComponent?: AnyComponent iconProps?: Record isPinned?: boolean allowedPath?: string objectId?: Ref objectClass?: Ref> data?: Record readonly?: boolean } export enum SidebarEvent { OpenWidget = 'openWidget' } export interface OpenSidebarWidgetParams { widget: Ref tab?: WidgetTab } export interface TxSidebarEvent = Record> extends Tx { event: SidebarEvent params: T } export interface WorkbenchTab extends Preference { location: string isPinned: boolean name?: string } /** * @public */ export interface ApplicationNavModel extends Doc { extends: Ref spaces?: SpacesNavModel[] specials?: SpecialNavModel[] aside?: AnyComponent } /** * @public */ export interface HiddenApplication extends Preference { attachedTo: Ref } /** * @public */ export interface SpacesNavModel { id: string // Id could be used for extending of navigation model label?: IntlString spaceClass: Ref> addSpaceLabel?: IntlString createComponent?: AnyComponent icon?: Asset // Child special items. specials?: SpecialNavModel[] visibleIf?: Resource<(space: Space) => Promise> } /** * @public */ export interface NavigatorModel { spaces: SpacesNavModel[] specials?: SpecialNavModel[] aside?: AnyComponent } /** * @public */ export interface SpecialNavModel { id: string // Uniq id label: IntlString icon?: Asset accessLevel?: AccountRole component: AnyComponent componentProps?: Record // If not top and bottom, position will be sorted alphabetically. position?: 'top' | 'bottom' | string // undefined == 'top visibleIf?: Resource<(spaces: Space[]) => Promise> // If defined, will be used to find spaces for visibleIf spaceClass?: Ref> checkIsDisabled?: Resource<() => Promise> notificationsCountProvider?: Resource< (inboxNotificationsByContext: Map, InboxNotification[]>) => number > navigationModel?: ParentsNavigationModel } /** * @public */ export interface ParentsNavigationModel { navigationComponent: AnyComponent navigationComponentLabel: IntlString navigationComponentIcon?: Asset mainComponentLabel: IntlString mainComponentIcon?: Asset navigationComponentProps?: Record syncWithLocationQuery?: boolean createComponent?: AnyComponent createComponentProps?: Record } /** * @public */ export interface ViewConfiguration { class: Ref> // show object of this class createItemDialog?: AnyComponent createItemLabel?: IntlString // If defined component will be used to render content for selected space. component?: AnyComponent componentProps?: Record } /** * @public */ export interface SpaceView extends Class { view: ViewConfiguration } /** * @public */ export const workbenchId = 'workbench' as Plugin export * from './analytics' export default plugin(workbenchId, { class: { Application: '' as Ref>, ApplicationNavModel: '' as Ref>, HiddenApplication: '' as Ref>, Widget: '' as Ref>, WidgetPreference: '' as Ref>, TxSidebarEvent: '' as Ref>>>, WorkbenchTab: '' as Ref> }, mixin: { SpaceView: '' as Ref> }, component: { WorkbenchApp: '' as AnyComponent, InviteLink: '' as AnyComponent, Archive: '' as AnyComponent, SpecialView: '' as AnyComponent }, string: { Archive: '' as IntlString, View: '' as IntlString, ServerUnderMaintenance: '' as IntlString, UpgradeDownloadProgress: '' as IntlString, OpenInSidebar: '' as IntlString, OpenInSidebarNewTab: '' as IntlString, ConfigureWidgets: '' as IntlString, WorkspaceIsArchived: '' as IntlString }, icon: { Search: '' as Asset }, event: { NotifyConnection: '' as Metadata, NotifyTitle: '' as Metadata }, metadata: { PlatformTitle: '' as Metadata, ExcludedApplications: '' as Metadata[]>, DefaultApplication: '' as Metadata, DefaultSpace: '' as Metadata>, DefaultSpecial: '' as Metadata, // Default for navigation expanded state NavigationExpandedDefault: '' as Metadata }, extensions: { WorkbenchExtensions: '' as ComponentExtensionId, WorkbenchTabExtensions: '' as ComponentExtensionId }, function: { CreateWidgetTab: '' as Resource<(widget: Widget, tab: WidgetTab, newTab: boolean) => Promise>, CloseWidgetTab: '' as Resource<(widget: Widget, tab: string) => Promise>, CloseWidget: '' as Resource<(widget: Ref) => Promise>, GetSidebarObject: '' as Resource<() => Partial>> }, actionImpl: { Navigate: '' as ViewAction<{ mode: 'app' | 'special' | 'space' application?: string special?: string space?: Ref // If no space is selected, select first space from list spaceClass?: Ref> spaceSpecial?: string }> } })