refactor(frontend): one entry-type taxonomy (#534) #641
Loading…
Reference in a new issue
No description provided.
Delete branch "refactor/534-entry-type-taxonomy"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The wiki's 13 entry types lived in separate copies across the frontend. Adding a fourteenth, or renaming one, meant finding every copy, and missing one left a type unlabelled or uncoloured on a single screen.
What was consolidated
#534 counted four copies. There were more:
WikiArticle,CampaignStoryline,WikiProposals,WikiNewEntry(TYPE_LABELS),CampaignDetail(LORE_TYPE_LABELS){value, label}option listWorkbenchResultActions(LORE_TYPE_OPTIONS)LorePickerWikiArticle,WikiProposals,CampaignDetailLORE_TYPESEach group was compared and found identical in content and order. They're all now in
src/entryTypes.js, a sibling ofvocabulary.js, which exportsENTRY_TYPE_LABELS,ENTRY_TYPE_PLURAL_LABELS,ENTRY_TYPE_COLOURSandENTRY_TYPES.Behaviour-preserving by design
Call sites import with aliases (
ENTRY_TYPE_LABELS as TYPE_LABELS), so every usage line and every?? typefallback is untouched. No label text, colour class or option order changes. Tailwind's content glob (./src/**/*.{js,jsx,ts,tsx}) covers the new.jsfile, so the colour classes still reach the production CSS.Test
entryTypes.test.jsasserts that the singular, plural and colour maps share one key set, in one order. That's the invariant that stops a future type from being added to one map and not the others.On review I removed two things from the first commit:
entryTypeLabel()helper with no call siteENTRY_TYPESassertion that could not fail, sinceENTRY_TYPESisObject.keys(ENTRY_TYPE_LABELS)(#441's pattern)Verification
Full frontend suite 67 files / 870 tests passed,
eslint srcclean.No CHANGELOG entry: nothing user-visible changes.
Refs #534 (one of five items; the issue stays open). This PR touches no files that #640 does.
🤖 Generated with Claude Code
Consolidate the wiki entry-type label maps that were copy-pasted, character-identical, across WikiArticle, CampaignStoryline, WikiProposals, WikiNewEntry (TYPE_LABELS) and CampaignDetail (LORE_TYPE_LABELS), plus the plural variant in LorePicker (ENTRY_TYPE_LABELS) and the colour maps duplicated in WikiArticle, WikiProposals and CampaignDetail (all three identical), into a new webapp/frontend/src/entryTypes.js, sibling to vocabulary.js. Also folded in the four duplicate LORE_TYPES key-list arrays and a {value,label} option list in WorkbenchResultActions that encoded the same 13 types. Behaviour, label text, colour classes, and rendered order are unchanged; call sites now import from entryTypes.js instead of declaring their own copy. Added entryTypes.test.js to assert the label/plural/colour maps share one key set in one order, so a future entry type can't be added to one map and missed in another. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>