From b3013647b9cb0833a911ba94aa549270fbb46a9d Mon Sep 17 00:00:00 2001 From: EthanHealy01 Date: Wed, 13 Aug 2025 15:18:33 +0100 Subject: [PATCH] update tool registry to order them as they appear in the nav bar --- frontend/src/data/toolRegistry.tsx | 682 +++++++++++++++++------------ 1 file changed, 394 insertions(+), 288 deletions(-) diff --git a/frontend/src/data/toolRegistry.tsx b/frontend/src/data/toolRegistry.tsx index 9a5582ece..adacc5c45 100644 --- a/frontend/src/data/toolRegistry.tsx +++ b/frontend/src/data/toolRegistry.tsx @@ -29,6 +29,7 @@ export type ToolRegistry = { * Quick reference helpers are provided below for convenience. */ // Ordered list used elsewhere for display ordering +// Subcategory display order (top to bottom, left to right) export const SUBCATEGORY_ORDER: string[] = [ 'Signing', 'Document Security', @@ -38,39 +39,101 @@ export const SUBCATEGORY_ORDER: string[] = [ 'Extraction', 'Removal', 'Automation', - 'General', // for now, this is the same as quick access, until we add suggested tools & favorites & whatnot + 'General', 'Advanced Formatting', 'Developer Tools', ]; +// Color coding for subcategories (loosely resembling the v1 color palette) +export const SUBCATEGORY_COLOR_MAP: Record = { + // Security & Signing (pink) + 'Signing': '#FF7892', + 'Document Security': '#FF7892', + // Review / Verification (blue-green) + 'Verification': '#1BB1D4', + 'Document Review': '#48BD54', + // Organize / Page operations (purple/organize + blue accents) + 'Page Formatting': '#7882FF', + 'Removal': '#7882FF', + 'Extraction': '#1BB1D4', + // Automation / General quick actions (green) + 'Automation': '#69DC95', + 'General': '#69DC95', + // Advanced buckets (red family) + 'Advanced Formatting': '#F55454', + 'Developer Tools': '#F55454', +}; + +export const getSubcategoryColor = (subcategory?: string | null): string => { + if (!subcategory) return '#7882FF'; + return SUBCATEGORY_COLOR_MAP[subcategory] || '#7882FF'; +}; + +// Grouped structure by subcategory (ordered by SUBCATEGORY_ORDER) +export type SubcategoryGroup = { + name: string; + color: string; + tools: (ToolRegistryEntry & { id: string })[]; +}; + +export const getAllToolsBySubcategoryOrdered = (): SubcategoryGroup[] => { + const entries: Array<[string, ToolRegistryEntry]> = Object.entries(flatToolRegistryMap); + const grouping: Record = {}; + for (const [id, tool] of entries) { + const sub = tool.subcategory ?? 'General'; + if (!grouping[sub]) { + grouping[sub] = { + name: sub, + color: getSubcategoryColor(sub), + tools: [], + }; + } + grouping[sub].tools.push({ id, ...tool }); + } + // Order tools within each subcategory alphabetically by name (display key) + Object.values(grouping).forEach(group => { + group.tools.sort((a, b) => a.name.localeCompare(b.name)); + }); + // Return groups ordered by SUBCATEGORY_ORDER + const ordered: SubcategoryGroup[] = []; + SUBCATEGORY_ORDER.forEach(sub => { + if (grouping[sub]) ordered.push(grouping[sub]); + }); + // Append any subcategories not explicitly listed + Object.keys(grouping) + .filter(name => !SUBCATEGORY_ORDER.includes(name)) + .sort((a, b) => a.localeCompare(b)) + .forEach(name => ordered.push(grouping[name])); + return ordered; +}; + export const flatToolRegistryMap: ToolRegistry = { - "add-attachments": { - icon: attachment, - name: "home.attachments.title", + + + // Signing + + "certSign": { + icon: workspace_premium, + name: "home.certSign.title", component: null, - view: "format", - description: "home.attachments.desc", + view: "sign", + description: "home.certSign.desc", category: "Standard Tools", - subcategory: "Page Formatting", + subcategory: "Signing" }, - "add-image": { - icon: image, - name: "home.addImage.title", + "sign": { + icon: signature, + name: "home.sign.title", component: null, - view: "format", - description: "home.addImage.desc", - category: "Advanced Tools", - subcategory: "Advanced Formatting" - }, - "add-page-numbers": { - icon: 123, - name: "home.add-page-numbers.title", - component: null, - view: "format", - description: "home.add-page-numbers.desc", + view: "sign", + description: "home.sign.desc", category: "Standard Tools", - subcategory: "Page Formatting" + subcategory: "Signing" }, + + + // Document Security + "add-password": { icon: password, name: "home.addPassword.title", @@ -80,15 +143,6 @@ export const flatToolRegistryMap: ToolRegistry = { category: "Standard Tools", subcategory: "Document Security" }, - "add-stamp": { - icon: approval, - name: "home.AddStampRequest.title", - component: null, - view: "format", - description: "home.AddStampRequest.desc", - category: "Standard Tools", - subcategory: "Document Security" - }, "add-watermark": { icon: branding_watermark, name: "home.watermark.title", @@ -98,68 +152,85 @@ export const flatToolRegistryMap: ToolRegistry = { category: "Standard Tools", subcategory: "Document Security" }, - "adjust-colors-contrast": { - icon: palette, - name: "home.adjust-contrast.title", + "add-stamp": { + icon: approval, + name: "home.AddStampRequest.title", component: null, view: "format", - description: "home.adjust-contrast.desc", - category: "Advanced Tools", - subcategory: "Advanced Formatting" - }, - "adjust-page-size-scale": { - icon: crop_free, - name: "home.scalePages.title", - component: null, - view: "format", - description: "home.scalePages.desc", + description: "home.AddStampRequest.desc", category: "Standard Tools", - subcategory: "Page Formatting" + subcategory: "Document Security" }, - "auto-rename-pdf-file": { - icon: match_word, - name: "home.auto-rename.title", + "sanitize": { + icon: sanitizer, + name: "home.sanitizePdf.title", component: null, - view: "format", - description: "home.auto-rename.desc", - category: "Advanced Tools", - subcategory: "Automation" - }, - "auto-split-by-size-count": { - icon: content_cut, - name: "home.autoSizeSplitPDF.title", - component: null, - view: "format", - description: "home.autoSizeSplitPDF.desc", - category: "Advanced Tools", - subcategory: "Automation" - }, - "auto-split-pages": { - icon: split_scene_right, - name: "home.autoSplitPDF.title", - component: null, - view: "format", - description: "home.autoSplitPDF.desc", - category: "Advanced Tools", - subcategory: "Automation" - }, - "automate": { - icon: automation, - name: "home.automate.title", - component: null, - view: "format", - description: "home.automate.desc", - category: "Advanced Tools", - subcategory: "Automation" - }, - "certSign": { - icon: workspace_premium, - name: "home.certSign.title", - component: null, - view: "sign", - description: "home.certSign.desc", + view: "security", + description: "home.sanitizePdf.desc", category: "Standard Tools", - subcategory: "Signing" + subcategory: "Document Security" + }, + "flatten": { + icon: layers_clear, + name: "home.flatten.title", + component: null, + view: "format", + description: "home.flatten.desc", + category: "Standard Tools", + subcategory: "Document Security" + }, + "unlock-pdf-forms": { + icon: preview_off, + name: "home.unlockPDFForms.title", + component: null, + view: "security", + description: "home.unlockPDFForms.desc", + category: "Standard Tools", + subcategory: "Document Security" + }, + "manage-certificates": { + icon: license, + name: "home.manageCertificates.title", + component: null, + view: "security", + description: "home.manageCertificates.desc", + category: "Standard Tools", + subcategory: "Document Security" + }, + + + // Verification + + "get-all-info-on-pdf": { + icon: fact_check, + name: "home.getPdfInfo.title", + component: null, + view: "extract", + description: "home.getPdfInfo.desc", + category: "Standard Tools", + subcategory: "Verification" + }, + "validate-pdf-signature": { + icon: verified, + name: "home.validateSignature.title", + component: null, + view: "security", + description: "home.validateSignature.desc", + category: "Standard Tools", + subcategory: "Verification" + }, + + + // Document Review + + "read": { + icon: article, + name: "home.read.title", + component: null, + view: "view", + description: "home.read.desc", + category: "Standard Tools", + subcategory: "Document Review" }, "change-metadata": { icon: assignment, @@ -179,33 +250,10 @@ export const flatToolRegistryMap: ToolRegistry = { category: "Standard Tools", subcategory: "Document Review" }, - "compare": { - icon: compare, - name: "home.compare.title", - component: null, - view: "format", - description: "home.compare.desc", - category: "Recommended Tools", - subcategory: null - }, - "compressPdfs": { - icon: zoom_in_map, - name: "home.compressPdfs.title", - component: CompressPdfPanel, - view: "compress", - description: "home.compressPdfs.desc", - category: "Recommended Tools", - subcategory: null - }, - "convert": { - icon: sync_alt, - name: "home.fileToPDF.title", - component: ConvertPanel, - view: "convert", - description: "home.fileToPDF.desc", - category: "Recommended Tools", - subcategory: null - }, + + + // Page Formatting + "cropPdf": { icon: crop, name: "home.crop.title", @@ -215,77 +263,50 @@ export const flatToolRegistryMap: ToolRegistry = { category: "Standard Tools", subcategory: "Page Formatting" }, - "detect-split-scanned-photos": { - icon: scanner, - name: "home.ScannerImageSplit.title", + "rotate": { + icon: rotate_right, + name: "home.rotate.title", component: null, view: "format", - description: "home.ScannerImageSplit.desc", - category: "Advanced Tools", - subcategory: "Advanced Formatting" + description: "home.rotate.desc", + category: "Standard Tools", + subcategory: "Page Formatting" }, - "edit-table-of-contents": { - icon: bookmark_add, - name: "home.editTableOfContents.title", + "splitPdf": { + icon: content_cut, + name: "home.split.title", + component: SplitPdfPanel, + view: "split", + description: "home.split.desc", + category: "Standard Tools", + subcategory: "Page Formatting" + }, + "reorganize-pages": { + icon: move_down, + name: "home.reorganizePages.title", + component: null, + view: "pageEditor", + description: "home.reorganizePages.desc", + category: "Standard Tools", + subcategory: "Page Formatting" + }, + "adjust-page-size-scale": { + icon: crop_free, + name: "home.scalePages.title", component: null, view: "format", - description: "home.editTableOfContents.desc", - category: "Advanced Tools", - subcategory: "Advanced Formatting" - }, - "extract-images": { - icon: filter, - name: "home.extractImages.title", - component: null, - view: "extract", - description: "home.extractImages.desc", + description: "home.scalePages.desc", category: "Standard Tools", - subcategory: "Extraction" + subcategory: "Page Formatting" }, - "extract-pages": { - icon: upload, - name: "home.extractPage.title", - component: null, - view: "extract", - description: "home.extractPage.desc", - category: "Standard Tools", - subcategory: "Extraction" - }, - "flatten": { - icon: layers_clear, - name: "home.flatten.title", + "add-page-numbers": { + icon: 123, + name: "home.add-page-numbers.title", component: null, view: "format", - description: "home.flatten.desc", + description: "home.add-page-numbers.desc", category: "Standard Tools", - subcategory: "Document Security" - }, - "get-all-info-on-pdf": { - icon: fact_check, - name: "home.getPdfInfo.title", - component: null, - view: "extract", - description: "home.getPdfInfo.desc", - category: "Standard Tools", - subcategory: "Verification" - }, - "manage-certificates": { - icon: license, - name: "home.manageCertificates.title", - component: null, - view: "security", - description: "home.manageCertificates.desc", - category: "Standard Tools", - subcategory: "Document Security" - }, - "mergePdfs": { - icon: library_add, - name: "home.merge.title", - component: null, - view: "merge", - description: "home.merge.desc", - category: "Recommended Tools", - subcategory: null + subcategory: "Page Formatting" }, "multi-page-layout": { icon: dashboard, @@ -296,51 +317,50 @@ export const flatToolRegistryMap: ToolRegistry = { category: "Standard Tools", subcategory: "Page Formatting" }, - "multi-tool": { - icon: dashboard_customize, - name: "home.multiTool.title", - component: null, - view: "pageEditor", - description: "home.multiTool.desc", - category: "Recommended Tools", - subcategory: null - }, - "ocr": { - icon: quick_reference_all, - name: "home.ocr.title", - component: OCRPanel, - view: "convert", - description: "home.ocr.desc", - category: "Recommended Tools", - subcategory: null - }, - "overlay-pdfs": { - icon: layers, - name: "home.overlay-pdfs.title", + "single-large-page": { + icon: looks_one, + name: "home.PdfToSinglePage.title", component: null, view: "format", - description: "home.overlay-pdfs.desc", - category: "Advanced Tools", - subcategory: "Advanced Formatting" - }, - "read": { - icon: article, - name: "home.read.title", - component: null, - view: "view", - description: "home.read.desc", + description: "home.PdfToSinglePage.desc", category: "Standard Tools", - subcategory: "Document Review" + subcategory: "Page Formatting" }, - "redact": { - icon: visibility_off, - name: "home.redact.title", + "add-attachments": { + icon: attachment, + name: "home.attachments.title", component: null, - view: "redact", - description: "home.redact.desc", - category: "Recommended Tools", - subcategory: null + view: "format", + description: "home.attachments.desc", + category: "Standard Tools", + subcategory: "Page Formatting", }, + + + // Extraction + + "extract-pages": { + icon: upload, + name: "home.extractPage.title", + component: null, + view: "extract", + description: "home.extractPage.desc", + category: "Standard Tools", + subcategory: "Extraction" + }, + "extract-images": { + icon: filter, + name: "home.extractImages.title", + component: null, + view: "extract", + description: "home.extractImages.desc", + category: "Standard Tools", + subcategory: "Extraction" + }, + + + // Removal + "remove": { icon: delete, name: "home.removePages.title", @@ -350,15 +370,6 @@ export const flatToolRegistryMap: ToolRegistry = { category: "Standard Tools", subcategory: "Removal" }, - "remove-annotations": { - icon: thread_unread, - name: "home.removeAnnotations.title", - component: null, - view: "remove", - description: "home.removeAnnotations.desc", - category: "Standard Tools", - subcategory: "Removal" - }, "remove-blank-pages": { icon: scan_delete, name: "home.removeBlanks.title", @@ -368,12 +379,12 @@ export const flatToolRegistryMap: ToolRegistry = { category: "Standard Tools", subcategory: "Removal" }, - "remove-certificate-sign": { - icon: remove_moderator, - name: "home.removeCertSign.title", + "remove-annotations": { + icon: thread_unread, + name: "home.removeAnnotations.title", component: null, - view: "security", - description: "home.removeCertSign.desc", + view: "remove", + description: "home.removeAnnotations.desc", category: "Standard Tools", subcategory: "Removal" }, @@ -395,6 +406,68 @@ export const flatToolRegistryMap: ToolRegistry = { category: "Standard Tools", subcategory: "Removal" }, + "remove-certificate-sign": { + icon: remove_moderator, + name: "home.removeCertSign.title", + component: null, + view: "security", + description: "home.removeCertSign.desc", + category: "Standard Tools", + subcategory: "Removal" + }, + + + // Automation + + "automate": { + icon: automation, + name: "home.automate.title", + component: null, + view: "format", + description: "home.automate.desc", + category: "Advanced Tools", + subcategory: "Automation" + }, + "auto-rename-pdf-file": { + icon: match_word, + name: "home.auto-rename.title", + component: null, + view: "format", + description: "home.auto-rename.desc", + category: "Advanced Tools", + subcategory: "Automation" + }, + "auto-split-pages": { + icon: split_scene_right, + name: "home.autoSplitPDF.title", + component: null, + view: "format", + description: "home.autoSplitPDF.desc", + category: "Advanced Tools", + subcategory: "Automation" + }, + "auto-split-by-size-count": { + icon: content_cut, + name: "home.autoSizeSplitPDF.title", + component: null, + view: "format", + description: "home.autoSizeSplitPDF.desc", + category: "Advanced Tools", + subcategory: "Automation" + }, + + + // Advanced Formatting + + "adjust-colors-contrast": { + icon: palette, + name: "home.adjust-contrast.title", + component: null, + view: "format", + description: "home.adjust-contrast.desc", + category: "Advanced Tools", + subcategory: "Advanced Formatting" + }, "repair": { icon: build, name: "home.repair.title", @@ -404,6 +477,24 @@ export const flatToolRegistryMap: ToolRegistry = { category: "Advanced Tools", subcategory: "Advanced Formatting" }, + "detect-split-scanned-photos": { + icon: scanner, + name: "home.ScannerImageSplit.title", + component: null, + view: "format", + description: "home.ScannerImageSplit.desc", + category: "Advanced Tools", + subcategory: "Advanced Formatting" + }, + "overlay-pdfs": { + icon: layers, + name: "home.overlay-pdfs.title", + component: null, + view: "format", + description: "home.overlay-pdfs.desc", + category: "Advanced Tools", + subcategory: "Advanced Formatting" + }, "replace-and-invert-color": { icon: format_color_fill, name: "home.replaceColorPdf.title", @@ -413,32 +504,23 @@ export const flatToolRegistryMap: ToolRegistry = { category: "Advanced Tools", subcategory: "Advanced Formatting" }, - "reorganize-pages": { - icon: move_down, - name: "home.reorganizePages.title", - component: null, - view: "pageEditor", - description: "home.reorganizePages.desc", - category: "Standard Tools", - subcategory: "Page Formatting" - }, - "rotate": { - icon: rotate_right, - name: "home.rotate.title", + "add-image": { + icon: image, + name: "home.addImage.title", component: null, view: "format", - description: "home.rotate.desc", - category: "Standard Tools", - subcategory: "Page Formatting" + description: "home.addImage.desc", + category: "Advanced Tools", + subcategory: "Advanced Formatting" }, - "sanitize": { - icon: sanitizer, - name: "home.sanitizePdf.title", + "edit-table-of-contents": { + icon: bookmark_add, + name: "home.editTableOfContents.title", component: null, - view: "security", - description: "home.sanitizePdf.desc", - category: "Standard Tools", - subcategory: "Document Security" + view: "format", + description: "home.editTableOfContents.desc", + category: "Advanced Tools", + subcategory: "Advanced Formatting" }, "scanner-effect": { icon: scanner, @@ -449,6 +531,10 @@ export const flatToolRegistryMap: ToolRegistry = { category: "Advanced Tools", subcategory: "Advanced Formatting" }, + + + // Developer Tools + "show-javascript": { icon: javascript, name: "home.showJS.title", @@ -458,7 +544,6 @@ export const flatToolRegistryMap: ToolRegistry = { category: "Advanced Tools", subcategory: "Developer Tools" }, - // External Developer Resources (open in new tab) "dev-api": { icon: open_in_new, name: "API", @@ -495,50 +580,71 @@ export const flatToolRegistryMap: ToolRegistry = { category: "Advanced Tools", subcategory: "Developer Tools" }, - "sign": { - icon: signature, - name: "home.sign.title", - component: null, - view: "sign", - description: "home.sign.desc", - category: "Standard Tools", - subcategory: "Signing" - }, - "single-large-page": { - icon: looks_one, - name: "home.PdfToSinglePage.title", + + + // Recommended Tools + "compare": { + icon: compare, + name: "home.compare.title", component: null, view: "format", - description: "home.PdfToSinglePage.desc", - category: "Standard Tools", - subcategory: "Page Formatting" + description: "home.compare.desc", + category: "Recommended Tools", + subcategory: null }, - "splitPdf": { - icon: content_cut, - name: "home.split.title", - component: SplitPdfPanel, - view: "split", - description: "home.split.desc", - category: "Standard Tools", - subcategory: "Page Formatting" + "compressPdfs": { + icon: zoom_in_map, + name: "home.compressPdfs.title", + component: CompressPdfPanel, + view: "compress", + description: "home.compressPdfs.desc", + category: "Recommended Tools", + subcategory: null }, - "unlock-pdf-forms": { - icon: preview_off, - name: "home.unlockPDFForms.title", + "convert": { + icon: sync_alt, + name: "home.fileToPDF.title", + component: ConvertPanel, + view: "convert", + description: "home.fileToPDF.desc", + category: "Recommended Tools", + subcategory: null + }, + "mergePdfs": { + icon: library_add, + name: "home.merge.title", component: null, - view: "security", - description: "home.unlockPDFForms.desc", - category: "Standard Tools", - subcategory: "Document Security" + view: "merge", + description: "home.merge.desc", + category: "Recommended Tools", + subcategory: null }, - "validate-pdf-signature": { - icon: verified, - name: "home.validateSignature.title", + "multi-tool": { + icon: dashboard_customize, + name: "home.multiTool.title", component: null, - view: "security", - description: "home.validateSignature.desc", - category: "Standard Tools", - subcategory: "Verification" + view: "pageEditor", + description: "home.multiTool.desc", + category: "Recommended Tools", + subcategory: null + }, + "ocr": { + icon: quick_reference_all, + name: "home.ocr.title", + component: OCRPanel, + view: "convert", + description: "home.ocr.desc", + category: "Recommended Tools", + subcategory: null + }, + "redact": { + icon: visibility_off, + name: "home.redact.title", + component: null, + view: "redact", + description: "home.redact.desc", + category: "Recommended Tools", + subcategory: null }, "view-pdf": { icon: article,