Filter to just show tools which exist

This commit is contained in:
James Brunton 2025-08-20 15:03:20 +01:00
parent eada9e43ec
commit 2ca823aced
2 changed files with 19 additions and 10 deletions

View File

@ -1,5 +1,6 @@
import { type TFunction } from 'i18next'; import { type TFunction } from 'i18next';
import React from 'react'; import React from 'react';
import { BaseToolProps } from '../types/tool';
export enum SubcategoryId { export enum SubcategoryId {
SIGNING = 'signing', SIGNING = 'signing',
@ -24,7 +25,7 @@ export enum ToolCategory {
export type ToolRegistryEntry = { export type ToolRegistryEntry = {
icon: React.ReactNode; icon: React.ReactNode;
name: string; name: string;
component: React.ComponentType<any> | null; component: React.ComponentType<BaseToolProps> | null;
view: 'sign' | 'security' | 'format' | 'extract' | 'view' | 'merge' | 'pageEditor' | 'convert' | 'redact' | 'split' | 'convert' | 'remove' | 'compress' | 'external'; view: 'sign' | 'security' | 'format' | 'extract' | 'view' | 'merge' | 'pageEditor' | 'convert' | 'redact' | 'split' | 'convert' | 'remove' | 'compress' | 'external';
description: string; description: string;
category: ToolCategory; category: ToolCategory;

View File

@ -21,7 +21,7 @@ import RemoveCertificateSign from '../tools/RemoveCertificateSign';
export function useFlatToolRegistry(): ToolRegistry { export function useFlatToolRegistry(): ToolRegistry {
const { t } = useTranslation(); const { t } = useTranslation();
return { const allTools: ToolRegistry = {
// Signing // Signing
"certSign": { "certSign": {
@ -617,4 +617,12 @@ export function useFlatToolRegistry(): ToolRegistry {
subcategory: SubcategoryId.GENERAL subcategory: SubcategoryId.GENERAL
}, },
}; };
const filteredTools = Object.keys(allTools)
.filter(key => allTools[key].component !== null || allTools[key].link)
.reduce((obj, key) => {
obj[key] = allTools[key];
return obj;
}, {} as ToolRegistry);
return filteredTools;
} }