2021-08-07 12:15:18 +00:00
|
|
|
//
|
|
|
|
// Copyright © 2020 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 08:08:25 +00:00
|
|
|
import { Class, DOMAIN_MODEL, Ref, Space } from '@hcengineering/core'
|
2023-04-25 07:34:10 +00:00
|
|
|
import { Builder, Mixin, Model, Prop, TypeRef, UX } from '@hcengineering/model'
|
2022-11-01 15:48:20 +00:00
|
|
|
import preference, { TPreference } from '@hcengineering/model-preference'
|
2023-04-25 07:34:10 +00:00
|
|
|
import { createAction } from '@hcengineering/model-view'
|
|
|
|
import type { Asset, IntlString } from '@hcengineering/platform'
|
|
|
|
import view, { KeyBinding } from '@hcengineering/view'
|
2023-07-04 01:50:24 +00:00
|
|
|
import type {
|
|
|
|
Application,
|
|
|
|
ApplicationNavModel,
|
|
|
|
HiddenApplication,
|
|
|
|
SpaceView,
|
|
|
|
ViewConfiguration
|
|
|
|
} from '@hcengineering/workbench'
|
2021-08-07 12:15:18 +00:00
|
|
|
|
2023-04-25 07:34:10 +00:00
|
|
|
import core, { TClass, TDoc } from '@hcengineering/model-core'
|
2021-08-07 12:15:18 +00:00
|
|
|
import workbench from './plugin'
|
|
|
|
|
2023-04-25 07:34:10 +00:00
|
|
|
export { workbenchId } from '@hcengineering/workbench'
|
2022-05-04 08:08:12 +00:00
|
|
|
export { Application }
|
|
|
|
|
2021-08-07 12:15:18 +00:00
|
|
|
@Model(workbench.class.Application, core.class.Doc, DOMAIN_MODEL)
|
2022-02-23 16:10:11 +00:00
|
|
|
@UX(workbench.string.Application)
|
2021-08-07 12:15:18 +00:00
|
|
|
export class TApplication extends TDoc implements Application {
|
|
|
|
label!: IntlString
|
|
|
|
icon!: Asset
|
2022-06-29 08:08:59 +00:00
|
|
|
alias!: string
|
2023-10-09 07:37:40 +00:00
|
|
|
position?: 'top' | 'mid'
|
2021-11-22 12:06:14 +00:00
|
|
|
hidden!: boolean
|
2021-08-07 12:15:18 +00:00
|
|
|
}
|
|
|
|
|
2023-07-04 01:50:24 +00:00
|
|
|
@Model(workbench.class.ApplicationNavModel, core.class.Doc, DOMAIN_MODEL)
|
|
|
|
@UX(workbench.string.Application)
|
|
|
|
export class TApplicationNavModel extends TDoc implements ApplicationNavModel {
|
|
|
|
extends!: Ref<Application>
|
|
|
|
}
|
|
|
|
|
2022-11-01 15:48:20 +00:00
|
|
|
@Model(workbench.class.HiddenApplication, preference.class.Preference)
|
|
|
|
export class THiddenApplication extends TPreference implements HiddenApplication {
|
|
|
|
@Prop(TypeRef(workbench.class.Application), workbench.string.HiddenApplication)
|
2023-10-07 10:38:21 +00:00
|
|
|
declare attachedTo: Ref<Application>
|
2022-11-01 15:48:20 +00:00
|
|
|
}
|
|
|
|
|
2021-08-07 12:15:18 +00:00
|
|
|
@Mixin(workbench.mixin.SpaceView, core.class.Class)
|
|
|
|
export class TSpaceView extends TClass implements SpaceView {
|
|
|
|
view!: ViewConfiguration
|
|
|
|
}
|
|
|
|
|
|
|
|
export function createModel (builder: Builder): void {
|
2023-07-04 01:50:24 +00:00
|
|
|
builder.createModel(TApplication, TSpaceView, THiddenApplication, TApplicationNavModel)
|
2023-01-14 10:54:54 +00:00
|
|
|
builder.mixin(workbench.class.Application, core.class.Class, view.mixin.ObjectPresenter, {
|
2021-12-14 09:24:14 +00:00
|
|
|
presenter: workbench.component.ApplicationPresenter
|
|
|
|
})
|
2023-02-14 18:26:53 +00:00
|
|
|
|
|
|
|
builder.mixin(workbench.class.Application, core.class.Class, view.mixin.IgnoreActions, {
|
|
|
|
actions: [view.action.Delete]
|
|
|
|
})
|
2021-08-07 12:15:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export default workbench
|
2022-05-04 08:08:12 +00:00
|
|
|
|
|
|
|
export function createNavigateAction (
|
|
|
|
builder: Builder,
|
|
|
|
key: KeyBinding,
|
|
|
|
label: IntlString,
|
2022-06-29 08:08:59 +00:00
|
|
|
application: Ref<Application>,
|
|
|
|
props: {
|
2022-05-04 08:08:12 +00:00
|
|
|
mode: 'app' | 'special' | 'space'
|
2022-06-29 08:08:59 +00:00
|
|
|
application?: string
|
2022-05-04 08:08:12 +00:00
|
|
|
special?: string
|
|
|
|
space?: Ref<Space>
|
|
|
|
spaceClass?: Ref<Class<Space>>
|
|
|
|
spaceSpecial?: string
|
2023-06-03 03:49:20 +00:00
|
|
|
query?: Record<string, string | null>
|
2022-05-04 08:08:12 +00:00
|
|
|
}
|
|
|
|
): void {
|
|
|
|
createAction(builder, {
|
|
|
|
action: workbench.actionImpl.Navigate,
|
2022-06-29 08:08:59 +00:00
|
|
|
actionProps: props,
|
2022-05-04 08:08:12 +00:00
|
|
|
label,
|
|
|
|
icon: view.icon.ArrowRight,
|
|
|
|
keyBinding: [key],
|
|
|
|
input: 'none',
|
|
|
|
category: view.category.Navigation,
|
|
|
|
target: core.class.Doc,
|
|
|
|
context: {
|
|
|
|
mode: ['workbench', 'browser', 'editor', 'panel', 'popup'],
|
2022-06-29 08:08:59 +00:00
|
|
|
application
|
2022-05-04 08:08:12 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|