11<script setup lang="ts">
22import { onMounted , ref } from " vue" ;
33import { useTypedFetchFromServiceControl } from " @/composables/serviceServiceControlUrls" ;
4- import { type DefaultEdge , MarkerType , useVueFlow , VueFlow , type Styles , type Node } from " @vue-flow/core" ;
4+ import { type DefaultEdge , MarkerType , VueFlow , type Styles , type Node } from " @vue-flow/core" ;
55import TimeSince from " ../TimeSince.vue" ;
66import routeLinks from " @/router/routeLinks" ;
77import Message from " @/resources/Message" ;
88import { NServiceBusHeaders } from " @/resources/Header" ;
99import { useRoute } from " vue-router" ;
1010import { ExtendedFailedMessage } from " @/resources/FailedMessage" ;
11+ import { Controls } from " @vue-flow/controls" ;
1112
1213const props = defineProps <{
1314 message: ExtendedFailedMessage ;
@@ -158,7 +159,6 @@ function constructEdges(mappedMessages: MappedMessage[]): DefaultEdge[] {
158159}
159160
160161const elements = ref <(Node | DefaultEdge )[]>([]);
161- const { onPaneReady, fitView } = useVueFlow ();
162162
163163onMounted (async () => {
164164 if (! props .message .conversationId ) return ;
@@ -178,13 +178,6 @@ onMounted(async () => {
178178 for (const root of mappedMessages .filter ((message ) => ! message .parentId )) assignDescendantLevelsAndWidth (root );
179179
180180 elements .value = [... constructNodes (mappedMessages ), ... constructEdges (mappedMessages )];
181- // TODO: if doing fitView on next Vue onUpdated() then it doesn't appear the elements
182- // are actually drawn yet. See if we can determine a better event to use this on rather than relying on setTimeout
183- setTimeout (() => fitView (), 50 );
184- });
185-
186- onPaneReady (({ fitView }) => {
187- fitView ();
188181});
189182
190183function typeIcon(type : MessageType ) {
@@ -201,7 +194,8 @@ function typeIcon(type: MessageType) {
201194
202195<template >
203196 <div id =" tree-container" >
204- <VueFlow v-model =" elements" :min-zoom =" 0.1" >
197+ <VueFlow v-model =" elements" :min-zoom =" 0.1" :fit-view-on-init =" true" >
198+ <Controls />
205199 <template #node-message =" nodeProps " >
206200 <div class =" node" :class =" [nodeProps.data.isError && 'error', nodeProps.data.id === props.message.id && 'current-message']" >
207201 <div class =" node-text wordwrap" >
@@ -230,6 +224,7 @@ function typeIcon(type: MessageType) {
230224<style >
231225@import " @vue-flow/core/dist/style.css" ;
232226@import " @vue-flow/core/dist/theme-default.css" ;
227+ @import " @vue-flow/controls/dist/style.css" ;
233228 </style >
234229
235230<style scoped>
0 commit comments