From f55ac2e3d44817a88a28e3c92d03374c2b61dec8 Mon Sep 17 00:00:00 2001 From: Denis Bykhov Date: Wed, 9 Jul 2025 10:12:10 +0500 Subject: [PATCH] Process notifications (#9501) Signed-off-by: Denis Bykhov --- models/process/src/index.ts | 11 +++ plugins/card-resources/src/index.ts | 1 + plugins/process-assets/assets/icons.svg | 5 ++ plugins/process-assets/lang/cs.json | 3 +- plugins/process-assets/lang/de.json | 3 +- plugins/process-assets/lang/en.json | 3 +- plugins/process-assets/lang/es.json | 3 +- plugins/process-assets/lang/fr.json | 3 +- plugins/process-assets/lang/it.json | 3 +- plugins/process-assets/lang/ja.json | 3 +- plugins/process-assets/lang/pt.json | 3 +- plugins/process-assets/lang/ru.json | 3 +- plugins/process-assets/lang/zh.json | 3 +- plugins/process-assets/src/index.ts | 3 +- .../src/components/ExecutionLogs.svelte | 7 -- .../components/ExecutionNotification.svelte | 42 ++++++++++++ .../src/components/LogActionPresenter.svelte | 4 +- .../src/components/NotifierExtension.svelte | 68 +++++++++++++++++++ plugins/process-resources/src/index.ts | 4 +- plugins/process-resources/src/plugin.ts | 6 +- plugins/process/src/index.ts | 5 +- server-plugins/process-resources/src/index.ts | 6 ++ 22 files changed, 168 insertions(+), 24 deletions(-) create mode 100644 plugins/process-resources/src/components/ExecutionNotification.svelte create mode 100644 plugins/process-resources/src/components/NotifierExtension.svelte diff --git a/models/process/src/index.ts b/models/process/src/index.ts index 6604e0d526..0428915ad9 100644 --- a/models/process/src/index.ts +++ b/models/process/src/index.ts @@ -122,6 +122,12 @@ export class TExecutionLog extends TDoc implements ExecutionLog { @Prop(TypeRef(process.class.Execution), process.string.Execution) execution!: Ref + @Prop(TypeRef(process.class.Process), process.string.Process) + process!: Ref + + @Prop(TypeRef(card.class.Card), card.string.Card) + card!: Ref + @Prop(TypeRef(process.class.Transition), process.string.Transition) transition?: Ref @@ -925,6 +931,11 @@ export function createModel (builder: Builder): void { label: process.string.Processes, component: process.component.ProcessesSettingSection }) + + builder.createDoc(presentation.class.ComponentPointExtension, core.space.Model, { + extension: workbench.extensions.WorkbenchExtensions, + component: process.component.NotifierExtension + }) } export { processId } from '@hcengineering/process' diff --git a/plugins/card-resources/src/index.ts b/plugins/card-resources/src/index.ts index f443ee9d6c..8462ce7da0 100644 --- a/plugins/card-resources/src/index.ts +++ b/plugins/card-resources/src/index.ts @@ -71,6 +71,7 @@ export { default as CardSelector } from './components/CardSelector.svelte' export { default as CardIcon } from './components/CardIcon.svelte' export { default as Navigator } from './components/navigator-next/Navigator.svelte' export { default as Favorites } from './components/Favorites.svelte' +export { default as CardPresenter } from './components/CardPresenter.svelte' export * from './types' export { getCardIconInfo } from './utils' diff --git a/plugins/process-assets/assets/icons.svg b/plugins/process-assets/assets/icons.svg index 819ae87908..5a666f08ca 100644 --- a/plugins/process-assets/assets/icons.svg +++ b/plugins/process-assets/assets/icons.svg @@ -21,4 +21,9 @@ + + + diff --git a/plugins/process-assets/lang/cs.json b/plugins/process-assets/lang/cs.json index de92776fa2..9dd6c1ea4b 100644 --- a/plugins/process-assets/lang/cs.json +++ b/plugins/process-assets/lang/cs.json @@ -87,7 +87,8 @@ "Floor": "Zaokrouhlit dolů", "Ceil": "Zaokrouhlit nahoru", "Absolute": "Absolutní hodnota", - "LogAction": "Událost" + "LogAction": "Událost", + "Started": "Spuštěno" }, "error": { "MethodNotFound": "Metoda nenalezena: {methodId}", diff --git a/plugins/process-assets/lang/de.json b/plugins/process-assets/lang/de.json index 8d3c428158..90720cb9e1 100644 --- a/plugins/process-assets/lang/de.json +++ b/plugins/process-assets/lang/de.json @@ -87,7 +87,8 @@ "Floor": "Abrunden", "Ceil": "Aufrunden", "Absolute": "Absolutwert", - "LogAction": "Ereignis" + "LogAction": "Ereignis", + "Started": "Gestartet" }, "error": { "MethodNotFound": "Methode nicht gefunden: {methodId}", diff --git a/plugins/process-assets/lang/en.json b/plugins/process-assets/lang/en.json index b05c893aa7..84b5f03e6c 100644 --- a/plugins/process-assets/lang/en.json +++ b/plugins/process-assets/lang/en.json @@ -87,7 +87,8 @@ "Absolute": "Absolute", "Ceil": "Ceil", "Floor": "Floor", - "LogAction": "Event" + "LogAction": "Event", + "Started": "Started" }, "error": { "MethodNotFound": "Method not found: {methodId}", diff --git a/plugins/process-assets/lang/es.json b/plugins/process-assets/lang/es.json index bdd7723f8a..4eebb0efb8 100644 --- a/plugins/process-assets/lang/es.json +++ b/plugins/process-assets/lang/es.json @@ -87,7 +87,8 @@ "Floor": "Redondear hacia abajo", "Ceil": "Redondear hacia arriba", "Absolute": "Valor absoluto", - "LogAction": "Evento" + "LogAction": "Evento", + "Started": "Iniciado" }, "error": { "MethodNotFound": "Método no encontrado: {methodId}", diff --git a/plugins/process-assets/lang/fr.json b/plugins/process-assets/lang/fr.json index 48f095f597..aa9326aafa 100644 --- a/plugins/process-assets/lang/fr.json +++ b/plugins/process-assets/lang/fr.json @@ -87,7 +87,8 @@ "Floor": "Arrondir vers le bas", "Ceil": "Arrondir vers le haut", "Absolute": "Valeur absolue", - "LogAction": "Événement" + "LogAction": "Événement", + "Started": "Démarré" }, "error": { "MethodNotFound": "Méthode introuvable : {methodId}", diff --git a/plugins/process-assets/lang/it.json b/plugins/process-assets/lang/it.json index aee928d0da..900b0550dd 100644 --- a/plugins/process-assets/lang/it.json +++ b/plugins/process-assets/lang/it.json @@ -87,7 +87,8 @@ "Floor": "Arrotondare per difetto", "Ceil": "Arrotondare per eccesso", "Absolute": "Valore assoluto", - "LogAction": "Evento" + "LogAction": "Evento", + "Started": "Avviato" }, "error": { "MethodNotFound": "Metodo non trovato: {methodId}", diff --git a/plugins/process-assets/lang/ja.json b/plugins/process-assets/lang/ja.json index 7d5e0a01e9..8d5ea465d9 100644 --- a/plugins/process-assets/lang/ja.json +++ b/plugins/process-assets/lang/ja.json @@ -86,7 +86,8 @@ "Floor": "切り捨て", "Ceil": "切り上げ", "Absolute": "絶対値", - "LogAction": "イベント" + "LogAction": "イベント", + "Started": "開始" }, "error": { "MethodNotFound": "メソッドが見つかりません: {methodId}", diff --git a/plugins/process-assets/lang/pt.json b/plugins/process-assets/lang/pt.json index e3e9907af1..7648d1ba91 100644 --- a/plugins/process-assets/lang/pt.json +++ b/plugins/process-assets/lang/pt.json @@ -87,7 +87,8 @@ "Floor": "Arredondar para baixo", "Ceil": "Arredondar para cima", "Absolute": "Valor absoluto", - "LogAction": "Evento" + "LogAction": "Evento", + "Started": "Iniciado" }, "error": { "MethodNotFound": "Método não encontrado: {methodId}", diff --git a/plugins/process-assets/lang/ru.json b/plugins/process-assets/lang/ru.json index 78b8f7d7e5..ec5ec58620 100644 --- a/plugins/process-assets/lang/ru.json +++ b/plugins/process-assets/lang/ru.json @@ -87,7 +87,8 @@ "Floor": "Округлить вниз", "Ceil": "Округлить вверх", "Absolute": "Абсолютное значение", - "LogAction": "Событие" + "LogAction": "Событие", + "Started": "Начат" }, "error": { "MethodNotFound": "Метод не найден: {methodId}", diff --git a/plugins/process-assets/lang/zh.json b/plugins/process-assets/lang/zh.json index 3910e0f7a1..ae5cd258b2 100644 --- a/plugins/process-assets/lang/zh.json +++ b/plugins/process-assets/lang/zh.json @@ -87,7 +87,8 @@ "Floor": "向下取整", "Ceil": "向上取整", "Absolute": "绝对值", - "LogAction": "事件" + "LogAction": "事件", + "Started": "已启动" }, "error": { "MethodNotFound": "找不到方法:{methodId}", diff --git a/plugins/process-assets/src/index.ts b/plugins/process-assets/src/index.ts index 9a0187e0b8..d68daa2f09 100644 --- a/plugins/process-assets/src/index.ts +++ b/plugins/process-assets/src/index.ts @@ -23,5 +23,6 @@ loadMetadata(process.icon, { Steps: `${icons}#steps`, ToDo: `${icons}#todo`, ToDoRemove: `${icons}#todo-remove`, - WaitSubprocesses: `${icons}#subprocesses` + WaitSubprocesses: `${icons}#subprocesses`, + Start: `${icons}#start` }) diff --git a/plugins/process-resources/src/components/ExecutionLogs.svelte b/plugins/process-resources/src/components/ExecutionLogs.svelte index d6114730f4..010edc9942 100644 --- a/plugins/process-resources/src/components/ExecutionLogs.svelte +++ b/plugins/process-resources/src/components/ExecutionLogs.svelte @@ -118,12 +118,6 @@ }} /> - {/if} - diff --git a/plugins/process-resources/src/components/ExecutionNotification.svelte b/plugins/process-resources/src/components/ExecutionNotification.svelte new file mode 100644 index 0000000000..1097bd30db --- /dev/null +++ b/plugins/process-resources/src/components/ExecutionNotification.svelte @@ -0,0 +1,42 @@ + + + +{#if val} + + +
+ +
+
+ + {#if val.transition} + + {/if} +
+
+
+{/if} diff --git a/plugins/process-resources/src/components/LogActionPresenter.svelte b/plugins/process-resources/src/components/LogActionPresenter.svelte index 390919115b..b832cccd42 100644 --- a/plugins/process-resources/src/components/LogActionPresenter.svelte +++ b/plugins/process-resources/src/components/LogActionPresenter.svelte @@ -13,7 +13,7 @@ // limitations under the License. --> {#if value === ExecutionLogAction.Started} - + {:else if value === ExecutionLogAction.Transition} {:else} diff --git a/plugins/process-resources/src/components/NotifierExtension.svelte b/plugins/process-resources/src/components/NotifierExtension.svelte new file mode 100644 index 0000000000..aef54aa668 --- /dev/null +++ b/plugins/process-resources/src/components/NotifierExtension.svelte @@ -0,0 +1,68 @@ + + diff --git a/plugins/process-resources/src/index.ts b/plugins/process-resources/src/index.ts index 46dc65a84c..d3f90607ee 100644 --- a/plugins/process-resources/src/index.ts +++ b/plugins/process-resources/src/index.ts @@ -52,6 +52,7 @@ import { ProcessMiddleware } from './middleware' import { continueExecution, showDoneQuery, todoTranstionCheck } from './utils' import LogActionPresenter from './components/LogActionPresenter.svelte' import TransitionRefPresenter from './components/settings/TransitionRefPresenter.svelte' +import NotifierExtension from './components/NotifierExtension.svelte' export default async (): Promise => ({ actionImpl: { @@ -88,7 +89,8 @@ export default async (): Promise => ({ ProcessesCardSection, TransitionEditor, TransitionRefPresenter, - LogActionPresenter + LogActionPresenter, + NotifierExtension }, transformEditor: { DateOffsetEditor, diff --git a/plugins/process-resources/src/plugin.ts b/plugins/process-resources/src/plugin.ts index 7037cc69e2..3cfc4916ca 100644 --- a/plugins/process-resources/src/plugin.ts +++ b/plugins/process-resources/src/plugin.ts @@ -55,7 +55,8 @@ export default mergeIds(processId, process, { TransitionEditor: '' as AnyComponent, StateEditor: '' as AnyComponent, TransitionRefPresenter: '' as AnyComponent, - LogActionPresenter: '' as AnyComponent + LogActionPresenter: '' as AnyComponent, + NotifierExtension: '' as AnyComponent }, transformEditor: { DateOffsetEditor: '' as AnyComponent, @@ -148,6 +149,7 @@ export default mergeIds(processId, process, { Search: '' as IntlString, Separator: '' as IntlString, Start: '' as IntlString, - End: '' as IntlString + End: '' as IntlString, + Started: '' as IntlString } }) diff --git a/plugins/process/src/index.ts b/plugins/process/src/index.ts index a2ce7d9dd9..14374ef954 100644 --- a/plugins/process/src/index.ts +++ b/plugins/process/src/index.ts @@ -67,6 +67,8 @@ export interface Transition extends Doc { export interface ExecutionLog extends Doc { execution: Ref + card: Ref + process: Ref transition?: Ref action: ExecutionLogAction } @@ -217,7 +219,8 @@ export default plugin(processId, { States: '' as Asset, ToDo: '' as Asset, WaitSubprocesses: '' as Asset, - ToDoRemove: '' as Asset + ToDoRemove: '' as Asset, + Start: '' as Asset }, function: { FirstValue: '' as Ref, diff --git a/server-plugins/process-resources/src/index.ts b/server-plugins/process-resources/src/index.ts index 9b7b05f2fc..0b69dff355 100644 --- a/server-plugins/process-resources/src/index.ts +++ b/server-plugins/process-resources/src/index.ts @@ -177,6 +177,8 @@ async function executeTransition ( res.push( control.txFactory.createTxCreateDoc(process.class.ExecutionLog, execution.space, { execution: execution._id, + process: execution.process, + card: execution.card, transition: transition._id, action: ExecutionLogAction.Transition }) @@ -479,6 +481,8 @@ async function initState (execution: Execution, control: TriggerControl): Promis res.push( control.txFactory.createTxCreateDoc(process.class.ExecutionLog, execution.space, { execution: execution._id, + process: execution.process, + card: execution.card, transition: transition._id, action: ExecutionLogAction.Started }) @@ -546,6 +550,8 @@ export async function OnProcessToDoRemove (txes: Tx[], control: TriggerControl): res.push( control.txFactory.createTxCreateDoc(process.class.ExecutionLog, execution.space, { execution: execution._id, + process: execution.process, + card: execution.card, action: ExecutionLogAction.Rollback }) )