11<script setup lang="ts">
2- import { type Ref , onUnmounted } from ' vue'
2+ import { type Ref , computed , onUnmounted } from ' vue'
33import { useRoute } from ' vue-router'
44import { useService } from ' @/composables/services'
55import KafkaGroups from ' ./KafkaGroups.vue'
@@ -13,29 +13,29 @@ const route = useRoute()
1313const serviceName = route .params .service ! .toString ()
1414const topicName = route .params .topic ?.toString ()
1515const { service, close } = <{service: Ref <KafkaService | null >, close: () => void }>fetchService (serviceName , ' kafka' )
16- function topic() {
16+ const topic = computed (() => {
1717 if (! service .value ) {return null }
1818 for (let topic of service .value ?.topics ){
1919 if (topic .name == topicName ) {
2020 return topic
2121 }
2222 }
2323 return null
24- }
24+ })
2525onUnmounted (() => {
2626 close ()
2727})
2828 </script >
2929
3030<template >
31- <div v-if =" $route.name == 'kafkaTopic' && service != null" >
31+ <div v-if =" $route.name == 'kafkaTopic' && service != null && topic " >
3232 <div class =" card-group" >
3333 <section class =" card" aria-label =" Info" >
3434 <div class =" card-body" >
3535 <div class =" row" >
3636 <div class =" col header mb-3" >
3737 <p id =" topic" class =" label" >Topic</p >
38- <p aria-labelledby =" topic" >{{ topic()? .name }}</p >
38+ <p aria-labelledby =" topic" >{{ topic.name }}</p >
3939 </div >
4040 <div class =" col header" >
4141 <p id =" cluster" class =" label" >Cluster</p >
@@ -56,7 +56,7 @@ onUnmounted(() => {
5656 <div class =" row" >
5757 <div class =" col" >
5858 <p id =" description" class =" label" >Description</p >
59- <markdown :source =" topic()? .description" aria-labelledby =" description" :html =" true" />
59+ <markdown :source =" topic.description" aria-labelledby =" description" :html =" true" />
6060 </div >
6161
6262 </div >
@@ -77,13 +77,13 @@ onUnmounted(() => {
7777 <kafka-messages :service =" service" :topicName =" topicName" />
7878 </div >
7979 <div class =" tab-pane fade" id =" partitions" role =" tabpanel" aria-labelledby =" partitions-tab" >
80- <kafka-partition :topic =" topic()! " />
80+ <kafka-partition :topic =" topic" />
8181 </div >
8282 <div class =" tab-pane fade" id =" groups" role =" tabpanel" aria-labelledby =" groups-tab" >
8383 <kafka-groups :service =" service" :topicName =" topicName" />
8484 </div >
8585 <div class =" tab-pane fade" id =" configs" role =" tabpanel" aria-labelledby =" configs-tab" >
86- <topic-config v-if = " topic() " :topic =" topic()! " />
86+ <topic-config :topic =" topic" />
8787 </div >
8888 </div >
8989 </div >
0 commit comments