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.
|
|
|
|
//
|
|
|
|
|
2022-09-21 11:08:25 +03:00
|
|
|
import type { Class, Doc, Mixin, Obj, Ref, Space } from '@hcengineering/core'
|
|
|
|
import type { Asset, IntlString, Metadata, Plugin, Resource } from '@hcengineering/platform'
|
|
|
|
import { plugin } from '@hcengineering/platform'
|
|
|
|
import { AnyComponent, Location } from '@hcengineering/ui'
|
|
|
|
import { ViewAction } from '@hcengineering/view'
|
2022-11-01 18:48:20 +03:00
|
|
|
import type { Preference } from '@hcengineering/preference'
|
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
|
2021-08-06 11:31:17 +03:00
|
|
|
navigatorModel?: NavigatorModel
|
2022-06-30 06:46:46 +03:00
|
|
|
locationResolver?: Resource<(loc: Location) => Promise<Location | 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
|
|
|
|
navFooterComponent?: AnyComponent
|
2021-08-06 11:31:17 +03:00
|
|
|
}
|
|
|
|
|
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 {
|
|
|
|
label: IntlString
|
|
|
|
spaceClass: Ref<Class<Space>>
|
|
|
|
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[]
|
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
|
2021-11-22 15:06:14 +03:00
|
|
|
component: AnyComponent
|
2022-03-22 12:09:58 +03:00
|
|
|
componentProps?: Record<string, string>
|
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>>
|
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
|
|
|
|
|
|
|
|
export default plugin(workbenchId, {
|
|
|
|
class: {
|
2022-11-01 18:48:20 +03:00
|
|
|
Application: '' as Ref<Class<Application>>,
|
|
|
|
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,
|
|
|
|
InviteLink: '' as AnyComponent
|
2022-04-01 08:57:22 +03:00
|
|
|
},
|
2022-04-21 18:47:04 +03:00
|
|
|
icon: {
|
|
|
|
Search: '' as Asset
|
|
|
|
},
|
2022-04-01 08:57:22 +03:00
|
|
|
metadata: {
|
|
|
|
PlatformTitle: '' as Metadata<string>,
|
|
|
|
ExcludedApplications: '' as Metadata<Ref<Application>[]>
|
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
|
|
|
}
|
|
|
|
})
|