Line data Source code
1 : import { computed } from 'vue'
2 : import { useI18n } from 'vue-i18n'
3 :
4 : import { getExecutionStatusMessage } from '@/renderer/extensions/linearMode/getExecutionStatusMessage'
5 : import { app } from '@/scripts/app'
6 : import { useExecutionStore } from '@/stores/executionStore'
7 : import { useNodeDefStore } from '@/stores/nodeDefStore'
8 : import {
9 : executionIdToNodeLocatorId,
10 : getNodeByLocatorId
11 : } from '@/utils/graphTraversalUtil'
12 :
13 0 : function resolveStatus(
14 : t: (key: string) => string,
15 : nodeDefStore: ReturnType<typeof useNodeDefStore>,
16 : executionId: string | number
17 : ): string | null {
18 0 : const locatorId = executionIdToNodeLocatorId(app.rootGraph, executionId)
19 0 : if (!locatorId) return null
20 :
21 0 : const node = getNodeByLocatorId(app.rootGraph, locatorId)
22 0 : const nodeType = node?.type
23 0 : if (!nodeType) return null
24 :
25 : const nodeDef = nodeDefStore.nodeDefsByName[nodeType] ?? null
26 0 : return getExecutionStatusMessage(t, nodeType, nodeDef, node.properties)
27 : }
28 :
29 31 : export function useExecutionStatus() {
30 31 : const { t } = useI18n()
31 31 : const executionStore = useExecutionStore()
32 31 : const nodeDefStore = useNodeDefStore()
33 :
34 : const executionStatusMessage = computed<string | null>(() => {
35 31 : const executionId = executionStore.executingNodeId
36 31 : if (!executionId) return null
37 31 : return resolveStatus(t, nodeDefStore, executionId) || t('execution.running')
38 : })
39 :
40 31 : return { executionStatusMessage }
41 : }
|