From 698b44614ef3b0e7375cb7a9bb128a7e615da8bb Mon Sep 17 00:00:00 2001 From: Kristina Date: Thu, 18 Sep 2025 07:16:03 +0400 Subject: [PATCH 1/8] Fix directs order (#9885) --- .../src/components/ChatNavigation.svelte | 3 -- server-plugins/card-resources/src/index.ts | 31 +++++++++++++++++++ 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/plugins/chat-resources/src/components/ChatNavigation.svelte b/plugins/chat-resources/src/components/ChatNavigation.svelte index f0bdaa5251..34cd5b34d8 100644 --- a/plugins/chat-resources/src/components/ChatNavigation.svelte +++ b/plugins/chat-resources/src/components/ChatNavigation.svelte @@ -116,9 +116,6 @@ { type: communication.type.Direct, order: 2 } ], fixedTypes: [chat.masterTag.Thread, communication.type.Direct], - specialSorting: { - [communication.type.Direct]: 'alphabetical' - }, allowCreate: true, defaultSorting: 'recent', lookback: '2w', diff --git a/server-plugins/card-resources/src/index.ts b/server-plugins/card-resources/src/index.ts index ebee2ab0ad..36d5fb046d 100644 --- a/server-plugins/card-resources/src/index.ts +++ b/server-plugins/card-resources/src/index.ts @@ -380,6 +380,37 @@ async function OnCardUpdate (ctx: TxUpdateDoc[], control: TriggerControl): }) } + res.push(...(await updatePeers(control, doc, updateTx))) + return res +} + +async function updatePeers (control: TriggerControl, doc: Card, updateTx: TxUpdateDoc): Promise { + if (updateTx.space === core.space.DerivedTx) return [] + const isDirect = control.hierarchy.isDerived(doc._class, communication.type.Direct) + const isThreadFromDirect = (doc.parentInfo ?? []).some((it) => + control.hierarchy.isDerived(it._class, communication.type.Direct) + ) + + if (!isDirect && !isThreadFromDirect) return [] + + delete updateTx.operations.title + delete updateTx.operations.parentInfo + delete updateTx.operations.parent + delete updateTx.operations.$inc + + const peers = ( + ( + await control.domainRequest(control.ctx, 'communication' as OperationDomain, { + findPeers: { params: { kind: 'card', cardId: doc._id } } + }) + ).value as CardPeer[] + ).flatMap((it) => it.members) + + const res: Tx[] = [] + for (const peer of peers) { + res.push(control.txFactory.createTxUpdateDoc(doc._class, peer.extra.space, peer.cardId, updateTx.operations)) + } + return res } From 0f01f53958cd104f8925be6261703c262c06e042 Mon Sep 17 00:00:00 2001 From: Denis Bykhov Date: Thu, 18 Sep 2025 08:18:57 +0500 Subject: [PATCH 2/8] Fix processes rollback (#9886) --- services/process/src/main.ts | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/services/process/src/main.ts b/services/process/src/main.ts index fcadfaa1b7..69cc902d6a 100644 --- a/services/process/src/main.ts +++ b/services/process/src/main.ts @@ -37,6 +37,7 @@ import process, { parseError, processError, ProcessError, + ProcessToDo, State, Step, Transition @@ -169,6 +170,10 @@ async function processExecution (control: ProcessControl, record: ProcessMessage if (transition !== undefined) { await execute(execution, transition, control) } else { + if (record.event === process.trigger.OnToDoRemove) { + const rollbackResult = await checkRollback(control, record, execution) + if (rollbackResult) return + } control.ctx.info('No transition found for event', { event: record.event, execution: execution._id, @@ -177,6 +182,23 @@ async function processExecution (control: ProcessControl, record: ProcessMessage } } +async function checkRollback (control: ProcessControl, record: ProcessMessage, execution: Execution): Promise { + const todo = record.context.todo as ProcessToDo + if (!todo?.withRollback) return false + const rollbackTxes = execution.rollback.pop() ?? [] + for (const tx of rollbackTxes) { + const timeout = setTimeout(() => { + control.ctx.warn('TX HANG', tx) + }, 30000) + await control.client.tx(tx) + clearTimeout(timeout) + } + await control.client.update(execution, { + rollback: execution.rollback + }) + return true +} + async function getTriggerRollback (triggger: TriggerImpl, control: ProcessControl): Promise { if (triggger.rollbackFunc !== undefined) { const rollbackFunc = await getResource(triggger.rollbackFunc) @@ -284,13 +306,12 @@ async function executeTransition (execution: Execution, transition: Transition, execution.rollback.push(rollback) } const executionUpdate = getDiffUpdate(execution, { - rollback: execution.rollback.length > 30 ? execution.rollback.slice(-30) : execution.rollback, - context: execution.context, currentState: state._id, status: isDone ? ExecutionStatus.Done : ExecutionStatus.Active, error: null }) executionUpdate.context = execution.context + executionUpdate.rollback = execution.rollback.length > 30 ? execution.rollback.slice(-30) : execution.rollback res.push(client.txFactory.createTxUpdateDoc(execution._class, execution.space, execution._id, executionUpdate)) res.push( client.txFactory.createTxCreateDoc(process.class.ExecutionLog, execution.space, { From ffff8c804b8017f02908774b40d73fbbe2034b41 Mon Sep 17 00:00:00 2001 From: Denis Bykhov Date: Thu, 18 Sep 2025 08:19:25 +0500 Subject: [PATCH 3/8] Fix function context presenter (#9887) --- .../components/attributeEditors/FunctionContextPresenter.svelte | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/process-resources/src/components/attributeEditors/FunctionContextPresenter.svelte b/plugins/process-resources/src/components/attributeEditors/FunctionContextPresenter.svelte index 7101d634e6..ae8592de93 100644 --- a/plugins/process-resources/src/components/attributeEditors/FunctionContextPresenter.svelte +++ b/plugins/process-resources/src/components/attributeEditors/FunctionContextPresenter.svelte @@ -22,7 +22,7 @@ export let context: Context const client = getClient() - const func = client.getModel().findObject(contextValue.func) + $: func = client.getModel().findObject(contextValue.func) {#if func !== undefined} From 4e18cf4eca555782a4cdde62d631815c534b6896 Mon Sep 17 00:00:00 2001 From: Denis Bykhov Date: Thu, 18 Sep 2025 08:20:11 +0500 Subject: [PATCH 4/8] Sortable actions (#9888) --- .../settings/StatesInlineEditor.svelte | 8 +- .../settings/TransitionEditor.svelte | 36 +++-- .../settings/TransitionsInlineEditor.svelte | 6 +- .../components/list/SortableDocList.svelte | 107 +++++++++++++ .../src/components/list/SortableList.svelte | 151 ++---------------- plugins/view-resources/src/index.ts | 2 + 6 files changed, 155 insertions(+), 155 deletions(-) create mode 100644 plugins/view-resources/src/components/list/SortableDocList.svelte diff --git a/plugins/process-resources/src/components/settings/StatesInlineEditor.svelte b/plugins/process-resources/src/components/settings/StatesInlineEditor.svelte index ce66596f54..fcd1884a38 100644 --- a/plugins/process-resources/src/components/settings/StatesInlineEditor.svelte +++ b/plugins/process-resources/src/components/settings/StatesInlineEditor.svelte @@ -17,11 +17,11 @@ import { translate } from '@hcengineering/platform' import { getClient } from '@hcengineering/presentation' import { Process, State } from '@hcengineering/process' + import { makeRank } from '@hcengineering/rank' import { Button, IconAdd, Label } from '@hcengineering/ui' + import { SortableDocList } from '@hcengineering/view-resources' import plugin from '../../plugin' import StateInlineEditor from './StateInlineEditor.svelte' - import { makeRank } from '@hcengineering/rank' - import { SortableList } from '@hcengineering/view-resources' export let process: Process export let states: State[] @@ -49,11 +49,11 @@
- + - + {#if !readonly} - {/each} + + + + + - + {#if !readonly}