1
1
<script setup lang="ts">
2
- import Message from " @/resources/Message" ;
3
2
import { computed , onUnmounted , watch } from " vue" ;
4
3
import { RouterLink } from " vue-router" ;
5
4
import routeLinks from " @/router/routeLinks" ;
@@ -19,24 +18,20 @@ import SagaTimeoutIcon from "@/assets/SagaTimeoutIcon.svg";
19
18
import ToolbarEndpointIcon from " @/assets/Shell_ToolbarEndpoint.svg" ;
20
19
import NoSagaIcon from " @/assets/NoSaga.svg" ;
21
20
import CopyClipboardIcon from " @/assets/Shell_CopyClipboard.svg" ;
21
+ import { useMessageStore } from " @/stores/MessageStore" ;
22
+ import { storeToRefs } from " pinia" ;
22
23
23
- const props = withDefaults (
24
- defineProps <{
25
- message: Message ;
26
- }>(),
27
- {
28
- message : () => ({}) as Message ,
29
- }
30
- );
24
+ const store = useMessageStore ();
25
+ const { state : messageState } = storeToRefs (store );
31
26
32
27
const sagaDiagramStore = useSagaDiagramStore ();
33
28
34
29
// Watch for message and set saga ID when component mounts or message changes
35
30
watch (
36
- () => props . message ?. invoked_sagas ,
31
+ () => messageState . value . data . invoked_saga ,
37
32
(newSagas ) => {
38
- if (newSagas && newSagas ?. length > 0 ) {
39
- sagaDiagramStore .setSagaId (newSagas [ 0 ] .saga_id );
33
+ if (newSagas . has_saga ) {
34
+ sagaDiagramStore .setSagaId (newSagas .saga_id || " " );
40
35
} else {
41
36
sagaDiagramStore .clearSagaHistory ();
42
37
}
@@ -150,7 +145,7 @@ interface SagaViewModel {
150
145
MessageIdUrl: string ;
151
146
ParticipatedInSaga: boolean ;
152
147
HasSagaData: boolean ;
153
- ShowNoPluginActiveLeged : boolean ;
148
+ ShowNoPluginActiveLegend : boolean ;
154
149
SagaCompleted: boolean ;
155
150
FormattedCompletionTime: string ;
156
151
SagaUpdates: SagaUpdateViewModel [];
@@ -160,15 +155,13 @@ const vm = computed<SagaViewModel>(() => {
160
155
const completedUpdate = sagaDiagramStore .sagaHistory ?.changes .find ((update ) => update .status === " completed" );
161
156
const completionTime = completedUpdate ? new Date (completedUpdate .finish_time ) : null ;
162
157
163
- const invokedSaga = props .message ?.invoked_sagas ?.[0 ];
164
-
165
158
return {
166
- SagaTitle: typeToName (invokedSaga ? .saga_type ) || " Unknown saga" ,
167
- SagaGuid: invokedSaga ? .saga_id || " Missing guid" ,
168
- MessageIdUrl: routeLinks .messages .successMessage .link (props . message . message_id , props . message . id ),
169
- ParticipatedInSaga: invokedSaga !== undefined ,
159
+ SagaTitle: typeToName (messageState . value . data . invoked_saga .saga_type ) || " Unknown saga" ,
160
+ SagaGuid: messageState . value . data . invoked_saga .saga_id || " Missing guid" ,
161
+ MessageIdUrl: messageState . value && routeLinks .messages .successMessage .link (messageState . value . data . message_id || " " , messageState . value . data . id || " " ),
162
+ ParticipatedInSaga: messageState . value . data . invoked_saga . has_saga || false ,
170
163
HasSagaData: !! sagaDiagramStore .sagaHistory ,
171
- ShowNoPluginActiveLeged: ! sagaDiagramStore .sagaHistory && invokedSaga !== undefined ,
164
+ ShowNoPluginActiveLegend: ( ! sagaDiagramStore .sagaHistory && messageState . value . data . invoked_saga . has_saga ) || false ,
172
165
SagaCompleted: !! completedUpdate ,
173
166
FormattedCompletionTime: completionTime ? ` ${completionTime .toLocaleDateString ()} ${completionTime .toLocaleTimeString ()} ` : " " ,
174
167
SagaUpdates: parseSagaUpdates (sagaDiagramStore .sagaHistory ),
@@ -194,7 +187,7 @@ const vm = computed<SagaViewModel>(() => {
194
187
</div >
195
188
196
189
<!-- Saga Audit Plugin Needed container -->
197
- <div v-if =" vm.ShowNoPluginActiveLeged " class =" body" role =" status" aria-label =" saga-plugin-needed" >
190
+ <div v-if =" vm.ShowNoPluginActiveLegend " class =" body" role =" status" aria-label =" saga-plugin-needed" >
198
191
<div class =" saga-message" >
199
192
<div class =" saga-message-container" >
200
193
<img class =" saga-message-image" :src =" NoSagaIcon" alt =" " />
0 commit comments