Skip to content

Commit 6544179

Browse files
committed
feat(web): add entity type badges to History page entries
Display colored badges (Author, Work, Institution, etc.) on history entries for quick visual identification, consistent with BookmarkListItem.
1 parent 433bf81 commit 6544179

File tree

1 file changed

+37
-7
lines changed

1 file changed

+37
-7
lines changed

apps/web/src/components/HistoryManager.tsx

Lines changed: 37 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { logError, logger } from "@bibgraph/utils/logger";
88
import { type CatalogueEntity,catalogueService } from "@bibgraph/utils/storage/catalogue-db";
99
import {
1010
ActionIcon,
11+
Badge,
1112
Button,
1213
Card,
1314
Divider,
@@ -37,6 +38,26 @@ import { useUserInteractions } from "@/hooks/use-user-interactions";
3738
/** Non-entity pages that shouldn't trigger display name fetches */
3839
const NON_ENTITY_URL_PATTERNS = ["/about", "/settings", "/history", "/bookmarks", "/catalogue"];
3940

41+
/** Color mapping for entity type badges - consistent with BookmarkListItem */
42+
const ENTITY_TYPE_COLORS: Record<string, string> = {
43+
works: "blue",
44+
authors: "green",
45+
sources: "orange",
46+
institutions: "purple",
47+
topics: "pink",
48+
concepts: "cyan",
49+
publishers: "grape",
50+
funders: "yellow",
51+
keywords: "teal",
52+
domains: "indigo",
53+
fields: "lime",
54+
subfields: "violet",
55+
};
56+
57+
const getEntityTypeColor = (entityType: string): string => {
58+
return ENTITY_TYPE_COLORS[entityType] || "gray";
59+
};
60+
4061
/**
4162
* Sub-component for rendering a single history entry with display name resolution
4263
*/
@@ -111,13 +132,22 @@ const HistoryEntryCard = ({ entry, onNavigate, onDelete, formatDate }: HistoryEn
111132
>
112133
<Group justify="space-between" align="flex-start">
113134
<Stack gap="xs" style={{ flex: 1 }}>
114-
{isLoading && !titleFromNotes ? (
115-
<Skeleton height={16} width="60%" />
116-
) : (
117-
<Text size="sm" fw={500}>
118-
{title}
119-
</Text>
120-
)}
135+
<Group gap="xs" wrap="nowrap">
136+
<Badge
137+
size="xs"
138+
color={getEntityTypeColor(entry.entityType)}
139+
variant="light"
140+
>
141+
{formatEntityType(entry.entityType)}
142+
</Badge>
143+
{isLoading && !titleFromNotes ? (
144+
<Skeleton height={16} width="60%" />
145+
) : (
146+
<Text size="sm" fw={500} lineClamp={1}>
147+
{title}
148+
</Text>
149+
)}
150+
</Group>
121151
{entry.notes && (
122152
<Text size="xs" c="dimmed" lineClamp={2}>
123153
{entry.notes.split('\n').filter(line => !line.startsWith('URL:') && !line.startsWith('Title:')).join('\n')}

0 commit comments

Comments
 (0)