feat(metrics): implement ability to hide internal topics in charts#2297
feat(metrics): implement ability to hide internal topics in charts#2297
Conversation
| const isInternalTopic = (topic: TopicOption) => topic.name.startsWith('__') | ||
|
|
||
| const filteredTopicList = showInternal | ||
| ? topicList | ||
| : topicList.filter((t) => !isInternalTopic(t)) |
There was a problem hiding this comment.
The topics should have already been filtered by the API right? I'm not sure this is needed, and I think it's different from the topic list page where only the API filters hidden ones.
There was a problem hiding this comment.
Initially I was using the includeHidden query param in the URL so the API would filter topics.
But toggling the switch updated the URL each time, which caused the whole page (server components) to re-render.
That felt unnecessarily heavy just for showing/hiding internal topics.
So instead, I fetch all topics once (including hidden ones), and then handle the internal topic filtering on the client using:
const isInternalTopic = (topic: TopicOption) =>
topic.name.startsWith('__')
This way, toggling the switch only affects local state and doesn’t trigger a full page re-render.
It keeps the UI more responsive while avoiding extra API calls.
There was a problem hiding this comment.
I see your point and I don't disagree with the concept, but the issue is that topics aren't identified by leading __ alone. There is a separate flag for internal within Kafka. I.e., I can name a topic with __ as the prefix and it would still not be internal. If you fetch all of the topics regardless or visibility, you can look at the attributes.internal value instead of filtering based on name.
There was a problem hiding this comment.
The popover mentions that internal topics are prefixed with __, so I initially used startsWith('__') based on that convention. But I agree it’s better to rely on attributes.internal from the API, so I’ll update it accordingly.
There was a problem hiding this comment.
I have updated to show the topics based on visibility attribute
Signed-off-by: hemahg <hhg@redhat.com>
Signed-off-by: hemahg <hhg@redhat.com>
Signed-off-by: hemahg <hhg@redhat.com>
Signed-off-by: hemahg <hhg@redhat.com>
Signed-off-by: hemahg <hhg@redhat.com>
16b45dd to
c57bad5
Compare
|



feat(metrics): implement ability to hide internal topics in charts