1
1
<script setup lang="ts">
2
2
import { onMounted , ref } from " vue" ;
3
3
import { 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" ;
5
5
import TimeSince from " ../TimeSince.vue" ;
6
6
import routeLinks from " @/router/routeLinks" ;
7
7
import Message from " @/resources/Message" ;
8
8
import { NServiceBusHeaders } from " @/resources/Header" ;
9
9
import { useRoute } from " vue-router" ;
10
10
import { ExtendedFailedMessage } from " @/resources/FailedMessage" ;
11
+ import { Controls } from " @vue-flow/controls" ;
11
12
12
13
const props = defineProps <{
13
14
message: ExtendedFailedMessage ;
@@ -158,7 +159,6 @@ function constructEdges(mappedMessages: MappedMessage[]): DefaultEdge[] {
158
159
}
159
160
160
161
const elements = ref <(Node | DefaultEdge )[]>([]);
161
- const { onPaneReady, fitView } = useVueFlow ();
162
162
163
163
onMounted (async () => {
164
164
if (! props .message .conversationId ) return ;
@@ -178,13 +178,6 @@ onMounted(async () => {
178
178
for (const root of mappedMessages .filter ((message ) => ! message .parentId )) assignDescendantLevelsAndWidth (root );
179
179
180
180
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 ();
188
181
});
189
182
190
183
function typeIcon(type : MessageType ) {
@@ -201,7 +194,8 @@ function typeIcon(type: MessageType) {
201
194
202
195
<template >
203
196
<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 />
205
199
<template #node-message =" nodeProps " >
206
200
<div class =" node" :class =" [nodeProps.data.isError && 'error', nodeProps.data.id === props.message.id && 'current-message']" >
207
201
<div class =" node-text wordwrap" >
@@ -230,6 +224,7 @@ function typeIcon(type: MessageType) {
230
224
<style >
231
225
@import " @vue-flow/core/dist/style.css" ;
232
226
@import " @vue-flow/core/dist/theme-default.css" ;
227
+ @import " @vue-flow/controls/dist/style.css" ;
233
228
</style >
234
229
235
230
<style scoped>
0 commit comments