Fix tracker project actions (#10786)

* Fix tracker project actions

Signed-off-by: Artem Savchenko <armisav@gmail.com>

* Revert "Fix tracker project actions"

This reverts commit 586c6562bd.

* Convert docs for all actions

Signed-off-by: Artem Savchenko <armisav@gmail.com>

* Clean up

Signed-off-by: Artem Savchenko <armisav@gmail.com>

* Clean up

Signed-off-by: Artem Savchenko <armisav@gmail.com>

---------

Signed-off-by: Artem Savchenko <armisav@gmail.com>
This commit is contained in:
Artyom Savchenko
2026-04-20 13:06:57 +07:00
committed by GitHub
parent 4da2c637f4
commit 49a2edf19e
2 changed files with 16 additions and 4 deletions
+14 -2
View File
@@ -41,6 +41,18 @@ import view from './plugin'
import { type FocusSelection, type SelectionStore } from './selection'
import { restrictionStore } from './utils'
/**
* Collapses a single-element array to the element, otherwise returns the original value.
*
* @public
*/
export function normalizeActionContext<T extends Doc> (doc: T | T[] | undefined): T | T[] | undefined {
if (Array.isArray(doc) && doc.length === 1) {
return doc[0]
}
return doc
}
/**
* @public
*/
@@ -114,7 +126,7 @@ export async function filterAvailableActions (
} else {
const visibilityTester = await getResource(action.visibilityTester)
if (await visibilityTester(doc)) {
if (await visibilityTester(normalizeActionContext(doc))) {
result.push(action)
}
}
@@ -132,7 +144,7 @@ export async function invokeAction (
): Promise<void> {
const impl = await getResource(action.action)
Analytics.handleEvent(action.analyticsEvent ?? action._id)
await impl(Array.isArray(object) && object.length === 1 ? object[0] : object, evt, {
await impl(normalizeActionContext(object), evt, {
...action.actionProps,
...props
})
@@ -51,7 +51,7 @@
} from '@hcengineering/ui'
import { Action, ActionCategory, ViewContext } from '@hcengineering/view'
import { createEventDispatcher, onMount, tick } from 'svelte'
import { filterActions, getSelection } from '../actions'
import { filterActions, getSelection, normalizeActionContext } from '../actions'
import view from '../plugin'
import { focusStore, selectionStore } from '../selection'
import { openDoc } from '../utils'
@@ -99,7 +99,7 @@
} else {
const visibilityTester = await getResource(action.visibilityTester)
if (await visibilityTester(docs)) {
if (await visibilityTester(normalizeActionContext(docs))) {
resultActions.push(action)
}
}