Copilot commented on code in PR #10089:
URL: https://github.com/apache/gravitino/pull/10089#discussion_r2867142361
##########
web-v2/web/src/lib/store/metalakes/index.js:
##########
@@ -1829,6 +1828,24 @@ export const appMetalakesSlice = createSlice({
setTableProps(state, action) {
state.tableProps = action.payload
},
+ removeTopicFromStore(state, action) {
+ const { metalake, catalog, catalogType, schema, topic } = action.payload
+ const schemaKey =
`{{${metalake}}}{{${catalog}}}{{${catalogType}}}{{${schema}}}`
+ const topicKey =
`{{${metalake}}}{{${catalog}}}{{${catalogType}}}{{${schema}}}{{${topic}}}`
+
+ state.topics = state.topics.filter(item => item.name !== topic)
+ state.tableData = state.tableData.filter(item => !(item?.node ===
'topic' && item?.name === topic))
+ state.selectedNodes = state.selectedNodes.filter(key => key !== topicKey)
+
+ if (state.activatedDetails?.name === topic) {
+ state.activatedDetails = null
Review Comment:
When a deleted topic is currently shown in the details panel, this reducer
only sets `activatedDetails = null`. The tag/policy counters are stored
separately in `currentEntityTags` / `currentEntityPolicies`, so they can remain
populated and keep showing stale tag/policy info for a non-existent topic (and
may trigger follow-up UI actions against a deleted entity). If
`activatedDetails` is cleared here, also reset `currentEntityTags` and
`currentEntityPolicies` (and any other topic-scoped detail state) to keep the
UI consistent.
```suggestion
state.activatedDetails = null
state.currentEntityTags = []
state.currentEntityPolicies = []
```
##########
web-v2/web/src/lib/store/metalakes/index.js:
##########
@@ -1829,6 +1828,24 @@ export const appMetalakesSlice = createSlice({
setTableProps(state, action) {
state.tableProps = action.payload
},
+ removeTopicFromStore(state, action) {
+ const { metalake, catalog, catalogType, schema, topic } = action.payload
+ const schemaKey =
`{{${metalake}}}{{${catalog}}}{{${catalogType}}}{{${schema}}}`
+ const topicKey =
`{{${metalake}}}{{${catalog}}}{{${catalogType}}}{{${schema}}}{{${topic}}}`
Review Comment:
`removeTopicFromStore` builds `schemaKey`/`topicKey` using `catalogType`
from the action payload, but `deleteTopic` is invoked from the UI without
`catalogType` (e.g. SchemaDetailsPage dispatches `deleteTopic({ metalake,
catalog, schema, topic })`). Also, topic tree keys in this slice are generated
with the hardcoded type `'messaging'` (see `fetchTopics`). If `catalogType` is
missing or differs, the reducer won’t remove the topic from `selectedNodes` /
`metalakeTree` because the computed keys won’t match. Consider defaulting
`catalogType` to `'messaging'` for topic deletions (in the thunk before
dispatching `removeTopicFromStore`, or inside the reducer when computing keys),
so the keys are consistent with `fetchTopics`/tree loading.
```suggestion
const effectiveCatalogType = catalogType || 'messaging'
const schemaKey =
`{{${metalake}}}{{${catalog}}}{{${effectiveCatalogType}}}{{${schema}}}`
const topicKey =
`{{${metalake}}}{{${catalog}}}{{${effectiveCatalogType}}}{{${schema}}}{{${topic}}}`
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]