UBER-944: action for opening in new tab (#4447)

Signed-off-by: Vyacheslav Tumanov <me@slavatumanov.me>
This commit is contained in:
Vyacheslav Tumanov 2024-01-30 16:08:28 +05:00 committed by GitHub
parent 9de78e5435
commit a7d668cd40
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 47 additions and 2 deletions

View File

@ -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
})

View File

@ -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,

View File

@ -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",

View File

@ -21,6 +21,7 @@
"Archive": "Архивировать",
"ArchiveConfirm": "Вы действительно хотите заархивировать {count, plural, =1 {этот объект} one {этот # объект} few {эти # объекта} other {эти # объектов}}?",
"Open": "Открыть",
"OpenInNewTab": "Открыть в новой вкладке",
"Assignees": "Исполнители",
"Labels": "Метки",
"ActionPlaceholder": "Поиск или команда...",

View File

@ -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<void> {
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,

View File

@ -848,7 +848,8 @@ const view = plugin(viewId, {
Preview: '' as Ref<Action>,
// Edit document
Open: '' as Ref<Action>
Open: '' as Ref<Action>,
OpenInNewTab: '' as Ref<Action>
},
viewlet: {
Table: '' as Ref<ViewletDescriptor>,
@ -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,