Conversation
|
@claude Review this PR |
|
Claude finished @weeco's task in 2m 30s —— View job PR Review: Remove topics from backend-api
Good overall direction — migrating topic-related API calls from the MobX-based Bugs1.
const hasEditPermissions = true;This unconditionally allows the edit button for every user, removing the ACL-based permission check. The old code presumably checked 2. Missing
Several query functions don't check Affected hooks:
Example fix: const response = await config.fetch(`${config.restBasePath}/topics`, { method: 'GET', headers });
if (!response.ok) throw new Error(`Failed to fetch topics: ${response.statusText}`);
return response.json();Code quality3. Duplicated auth header boilerplate
The JWT auth header block is copy-pasted ~10 times: const headers: HeadersInit = {};
if (config.jwt) {
headers.Authorization = `Bearer ${config.jwt}`;
}Since this is used everywhere in this file, extracting a function createAuthHeaders(extraHeaders?: HeadersInit): HeadersInit {
const headers: HeadersInit = { ...extraHeaders };
if (config.jwt) headers.Authorization = `Bearer ${config.jwt}`;
return headers;
}4.
The hook uses If the intent is to share invalidation with the Connect-based 5. Cache isolation between
Both hooks hit the same |
|
I need to double check how we fetch permissions still, related to some work I've done on Friday |
| api.refreshPartitions('all', true).catch(() => { | ||
| // Error handling managed by API layer | ||
| }); | ||
| queryClient.invalidateQueries({ queryKey: ['topicPartitionsAll'] }); |
There was a problem hiding this comment.
You can rely on a useQueryClient hook to grab the singleton instance too.
| } | ||
|
|
||
| async refreshData(force: boolean): Promise<void> { | ||
| async refreshData(_force: boolean): Promise<void> { |
There was a problem hiding this comment.
If we don't use the _force, should we drop it
| topicConfigData === undefined | ||
| ? undefined | ||
| : topicConfigData === null || topicConfigData.error !== null | ||
| ? null | ||
| : topicConfigData.configEntries; |
There was a problem hiding this comment.
Can we avoid nested ternaries? I know this was there before but maybe an easy opportunity to clean up
| queryClient.getQueryData<Map<string, import('../../../state/rest-interfaces').Partition[] | null>>([ | ||
| 'topicPartitionsAll', | ||
| ]) ?? new Map<string, import('../../../state/rest-interfaces').Partition[] | null>(); |
There was a problem hiding this comment.
Why do we need this type of dynamic import? I would just import it, I guess react doctor might complain about it being a barrel file of some sort? I think in this case it would make it worse to have this import everywhere, just hoist it to the top of the file.
|
@claude review again |
|
Claude finished @malinskibeniamin's task in 2m 15s —— View job PR Review: Remove topics from backend-api
Good progress since the last review — the Open inline comments (from @malinskibeniamin, 2026-03-31)1. Use The component imports and uses the import queryClient from '../../../query-client';
// ...
useEffect(() => {
queryClient.invalidateQueries({ queryKey: ['topicPartitionsAll'] });
}, []);Since this is a functional component, the hook is available. Prefer 2. Drop unused async refreshData(_force: boolean): Promise<void> {The parameter is never read (underscore is just suppressing the lint warning). The body comment makes it clear topics are now handled by React Query in children. Drop the parameter and update the two call sites at lines 553 and 555. 3. Nested ternaries in const topicConfig: ConfigEntry[] | null | undefined =
topicConfigData === undefined
? undefined
: topicConfigData === null || topicConfigData.error !== null
? null
: topicConfigData.configEntries;Could be an let topicConfig: ConfigEntry[] | null | undefined;
if (topicConfigData === undefined) {
topicConfig = undefined;
} else if (topicConfigData === null || topicConfigData.error !== null) {
topicConfig = null;
} else {
topicConfig = topicConfigData.configEntries;
}4. Inline dynamic imports in
queryClient.getQueryData<import('../../../state/rest-interfaces').GetTopicsResponse>(['topics'])
// ...
queryClient.getQueryData<Map<string, import('../../../state/rest-interfaces').Partition[] | null>>([...])
Remaining items from previous review5. Missing
Compare: 6. Not blockingItems 1–4 are all small, clean-up style changes that address @malinskibeniamin's review comments. Items 5–6 are pre-existing (carried over from the last review). |
No description provided.