2021-08-06 11:31:17 +03:00
|
|
|
//
|
|
|
|
// 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.
|
|
|
|
//
|
|
|
|
|
2024-10-01 10:53:36 +03:00
|
|
|
import type { AccountRole, Class, Doc, Mixin, Obj, Ref, Space, Tx } from '@hcengineering/core'
|
2024-03-19 12:48:03 +03:00
|
|
|
import { DocNotifyContext, InboxNotification } from '@hcengineering/notification'
|
2022-09-21 11:08:25 +03:00
|
|
|
import type { Asset, IntlString, Metadata, Plugin, Resource } from '@hcengineering/platform'
|
|
|
|
import { plugin } from '@hcengineering/platform'
|
2023-07-04 04:50:24 +03:00
|
|
|
import type { Preference } from '@hcengineering/preference'
|
2024-09-18 05:27:13 +03:00
|
|
|
import {
|
|
|
|
AnyComponent,
|
|
|
|
type AnySvelteComponent,
|
|
|
|
ComponentExtensionId,
|
|
|
|
Location,
|
|
|
|
ResolvedLocation
|
|
|
|
} from '@hcengineering/ui'
|
2022-09-21 11:08:25 +03:00
|
|
|
import { ViewAction } from '@hcengineering/view'
|
2021-08-06 11:31:17 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
2024-10-02 21:49:49 +03:00
|
|
|
|
|
|
|
export interface LocationData {
|
2024-10-29 16:06:16 +03:00
|
|
|
objectId?: Ref<Doc>
|
|
|
|
objectClass?: Ref<Class<Doc>>
|
2024-10-02 21:49:49 +03:00
|
|
|
name?: string
|
|
|
|
nameIntl?: IntlString
|
|
|
|
icon?: Asset
|
|
|
|
iconComponent?: AnyComponent
|
|
|
|
iconProps?: Record<string, any>
|
|
|
|
}
|
|
|
|
|
2021-08-06 11:31:17 +03:00
|
|
|
export interface Application extends Doc {
|
|
|
|
label: IntlString
|
2022-06-29 11:08:59 +03:00
|
|
|
alias: string
|
2021-08-06 11:31:17 +03:00
|
|
|
icon: Asset
|
2021-11-22 15:06:14 +03:00
|
|
|
hidden: boolean
|
2023-10-09 10:37:40 +03:00
|
|
|
position?: 'top' | 'mid'
|
2023-07-04 04:50:24 +03:00
|
|
|
|
|
|
|
// Also attached ApplicationNavModel will be joined after this one main.
|
2021-08-06 11:31:17 +03:00
|
|
|
navigatorModel?: NavigatorModel
|
2023-08-22 07:52:10 +03:00
|
|
|
aside?: AnyComponent
|
2023-07-04 04:50:24 +03:00
|
|
|
|
2023-03-20 11:45:52 +03:00
|
|
|
locationResolver?: Resource<(loc: Location) => Promise<ResolvedLocation | undefined>>
|
2024-10-02 21:49:49 +03:00
|
|
|
locationDataResolver?: Resource<(loc: Location) => Promise<LocationData>>
|
2022-01-11 12:05:53 +03:00
|
|
|
|
|
|
|
// Component will be displayed in case navigator model is not defined, or nothing is selected in navigator model
|
|
|
|
component?: AnyComponent
|
2022-03-31 11:32:42 +03:00
|
|
|
|
|
|
|
navHeaderComponent?: AnyComponent
|
2024-05-08 12:41:44 +03:00
|
|
|
accessLevel?: AccountRole
|
2022-03-31 11:32:42 +03:00
|
|
|
navFooterComponent?: AnyComponent
|
2021-08-06 11:31:17 +03:00
|
|
|
}
|
|
|
|
|
2024-09-18 05:27:13 +03:00
|
|
|
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
|
|
|
|
headerLabel?: IntlString
|
|
|
|
|
|
|
|
closeIfNoTabs?: boolean
|
|
|
|
onTabClose?: Resource<(tab: WidgetTab) => Promise<void>>
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface WidgetPreference extends Preference {
|
|
|
|
enabled: boolean
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface WidgetTab {
|
|
|
|
id: string
|
|
|
|
name?: string
|
|
|
|
icon?: Asset | AnySvelteComponent
|
|
|
|
iconComponent?: AnyComponent
|
|
|
|
iconProps?: Record<string, any>
|
|
|
|
isPinned?: boolean
|
|
|
|
allowedPath?: string
|
2024-10-29 16:06:16 +03:00
|
|
|
objectId?: Ref<Doc>
|
|
|
|
objectClass?: Ref<Class<Doc>>
|
2024-09-18 05:27:13 +03:00
|
|
|
data?: Record<string, any>
|
2024-11-07 13:08:15 +03:00
|
|
|
readonly?: boolean
|
2024-09-18 05:27:13 +03:00
|
|
|
}
|
|
|
|
|
2024-10-01 10:53:36 +03:00
|
|
|
export enum SidebarEvent {
|
|
|
|
OpenWidget = 'openWidget'
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface OpenSidebarWidgetParams {
|
|
|
|
widget: Ref<Widget>
|
|
|
|
tab?: WidgetTab
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface TxSidebarEvent<T extends Record<string, any> = Record<string, any>> extends Tx {
|
|
|
|
event: SidebarEvent
|
|
|
|
params: T
|
|
|
|
}
|
|
|
|
|
2024-10-02 21:49:49 +03:00
|
|
|
export interface WorkbenchTab extends Preference {
|
|
|
|
location: string
|
|
|
|
isPinned: boolean
|
2024-10-10 16:27:40 +03:00
|
|
|
name?: string
|
2024-10-02 21:49:49 +03:00
|
|
|
}
|
|
|
|
|
2023-07-04 04:50:24 +03:00
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
|
|
|
export interface ApplicationNavModel extends Doc {
|
|
|
|
extends: Ref<Application>
|
|
|
|
|
|
|
|
spaces?: SpacesNavModel[]
|
|
|
|
specials?: SpecialNavModel[]
|
|
|
|
aside?: AnyComponent
|
|
|
|
}
|
|
|
|
|
2022-11-01 18:48:20 +03:00
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
|
|
|
export interface HiddenApplication extends Preference {
|
|
|
|
attachedTo: Ref<Application>
|
|
|
|
}
|
|
|
|
|
2021-08-06 11:31:17 +03:00
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
|
|
|
export interface SpacesNavModel {
|
2023-07-04 04:50:24 +03:00
|
|
|
id: string // Id could be used for extending of navigation model
|
|
|
|
label?: IntlString
|
2021-08-06 11:31:17 +03:00
|
|
|
spaceClass: Ref<Class<Space>>
|
2023-07-04 04:50:24 +03:00
|
|
|
addSpaceLabel?: IntlString
|
|
|
|
createComponent?: AnyComponent
|
2022-04-02 07:06:48 +03:00
|
|
|
icon?: Asset
|
2022-03-31 11:32:42 +03:00
|
|
|
|
|
|
|
// Child special items.
|
|
|
|
specials?: SpecialNavModel[]
|
2023-06-16 14:29:07 +03:00
|
|
|
|
|
|
|
visibleIf?: Resource<(space: Space) => Promise<boolean>>
|
2021-08-06 11:31:17 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
|
|
|
export interface NavigatorModel {
|
|
|
|
spaces: SpacesNavModel[]
|
2021-11-22 15:06:14 +03:00
|
|
|
specials?: SpecialNavModel[]
|
2022-04-02 07:08:37 +03:00
|
|
|
aside?: AnyComponent
|
2021-11-22 15:06:14 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
|
|
|
export interface SpecialNavModel {
|
|
|
|
id: string // Uniq id
|
|
|
|
label: IntlString
|
2022-03-31 11:32:42 +03:00
|
|
|
icon?: Asset
|
2024-05-08 12:41:44 +03:00
|
|
|
accessLevel?: AccountRole
|
2021-11-22 15:06:14 +03:00
|
|
|
component: AnyComponent
|
2023-04-26 10:53:16 +03:00
|
|
|
componentProps?: Record<string, any>
|
2022-05-11 08:36:35 +03:00
|
|
|
// If not top and bottom, position will be sorted alphabetically.
|
|
|
|
position?: 'top' | 'bottom' | string // undefined == 'top
|
2023-02-27 06:03:03 +03:00
|
|
|
visibleIf?: Resource<(spaces: Space[]) => Promise<boolean>>
|
2022-03-04 12:01:46 +03:00
|
|
|
// If defined, will be used to find spaces for visibleIf
|
|
|
|
spaceClass?: Ref<Class<Space>>
|
2023-03-03 19:56:04 +03:00
|
|
|
checkIsDisabled?: Resource<() => Promise<boolean>>
|
2024-02-02 12:43:50 +03:00
|
|
|
notificationsCountProvider?: Resource<
|
|
|
|
(inboxNotificationsByContext: Map<Ref<DocNotifyContext>, InboxNotification[]>) => number
|
|
|
|
>
|
2021-08-06 11:31:17 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
|
|
|
export interface ViewConfiguration {
|
|
|
|
class: Ref<Class<Doc>> // show object of this class
|
|
|
|
createItemDialog?: AnyComponent
|
2022-03-14 12:04:41 +03:00
|
|
|
createItemLabel?: IntlString
|
2022-04-06 13:20:35 +03:00
|
|
|
|
|
|
|
// If defined component will be used to render content for selected space.
|
|
|
|
component?: AnyComponent
|
|
|
|
componentProps?: Record<string, any>
|
2021-08-06 11:31:17 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
|
|
|
export interface SpaceView extends Class<Obj> {
|
|
|
|
view: ViewConfiguration
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
|
|
|
export const workbenchId = 'workbench' as Plugin
|
|
|
|
|
2024-08-14 10:37:52 +03:00
|
|
|
export * from './analytics'
|
|
|
|
|
2021-08-06 11:31:17 +03:00
|
|
|
export default plugin(workbenchId, {
|
|
|
|
class: {
|
2022-11-01 18:48:20 +03:00
|
|
|
Application: '' as Ref<Class<Application>>,
|
2023-07-04 04:50:24 +03:00
|
|
|
ApplicationNavModel: '' as Ref<Class<ApplicationNavModel>>,
|
2024-09-18 05:27:13 +03:00
|
|
|
HiddenApplication: '' as Ref<Class<HiddenApplication>>,
|
|
|
|
Widget: '' as Ref<Class<Widget>>,
|
2024-10-01 10:53:36 +03:00
|
|
|
WidgetPreference: '' as Ref<Class<WidgetPreference>>,
|
2024-10-02 21:49:49 +03:00
|
|
|
TxSidebarEvent: '' as Ref<Class<TxSidebarEvent<Record<string, any>>>>,
|
|
|
|
WorkbenchTab: '' as Ref<Class<WorkbenchTab>>
|
2021-08-06 11:31:17 +03:00
|
|
|
},
|
|
|
|
mixin: {
|
|
|
|
SpaceView: '' as Ref<Mixin<SpaceView>>
|
2021-08-08 19:54:32 +03:00
|
|
|
},
|
|
|
|
component: {
|
2023-02-07 21:00:56 +03:00
|
|
|
WorkbenchApp: '' as AnyComponent,
|
2024-01-11 17:46:11 +03:00
|
|
|
InviteLink: '' as AnyComponent,
|
|
|
|
Archive: '' as AnyComponent,
|
2024-05-08 12:41:44 +03:00
|
|
|
SpecialView: '' as AnyComponent
|
2024-01-11 17:46:11 +03:00
|
|
|
},
|
|
|
|
string: {
|
|
|
|
Archive: '' as IntlString,
|
|
|
|
View: '' as IntlString,
|
2024-06-29 16:22:19 +03:00
|
|
|
ServerUnderMaintenance: '' as IntlString,
|
2024-09-18 05:27:13 +03:00
|
|
|
UpgradeDownloadProgress: '' as IntlString,
|
|
|
|
OpenInSidebar: '' as IntlString,
|
|
|
|
OpenInSidebarNewTab: '' as IntlString,
|
2024-11-12 14:06:51 +03:00
|
|
|
ConfigureWidgets: '' as IntlString,
|
|
|
|
WorkspaceIsArchived: '' as IntlString
|
2022-04-01 08:57:22 +03:00
|
|
|
},
|
2022-04-21 18:47:04 +03:00
|
|
|
icon: {
|
|
|
|
Search: '' as Asset
|
|
|
|
},
|
2023-06-20 08:47:00 +03:00
|
|
|
event: {
|
|
|
|
NotifyConnection: '' as Metadata<string>,
|
|
|
|
NotifyTitle: '' as Metadata<string>
|
|
|
|
},
|
2022-04-01 08:57:22 +03:00
|
|
|
metadata: {
|
|
|
|
PlatformTitle: '' as Metadata<string>,
|
2023-06-08 20:42:00 +03:00
|
|
|
ExcludedApplications: '' as Metadata<Ref<Application>[]>,
|
|
|
|
DefaultApplication: '' as Metadata<string>,
|
|
|
|
DefaultSpace: '' as Metadata<Ref<Space>>,
|
2023-06-26 17:03:12 +03:00
|
|
|
DefaultSpecial: '' as Metadata<string>,
|
|
|
|
// Default for navigation expanded state
|
|
|
|
NavigationExpandedDefault: '' as Metadata<boolean>
|
2022-05-04 11:08:12 +03:00
|
|
|
},
|
2024-03-19 12:48:03 +03:00
|
|
|
extensions: {
|
2024-10-02 21:49:49 +03:00
|
|
|
WorkbenchExtensions: '' as ComponentExtensionId,
|
|
|
|
WorkbenchTabExtensions: '' as ComponentExtensionId
|
2024-03-19 12:48:03 +03:00
|
|
|
},
|
2024-10-03 18:30:32 +03:00
|
|
|
function: {
|
|
|
|
CreateWidgetTab: '' as Resource<(widget: Widget, tab: WidgetTab, newTab: boolean) => Promise<void>>,
|
2024-10-29 16:06:16 +03:00
|
|
|
CloseWidgetTab: '' as Resource<(widget: Widget, tab: string) => Promise<void>>,
|
|
|
|
GetSidebarObject: '' as Resource<() => Partial<Pick<Doc, '_id' | '_class'>>>
|
2024-10-03 18:30:32 +03:00
|
|
|
},
|
2022-05-04 11:08:12 +03:00
|
|
|
actionImpl: {
|
|
|
|
Navigate: '' as ViewAction<{
|
|
|
|
mode: 'app' | 'special' | 'space'
|
2022-06-29 11:08:59 +03:00
|
|
|
application?: string
|
2022-05-04 11:08:12 +03:00
|
|
|
special?: string
|
|
|
|
space?: Ref<Space>
|
|
|
|
// If no space is selected, select first space from list
|
|
|
|
spaceClass?: Ref<Class<Space>>
|
|
|
|
spaceSpecial?: string
|
|
|
|
}>
|
2021-08-06 11:31:17 +03:00
|
|
|
}
|
|
|
|
})
|