Skip to content

Commit 1654bc6

Browse files
committed
fix(web): display user-friendly provenance labels in Graph list
Convert technical serialized format (provenance:user|label:...) to human-readable labels (Added manually, Loaded from collection, etc.) in the Catalogue entities notes column.
1 parent 36296b8 commit 1654bc6

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed

apps/web/src/components/catalogue/CatalogueEntities.tsx

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,36 @@ const formatEntityMetadata = (entity: CatalogueEntity): string => {
192192
return 'No metadata';
193193
};
194194

195+
/**
196+
* Provenance labels for graph list entries
197+
* Maps technical provenance values to user-friendly descriptions
198+
*/
199+
const PROVENANCE_LABELS: Record<string, string> = {
200+
user: "Added manually",
201+
"collection-load": "Loaded from collection",
202+
expansion: "Discovered via expansion",
203+
"auto-population": "Auto-populated",
204+
};
205+
206+
/**
207+
* Formats notes field for user-friendly display
208+
* Handles graph list serialized format: "provenance:TYPE|label:LABEL"
209+
* @param notes - Raw notes string from entity
210+
* @returns User-friendly display string
211+
*/
212+
const formatNotesForDisplay = (notes: string | undefined): string => {
213+
if (!notes) return "No notes";
214+
215+
// Check for graph list serialized format: "provenance:TYPE|label:LABEL"
216+
const provenanceMatch = notes.match(/^provenance:([^|]+)(?:\|label:.+)?$/);
217+
if (provenanceMatch) {
218+
const [, provenanceType] = provenanceMatch;
219+
return PROVENANCE_LABELS[provenanceType] || provenanceType;
220+
}
221+
222+
return notes;
223+
};
224+
195225
const SortableEntityRow = ({
196226
entity,
197227
onNavigate,
@@ -289,7 +319,7 @@ const SortableEntityRow = ({
289319
) : (
290320
<Group gap="sm">
291321
<Text size="sm" c="dimmed" style={{ flex: 1 }}>
292-
{entity.notes || "No notes"}
322+
{formatNotesForDisplay(entity.notes)}
293323
</Text>
294324
<ActionIcon
295325
size="sm"

0 commit comments

Comments
 (0)