Skip to content

[codex] Add locality relation entry history#1194

Merged
karilint merged 1 commit into
mainfrom
codex/1191-entry-history-locality-relations
Jun 3, 2026
Merged

[codex] Add locality relation entry history#1194
karilint merged 1 commit into
mainfrom
codex/1191-entry-history-locality-relations

Conversation

@karilint
Copy link
Copy Markdown
Collaborator

@karilint karilint commented Jun 3, 2026

Summary

  • Reuse the existing update-history popover for relation/list row history.
  • Add a read-mode row action slot to editable detail tables.
  • Show entry history for locality sedimentary structure, collecting method, synonym, museum, and project relation rows.
  • Show entry history for species synonym rows.
  • Match relation entries by pk_data when available so the popover can show all update rows for the entry, not only the identifier column.
  • Add focused frontend tests for entry-history matching and row-click propagation.

Root Cause / Context

Locality and species relation rows already have update log data in their detail update containers, but read-mode relation tables had no row-level affordance for surfacing entry add/remove/update logs. Field-level history from #1183 did not cover relation/list entries.

Occurrence rows (now_ls) are intentionally left for the separate occurrence-history work because they need richer locality/species update matching than these direct relation rows.

Validation

  • cd frontend && npm test -- --runTestsByPath src/tests/components/DetailView/FieldUpdateHistory.test.tsx --runInBand
  • npm run lint:frontend
  • npm run tsc:frontend
  • Commit hook also ran root npm run lint and root npm run tsc successfully after the expanded scope.

Closes #1191

@karilint karilint force-pushed the codex/1191-entry-history-locality-relations branch from 4c8ec49 to e9e8722 Compare June 3, 2026 12:53
@karilint karilint marked this pull request as ready for review June 3, 2026 13:07
@karilint karilint requested a review from Copilot June 3, 2026 13:07
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extends the existing field-level update history UI to support entry-level history for relation/list rows (e.g., locality sedimentary structure, collecting method, museum/project links, locality synonyms, and species synonyms) by reusing the existing popover pattern and adding a read-mode row actions slot to detail tables.

Changes:

  • Refactors FieldUpdateHistory into a reusable popover and adds EntryUpdateHistory that can match relation-entry update logs (including pk_data matching).
  • Adds renderReadRowActions support to EditableTable so read-mode tables can show per-row actions (history icon, etc.).
  • Integrates entry-history actions into multiple Locality and Species relation tabs and adds targeted frontend tests for matching and click propagation.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
frontend/src/components/DetailView/common/FieldUpdateHistory.tsx Refactors history popover and adds entry-level history matching (including pk_data support).
frontend/src/components/DetailView/common/EditableTable.tsx Adds a read-mode row action slot and ensures row actions can coexist with row navigation.
frontend/src/components/Locality/Tabs/LithologyTab.tsx Adds entry-history row action for sedimentary structure rows.
frontend/src/components/Locality/Tabs/TaphonomyTab.tsx Adds entry-history row action for collecting method rows.
frontend/src/components/Locality/Tabs/MuseumTab.tsx Adds entry-history row action for museum relation rows.
frontend/src/components/Locality/Tabs/ProjectTab.tsx Adds entry-history row action for project relation rows.
frontend/src/components/Locality/Tabs/LocalityTab.tsx Adds entry-history row action for locality synonym rows.
frontend/src/components/Species/Tabs/SynonymTab.tsx Adds entry-history row action for species synonym rows.
frontend/src/tests/components/DetailView/FieldUpdateHistory.test.tsx Adds focused tests for entry-history matching and row-click propagation behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +90 to +104
const encodedPkSegment = getEncodedPkSegment(rowValue)

return collectUpdateContainers(data).flatMap(container =>
container.updates
.filter(log => {
if (log.table_name !== tableName) return false

const pkData = getPkData(log)
const pkDataMatches = encodedPkSegment && typeof pkData === 'string' ? pkData.includes(encodedPkSegment) : false
if (pkDataMatches) return true

if (columnName && log.column_name !== columnName) return false

return valuesMatch(log.new_data, rowValue) || valuesMatch(log.old_data, rowValue)
})
Comment on lines +298 to +306
return (
<UpdateHistoryPopover
idPrefix={[tableName, columnName, formatValue(rowValue)].filter(Boolean).join('-')}
title={`${label} entry history`}
tooltip={`Show entry history for ${label}`}
ariaLabel={`Show entry history for ${label}`}
updates={updates}
onOpen={handleOpen}
/>
Comment on lines 31 to +34
isObject(value) && 'column_name' in value && 'log_action' in value

const getPkData = (log: UpdateLog) => (log as unknown as { pk_data?: unknown }).pk_data

Comment on lines 134 to 141
const restrictionIndicator = ({ row }: { row: MRT_Row<T> }) => {
if (!checkRowRestriction || !checkRowRestriction(row.original)) return null

return (
<Tooltip placement="top" title="This item has restricted visibility">
<PolicyIcon aria-label="Restricted visibility indicator" color="primary" fontSize="medium" />
</Tooltip>
)
@karilint karilint force-pushed the codex/1191-entry-history-locality-relations branch from e9e8722 to 146aeeb Compare June 3, 2026 14:26
Copy link
Copy Markdown
Collaborator Author

karilint commented Jun 3, 2026

Addressed Copilot's feedback in 146aeeb5:

  • Entry history matching now accepts composite pk values and requires all encoded pk_data segments to match when pk_data is present, preventing same-value matches in a different primary-key component.
  • Popover IDs now sanitize row values before using them in aria-describedby.
  • getPkData uses an intersection type instead of a double assertion.
  • The restricted-visibility icon now stops click propagation, matching the entry-history icon behavior.

Validation rerun:

  • cd frontend && npm test -- --runTestsByPath src/tests/components/DetailView/FieldUpdateHistory.test.tsx --runInBand
  • npm run lint:frontend
  • npm run tsc:frontend
  • amend hook passed root npm run lint and root npm run tsc.

@karilint karilint merged commit 214ead7 into main Jun 3, 2026
4 checks passed
@karilint karilint deleted the codex/1191-entry-history-locality-relations branch June 3, 2026 14:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Entry history for locality relation list items

2 participants