Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions common/config/rush/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions plugins/view-resources/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
"@hcengineering/query": "^0.7.17",
"@hcengineering/emoji": "workspace:^0.7.0",
"@hcengineering/theme": "workspace:^0.7.0",
"@hcengineering/workbench": "workspace:^0.7.0",
"@hcengineering/hls": "workspace:^0.7.0",
"fast-equals": "^5.2.2"
}
Expand Down
11 changes: 9 additions & 2 deletions plugins/view-resources/src/actionImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
copyTextToClipboardOldBrowser,
getClient,
getMarkup,
hasResource,
updateAttribute
} from '@hcengineering/presentation'
import { markupToJSON } from '@hcengineering/text'
Expand Down Expand Up @@ -48,6 +49,7 @@ import {
selectionStore
} from './selection'
import { deleteObjects, getObjectId, getObjectLinkFragment, restrictionStore } from './utils'
import workbenchPlugin from '@hcengineering/workbench'

/**
* Action to be used for copying text to clipboard.
Expand Down Expand Up @@ -328,8 +330,13 @@ async function OpenInNewTab (
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')
if (hasResource(workbenchPlugin.function.OpenInNewTab) === true) {
const res = await getResource(workbenchPlugin.function.OpenInNewTab)
await res(loc)
} else {
const url = locationToUrl(loc)
window.open(url, '_blank')
}
}

/**
Expand Down
5 changes: 3 additions & 2 deletions plugins/workbench-resources/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import Workbench from './components/Workbench.svelte'
import ServerManager from './components/ServerManager.svelte'
import WorkbenchTabs from './components/WorkbenchTabs.svelte'
import { isAdminUser } from '@hcengineering/presentation'
import { canCloseTab, closeCurrentTab, closeTab, pinTab, unpinTab } from './workbench'
import { canCloseTab, closeCurrentTab, closeTab, OpenInNewTab, pinTab, unpinTab } from './workbench'
import { closeWidget, closeWidgetTab, createWidgetTab, getSidebarObject } from './sidebar'

async function hasArchiveSpaces (spaces: Space[]): Promise<boolean> {
Expand Down Expand Up @@ -66,7 +66,8 @@ export default async (): Promise<Resources> => ({
CloseWidget: closeWidget,
GetSidebarObject: getSidebarObject,
LogIn: logIn,
LogOut: logOut
LogOut: logOut,
OpenInNewTab
},
actionImpl: {
Navigate: doNavigate,
Expand Down
13 changes: 13 additions & 0 deletions plugins/workbench-resources/src/workbench.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,19 @@ export function getTabLocation (tab: Pick<WorkbenchTab, 'location'>): Location {
return parseLocation(url)
}

export async function OpenInNewTab (loc: Location): Promise<void> {
const client = getClient()
const data = await getTabDataByLocation(loc)
const name = data.name ?? (await translate(data.label, {}, get(languageStore)))
const url = locationToUrl(loc)
await client.createDoc(workbench.class.WorkbenchTab, core.space.Workspace, {
attachedTo: getCurrentAccount().uuid,
location: url,
isPinned: false,
name
})
}

export async function closeTab (tab: WorkbenchTab): Promise<void> {
const tabs = get(tabsStore)
const index = tabs.findIndex((t) => t._id === tab._id)
Expand Down
5 changes: 3 additions & 2 deletions plugins/workbench/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import type { Class, Doc, Mixin, Ref, Space } from '@hcengineering/core'
import type { Asset, IntlString, Metadata, Plugin, Resource } from '@hcengineering/platform'
import { plugin } from '@hcengineering/platform'
import { AnyComponent, ComponentExtensionId } from '@hcengineering/ui'
import { AnyComponent, ComponentExtensionId, Location } from '@hcengineering/ui'
import { Action, ViewAction } from '@hcengineering/view'

import type {
Expand Down Expand Up @@ -95,7 +95,8 @@ export const workbenchPlugin = plugin(workbenchId, {
CloseWidget: '' as Resource<(widget: Ref<Widget>) => Promise<void>>,
GetSidebarObject: '' as Resource<() => Partial<Pick<Doc, '_id' | '_class'>>>,
LogIn: '' as Resource<(loginInfo: { account: string, token?: string }) => Promise<void>>,
LogOut: '' as Resource<() => Promise<void>>
LogOut: '' as Resource<() => Promise<void>>,
OpenInNewTab: '' as Resource<(loc: Location) => Promise<void>>
},
actionImpl: {
Navigate: '' as ViewAction<{
Expand Down