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-05-08 12:41:44 +03:00
|
|
|
import type { AccountRole, Class, Doc, Mixin, Obj, Ref, Space } 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-03-19 12:48:03 +03:00
|
|
|
import { AnyComponent, 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
|
|
|
|
*/
|
|
|
|
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>>
|
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
|
|
|
}
|
|
|
|
|
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>>,
|
2022-11-01 18:48:20 +03:00
|
|
|
HiddenApplication: '' as Ref<Class<HiddenApplication>>
|
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,
|
|
|
|
UpgradeDownloadProgress: '' 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: {
|
|
|
|
WorkbenchExtensions: '' as ComponentExtensionId
|
|
|
|
},
|
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
|
|
|
}
|
|
|
|
})
|