diff --git a/models/view/src/index.ts b/models/view/src/index.ts index 1914840092..9dfbce8991 100644 --- a/models/view/src/index.ts +++ b/models/view/src/index.ts @@ -399,6 +399,13 @@ export const actionTemplates = template({ keyBinding: ['Enter'], input: 'focus', category: view.category.General + }, + openInNewTab: { + action: view.actionImpl.OpenInNewTab, + label: view.string.OpenInNewTab, + icon: view.icon.Open, + input: 'focus', + category: view.category.General } }) @@ -1046,6 +1053,17 @@ export function createModel (builder: Builder): void { view.action.Open ) + createAction( + builder, + { + ...actionTemplates.openInNewTab, + target: core.class.Doc, + category: view.category.Editor, + context: { mode: ['browser', 'context'], group: 'create' } + }, + view.action.OpenInNewTab + ) + builder.mixin(core.class.Status, core.class.Class, view.mixin.ObjectPresenter, { presenter: view.component.StatusPresenter }) diff --git a/models/view/src/plugin.ts b/models/view/src/plugin.ts index 5c5979bdec..241b829405 100644 --- a/models/view/src/plugin.ts +++ b/models/view/src/plugin.ts @@ -40,7 +40,8 @@ export default mergeIds(viewId, view, { ShowActions: '' as ViewAction, Preview: '' as ViewAction, - Open: '' as ViewAction + Open: '' as ViewAction, + OpenInNewTab: '' as ViewAction }, component: { StringEditor: '' as AnyComponent, diff --git a/plugins/view-assets/lang/en.json b/plugins/view-assets/lang/en.json index 44ea7e3c61..25ee11068f 100644 --- a/plugins/view-assets/lang/en.json +++ b/plugins/view-assets/lang/en.json @@ -21,6 +21,7 @@ "Archive": "Archive", "ArchiveConfirm": "Do you want to archive this {count, plural, =1 {object} other {# objects}}?", "Open": "Open", + "OpenInNewTab": "Open in new tab", "Assignees": "Assignees", "Labels": "Labels", "MoveLeft": "Move left", diff --git a/plugins/view-assets/lang/ru.json b/plugins/view-assets/lang/ru.json index 0980f7c672..3172665b5a 100644 --- a/plugins/view-assets/lang/ru.json +++ b/plugins/view-assets/lang/ru.json @@ -21,6 +21,7 @@ "Archive": "Архивировать", "ArchiveConfirm": "Вы действительно хотите заархивировать {count, plural, =1 {этот объект} one {этот # объект} few {эти # объекта} other {эти # объектов}}?", "Open": "Открыть", + "OpenInNewTab": "Открыть в новой вкладке", "Assignees": "Исполнители", "Labels": "Метки", "ActionPlaceholder": "Поиск или команда...", diff --git a/plugins/view-resources/src/actionImpl.ts b/plugins/view-resources/src/actionImpl.ts index f473645db5..ef8608602d 100644 --- a/plugins/view-resources/src/actionImpl.ts +++ b/plugins/view-resources/src/actionImpl.ts @@ -32,6 +32,7 @@ import { } from './selection' import { deleteObjects, getObjectLinkFragment } from './utils' import contact from '@hcengineering/contact' +import { locationToUrl } from '@hcengineering/ui' /** * Action to be used for copying text to clipboard. @@ -239,6 +240,26 @@ async function Open ( navigate(loc) } +async function OpenInNewTab ( + doc: Doc, + evt: Event, + props: + | { + component?: AnyComponent + } + | undefined +): Promise { + evt.preventDefault() + const d = Array.isArray(doc) ? doc[0] : doc + const client = getClient() + const hierarchy = client.getHierarchy() + const panelComponent = hierarchy.classHierarchyMixin(d._class, view.mixin.ObjectPanel) + const component = props?.component ?? panelComponent?.component ?? view.component.EditDoc + const loc = await getObjectLinkFragment(hierarchy, d, {}, component) + const url = locationToUrl(loc) + window.open(url, '_blank') +} + /** * Quick action for show panel * Require props: @@ -495,6 +516,7 @@ export const actionImpl = { ShowActions, ShowPreview, Open, + OpenInNewTab, UpdateDocument, ShowPanel, ShowPopup, diff --git a/plugins/view/src/index.ts b/plugins/view/src/index.ts index 7df8c832ae..785df41765 100644 --- a/plugins/view/src/index.ts +++ b/plugins/view/src/index.ts @@ -848,7 +848,8 @@ const view = plugin(viewId, { Preview: '' as Ref, // Edit document - Open: '' as Ref + Open: '' as Ref, + OpenInNewTab: '' as Ref }, viewlet: { Table: '' as Ref, @@ -888,6 +889,7 @@ const view = plugin(viewId, { Rename: '' as IntlString, Assigned: '' as IntlString, Open: '' as IntlString, + OpenInNewTab: '' as IntlString, Created: '' as IntlString, Delete: '' as IntlString, Then: '' as IntlString,