11<script setup lang="ts">
2- import { computed , onMounted , ref , watch } from " vue" ;
2+ import { computed , watch } from " vue" ;
33import { RouterLink , useRoute } from " vue-router" ;
44import NoData from " ../NoData.vue" ;
55import TimeSince from " ../TimeSince.vue" ;
@@ -16,10 +16,10 @@ import RetryMessageButton from "@/components/messages/RetryMessageButton.vue";
1616import EditAndRetryButton from " @/components/messages/EditAndRetryButton.vue" ;
1717import ExportMessageButton from " @/components/messages/ExportMessageButton.vue" ;
1818import LoadingSpinner from " @/components/LoadingSpinner.vue" ;
19+ import TabsLayout from " @/components/TabsLayout.vue" ;
1920import { storeToRefs } from " pinia" ;
2021import MetadataLabel from " @/components/messages/MetadataLabel.vue" ;
2122
22- const panel = ref <number >(1 );
2323const route = useRoute ();
2424const id = computed (() => route .params .id as string );
2525const messageId = computed (() => route .params .messageId as string );
@@ -29,10 +29,6 @@ const isMassTransitConnected = useIsMassTransitConnected();
2929const store = useMessageViewStore ();
3030const { state } = storeToRefs (store );
3131
32- function togglePanel(panelNum : number ) {
33- panel .value = panelNum ;
34- }
35-
3632watch (
3733 [id , messageId ],
3834 async ([newId , newMessageId ], [oldId , oldMessageId ]) => {
@@ -49,8 +45,33 @@ watch(
4945 { immediate: true }
5046);
5147
52- onMounted (() => {
53- togglePanel (isError .value ? 1 : 2 );
48+ const tabs = computed (() => {
49+ const currentTabs = [
50+ {
51+ text: " Message body" ,
52+ component: BodyView ,
53+ },
54+ {
55+ text: " Headers" ,
56+ component: HeadersView ,
57+ },
58+ ];
59+
60+ if (isError .value ) {
61+ currentTabs .unshift ({
62+ text: " Stacktrace" ,
63+ component: StackTraceView ,
64+ });
65+ }
66+
67+ if (! isMassTransitConnected .value ) {
68+ currentTabs .push ({
69+ text: " Flow Diagram" ,
70+ component: FlowDiagram ,
71+ });
72+ }
73+
74+ return currentTabs ;
5475});
5576 </script >
5677
@@ -117,16 +138,7 @@ onMounted(() => {
117138 </div >
118139 <div class =" row" >
119140 <div class =" col-sm-12 no-side-padding" >
120- <div class =" nav tabs msg-tabs" >
121- <h5 v-if =" isError" :class =" { active: panel === 1 }" class =" nav-item" @click.prevent =" togglePanel(1)" ><a href =" #" >Stacktrace</a ></h5 >
122- <h5 :class =" { active: panel === 2 }" class =" nav-item" @click.prevent =" togglePanel(2)" ><a href =" #" >Message body</a ></h5 >
123- <h5 :class =" { active: panel === 3 }" class =" nav-item" @click.prevent =" togglePanel(3)" ><a href =" #" >Headers</a ></h5 >
124- <h5 v-if =" !isMassTransitConnected" :class =" { active: panel === 4 }" class =" nav-item" @click.prevent =" togglePanel(4)" ><a href =" #" >Flow Diagram</a ></h5 >
125- </div >
126- <StackTraceView v-if =" isError && panel === 1" />
127- <BodyView v-if =" panel === 2" />
128- <HeadersView v-if =" panel === 3" />
129- <FlowDiagram v-if =" panel === 4" />
141+ <TabsLayout :tabs =" tabs" />
130142 </div >
131143 </div >
132144 </template >
0 commit comments