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-01-31 12:08:51 +03:00
|
|
|
import type { Class, Doc, Mixin, Obj, Ref, Space } from '@anticrm/core'
|
2022-04-01 08:57:22 +03:00
|
|
|
import type { Asset, IntlString, Metadata, Plugin, Resource } from '@anticrm/platform'
|
2021-08-06 11:31:17 +03:00
|
|
|
import { plugin } from '@anticrm/platform'
|
2022-03-04 12:01:46 +03:00
|
|
|
import { AnyComponent } from '@anticrm/ui'
|
2021-08-06 11:31:17 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
|
|
|
export interface Application extends Doc {
|
|
|
|
label: IntlString
|
|
|
|
icon: Asset
|
2021-11-22 15:06:14 +03:00
|
|
|
hidden: boolean
|
2021-08-06 11:31:17 +03:00
|
|
|
navigatorModel?: NavigatorModel
|
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
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @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>
|
2021-12-30 12:04:32 +03:00
|
|
|
position?: 'top'|'bottom' // undefined == 'top
|
2022-02-03 12:03:53 +03:00
|
|
|
visibleIf?: Resource<(spaces: Space[]) => 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: {
|
|
|
|
Application: '' as Ref<Class<Application>>
|
|
|
|
},
|
|
|
|
mixin: {
|
|
|
|
SpaceView: '' as Ref<Mixin<SpaceView>>
|
2021-08-08 19:54:32 +03:00
|
|
|
},
|
|
|
|
component: {
|
|
|
|
WorkbenchApp: '' as AnyComponent
|
2022-04-01 08:57:22 +03:00
|
|
|
},
|
|
|
|
metadata: {
|
|
|
|
PlatformTitle: '' as Metadata<string>,
|
|
|
|
ExcludedApplications: '' as Metadata<Ref<Application>[]>
|
2021-08-06 11:31:17 +03:00
|
|
|
}
|
|
|
|
})
|