mirror of
https://github.com/hcengineering/platform.git
synced 2026-09-10 19:57:43 +02:00
Add workbench tabs (#6788)
Signed-off-by: Kristina Fefelova <kristin.fefelova@gmail.com>
This commit is contained in:
@@ -30,10 +30,12 @@ import type {
|
||||
WidgetPreference,
|
||||
WidgetTab,
|
||||
WidgetType,
|
||||
SidebarEvent
|
||||
SidebarEvent,
|
||||
WorkbenchTab
|
||||
} from '@hcengineering/workbench'
|
||||
import { type AnyComponent } from '@hcengineering/ui'
|
||||
import core, { TClass, TDoc, TTx } from '@hcengineering/model-core'
|
||||
import presentation from '@hcengineering/model-presentation'
|
||||
|
||||
import workbench from './plugin'
|
||||
|
||||
@@ -98,6 +100,13 @@ export class TTxSidebarEvent extends TTx implements TxSidebarEvent {
|
||||
params!: Record<string, any>
|
||||
}
|
||||
|
||||
@Model(workbench.class.WorkbenchTab, preference.class.Preference)
|
||||
@UX(workbench.string.Tab)
|
||||
export class TWorkbenchTab extends TPreference implements WorkbenchTab {
|
||||
location!: string
|
||||
isPinned!: boolean
|
||||
}
|
||||
|
||||
export function createModel (builder: Builder): void {
|
||||
builder.createModel(
|
||||
TApplication,
|
||||
@@ -106,7 +115,8 @@ export function createModel (builder: Builder): void {
|
||||
TApplicationNavModel,
|
||||
TWidget,
|
||||
TWidgetPreference,
|
||||
TTxSidebarEvent
|
||||
TTxSidebarEvent,
|
||||
TWorkbenchTab
|
||||
)
|
||||
|
||||
builder.mixin(workbench.class.Application, core.class.Class, view.mixin.ObjectPresenter, {
|
||||
@@ -133,6 +143,52 @@ export function createModel (builder: Builder): void {
|
||||
mode: ['workbench']
|
||||
}
|
||||
})
|
||||
|
||||
createAction(builder, {
|
||||
action: workbench.actionImpl.PinTab,
|
||||
label: view.string.Pin,
|
||||
icon: view.icon.Pin,
|
||||
input: 'focus',
|
||||
category: workbench.category.Workbench,
|
||||
target: workbench.class.WorkbenchTab,
|
||||
query: {
|
||||
isPinned: false
|
||||
},
|
||||
context: {
|
||||
mode: 'context',
|
||||
group: 'edit'
|
||||
}
|
||||
})
|
||||
|
||||
createAction(builder, {
|
||||
action: workbench.actionImpl.UnpinTab,
|
||||
label: view.string.Unpin,
|
||||
icon: view.icon.Pin,
|
||||
input: 'focus',
|
||||
category: workbench.category.Workbench,
|
||||
target: workbench.class.WorkbenchTab,
|
||||
query: {
|
||||
isPinned: true
|
||||
},
|
||||
context: {
|
||||
mode: 'context',
|
||||
group: 'edit'
|
||||
}
|
||||
})
|
||||
|
||||
createAction(builder, {
|
||||
action: workbench.actionImpl.CloseTab,
|
||||
label: presentation.string.Close,
|
||||
icon: view.icon.Delete,
|
||||
input: 'focus',
|
||||
category: workbench.category.Workbench,
|
||||
target: workbench.class.WorkbenchTab,
|
||||
visibilityTester: workbench.function.CanCloseTab,
|
||||
context: {
|
||||
mode: 'context',
|
||||
group: 'edit'
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
export default workbench
|
||||
|
||||
@@ -13,11 +13,12 @@
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
import { type Doc, type Space } from '@hcengineering/core'
|
||||
import { type Doc, type Ref, type Space } from '@hcengineering/core'
|
||||
import { type IntlString, type Resource, mergeIds } from '@hcengineering/platform'
|
||||
import { type AnyComponent } from '@hcengineering/ui/src/types'
|
||||
import { workbenchId } from '@hcengineering/workbench'
|
||||
import workbench from '@hcengineering/workbench-resources/src/plugin'
|
||||
import type { ActionCategory, ViewActionAvailabilityFunction } from '@hcengineering/view'
|
||||
|
||||
export default mergeIds(workbenchId, workbench, {
|
||||
component: {
|
||||
@@ -30,6 +31,15 @@ export default mergeIds(workbenchId, workbench, {
|
||||
},
|
||||
function: {
|
||||
HasArchiveSpaces: '' as Resource<(spaces: Space[]) => Promise<boolean>>,
|
||||
IsOwner: '' as Resource<(docs: Doc[]) => Promise<boolean>>
|
||||
IsOwner: '' as Resource<(docs: Doc[]) => Promise<boolean>>,
|
||||
CanCloseTab: '' as Resource<ViewActionAvailabilityFunction<Doc>>
|
||||
},
|
||||
category: {
|
||||
Workbench: '' as Ref<ActionCategory>
|
||||
},
|
||||
actionImpl: {
|
||||
PinTab: '' as Resource<(doc?: Doc | Doc[]) => Promise<void>>,
|
||||
UnpinTab: '' as Resource<(doc?: Doc | Doc[]) => Promise<void>>,
|
||||
CloseTab: '' as Resource<(doc?: Doc | Doc[]) => Promise<void>>
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user