Add field update history popover#1190
Conversation
|
@copilot Please review this pull request. |
Here is my review of the PR: Code Review: Add field update history popover✅ What works well
🔴 Issues to address1.
// Current – fallback never runs
const SafeDetailContext =
(DetailContext as unknown as Context<DetailContextType<Record<string, unknown>> | null> | undefined) ??
createContext<DetailContextType<Record<string, unknown>> | null>(null)
// Simpler and equivalent
const SafeDetailContext = DetailContext as unknown as Context<DetailContextType<Record<string, unknown>> | null>2. const isUpdateLog = (value: unknown): value is UpdateLog =>
isObject(value) && ('column_name' in value || 'old_data' in value || 'new_data' in value || 'log_action' in value)Any object with a property called const isUpdateLog = (value: unknown): value is UpdateLog =>
isObject(value) && 'column_name' in value && 'log_action' in value3. Non-unique key={`${log.log_id ?? index}-${log.column_name ?? field}`}When two different key={`${index}-${log.log_id ?? ''}-${log.column_name ?? field}`}🟡 Suggestions (non-blocking)4. No chronological ordering of updates Updates are displayed in traversal order rather than by date. Showing the most-recent update first (sort descending by 5. References repeat when multiple updates share a container Each update card calls 6. Both are 7. Test coverage gaps The existing tests are a good start. Consider adding:
|
Refs #1183
Summary
Validation
cd frontend && npx jest src/tests/components/DetailView/FieldUpdateHistory.test.tsx src/tests/components/SpeciesTaxonomyTab.test.tsx --runInBandcd frontend && npx tsc --noEmitnpm run lint:frontendnpm run lintandnpm run tsc