diff --git a/src/screens/ModulesPage.tsx b/src/screens/ModulesPage.tsx index 8547ed9..0903d7f 100644 --- a/src/screens/ModulesPage.tsx +++ b/src/screens/ModulesPage.tsx @@ -600,7 +600,9 @@ export function ModulesPage({ // Catalog search & filter const [catalogQuery, setCatalogQuery] = useState(""); - const [catalogFilter, setCatalogFilter] = useState("all"); + // Four groups that do not overlap: checked by CoA (curated list + community modules CoA recommends or verified), + // the rest of the AzerothCore community, and modules known not to work with CoA. + const [catalogFilter, setCatalogFilter] = useState<"all" | "verified" | "community" | "incompatible">("all"); const [selectedCatalogModule, setSelectedCatalogModule] = useState(null); // Public AzerothCore Catalog state @@ -1061,10 +1063,7 @@ export function ModulesPage({ ); // Group A: Recommended / Verified for CoA - const filteredVerifiedCatalog = VERIFIED_CATALOG.filter((item) => { - if (catalogFilter === "official" && !item.isOfficial) return false; - if (catalogFilter === "verified" && item.isOfficial) return false; - if (catalogFilter === "community" || catalogFilter === "incompatible") return false; + const searchedVerifiedCatalog = VERIFIED_CATALOG.filter((item) => { if (!catalogQuery.trim()) return true; const q = catalogQuery.toLowerCase(); return ( @@ -1076,7 +1075,7 @@ export function ModulesPage({ }); // Group B: AzerothCore Community Modules - const filteredCommunityCatalog = (publicCatalog?.items ?? []) + const searchedCommunityCatalog = (publicCatalog?.items ?? []) .filter((item) => { // Exclude items already curated in Group A, or upstream forks replaced by CoA const slug = (item.full_name || item.name || "").toLowerCase(); @@ -1092,20 +1091,6 @@ export function ModulesPage({ return false; } - // Filter by category / status - if (catalogFilter === "official" || catalogFilter === "verified") { - return false; - } - if (catalogFilter === "recommended") { - if (item.coa_status !== "Recommended" && item.coa_status !== "Verified") return false; - } - if (catalogFilter === "community") { - if (item.coa_status === "Incompatible" || item.coa_status === "Blocked") return false; - } - if (catalogFilter === "incompatible") { - if (item.coa_status !== "Incompatible" && item.coa_status !== "Blocked") return false; - } - if (!catalogQuery.trim()) return true; const q = catalogQuery.toLowerCase(); return ( @@ -1126,6 +1111,25 @@ export function ModulesPage({ return (a.name || "").localeCompare(b.name || ""); }); + type CatalogGroup = "verified" | "community" | "incompatible"; + const communityGroup = (status: string | undefined): CatalogGroup => + status === "Recommended" || status === "Verified" + ? "verified" + : status === "Incompatible" || status === "Blocked" + ? "incompatible" + : "community"; + // Counts follow the search, so each segment says how many modules it will show. + const catalogCounts: Record<"all" | CatalogGroup, number> = { + all: searchedVerifiedCatalog.length + searchedCommunityCatalog.length, + verified: searchedVerifiedCatalog.length + searchedCommunityCatalog.filter((i) => communityGroup(i.coa_status) === "verified").length, + community: searchedCommunityCatalog.filter((i) => communityGroup(i.coa_status) === "community").length, + incompatible: searchedCommunityCatalog.filter((i) => communityGroup(i.coa_status) === "incompatible").length, + }; + const filteredVerifiedCatalog = + catalogFilter === "all" || catalogFilter === "verified" ? searchedVerifiedCatalog : []; + const filteredCommunityCatalog = + catalogFilter === "all" ? searchedCommunityCatalog : searchedCommunityCatalog.filter((i) => communityGroup(i.coa_status) === catalogFilter); + // Helper to check whether any module/plugin is installed function checkModuleInstalled(repoOrId: string, name: string) { const slug = normalizeUrlSlug(repoOrId); @@ -1897,64 +1901,35 @@ export function ModulesPage({ {/* Controls: Filter pills, Search, Sort */}
- {/* Filter pills */} -
- - - - - - + {/* Filter: one segmented control, groups that do not overlap */} +
+ {([ + ["all", locale === "ru" ? "Все" : "All"], + ["verified", locale === "ru" ? "Проверено CoA" : "Checked by CoA"], + ["community", locale === "ru" ? "Сообщество" : "Community"], + ["incompatible", locale === "ru" ? "Несовместимые" : "Incompatible"], + ] as const).map(([key, label], index) => ( + + ))}
{/* Search and Sort */} @@ -1974,15 +1949,18 @@ export function ModulesPage({ />
- +