From 20b0d426a06bee1e2444e58378edef78cccb1d8b Mon Sep 17 00:00:00 2001 From: Willie Date: Fri, 29 May 2026 15:11:37 +0800 Subject: [PATCH] feat(ui): add enabled/disabled status filter to Resources page Mirror the list TUI status filter in the web dashboard. A single monochrome toggle button sits beside the source filter chips (separated by a divider) and cycles All -> Enabled -> Disabled. Counts are scoped to the active tab and compose orthogonally with the source filter. --- ui/src/pages/ResourcesPage.tsx | 93 ++++++++++++++++++++++++++++------ 1 file changed, 78 insertions(+), 15 deletions(-) diff --git a/ui/src/pages/ResourcesPage.tsx b/ui/src/pages/ResourcesPage.tsx index 698d81852..3055d2cb3 100644 --- a/ui/src/pages/ResourcesPage.tsx +++ b/ui/src/pages/ResourcesPage.tsx @@ -1,6 +1,7 @@ import { useState, useMemo, useCallback, useEffect, forwardRef, memo, type ReactElement } from 'react'; import { Link, useNavigate, useSearchParams } from 'react-router-dom'; import { + Asterisk, Search, GitBranch, Folder, @@ -529,6 +530,7 @@ function saveCollapsed(collapsed: Set) { type ResourceTab = 'skills' | 'agents'; type FilterType = 'all' | 'tracked' | 'github' | 'local'; +type StatusFilter = 'all' | 'enabled' | 'disabled'; type SortType = 'name-asc' | 'name-desc' | 'newest' | 'oldest'; type ViewType = 'grid' | 'grouped' | 'table'; @@ -539,6 +541,12 @@ const filterOptions: { key: FilterType; label: string; icon: React.ReactNode }[] { key: 'local', label: 'Local', icon: }, ]; +const statusOptions: { key: StatusFilter; label: string; icon: React.ReactNode }[] = [ + { key: 'all', label: 'All', icon: }, + { key: 'enabled', label: 'Enabled', icon: }, + { key: 'disabled', label: 'Disabled', icon: }, +]; + function matchFilter(skill: Skill, filterType: FilterType): boolean { switch (filterType) { case 'all': @@ -552,6 +560,17 @@ function matchFilter(skill: Skill, filterType: FilterType): boolean { } } +function matchStatus(skill: Skill, statusFilter: StatusFilter): boolean { + switch (statusFilter) { + case 'all': + return true; + case 'enabled': + return !skill.disabled; + case 'disabled': + return !!skill.disabled; + } +} + // Extract group key from relPath for sorting: tracked repo name or first dir segment. function sortGroup(s: Skill): string { @@ -788,10 +807,12 @@ export default function SkillsPage() { setActiveTab(tab); localStorage.setItem('skillshare:resources-tab', tab); setFilterType('all'); + setStatusFilter('all'); setSearch(''); }; const [search, setSearch] = useState(''); const [filterType, setFilterType] = useState('all'); + const [statusFilter, setStatusFilter] = useState('all'); const [sortType, setSortType] = useState('name-asc'); const [viewType, setViewType] = useState(() => { const saved = localStorage.getItem('skillshare:skills-view'); @@ -849,7 +870,26 @@ export default function SkillsPage() { return counts; }, [skills, activeTab]); - // Apply text filter -> type filter -> sort + // Compute enabled/disabled counts — scoped to the active tab, independent of + // the source filter so the two filter dimensions stay orthogonal. + const statusCounts = useMemo(() => { + const tabSkills = activeTab === 'agents' + ? skills.filter((s) => s.kind === 'agent') + : skills.filter((s) => s.kind !== 'agent'); + let disabled = 0; + for (const s of tabSkills) if (s.disabled) disabled++; + return { all: tabSkills.length, enabled: tabSkills.length - disabled, disabled }; + }, [skills, activeTab]); + + // Status filter is a single toggle button cycling All → Enabled → Disabled. + const nextStatusFilter: Record = { + all: 'enabled', + enabled: 'disabled', + disabled: 'all', + }; + const curStatus = statusOptions.find((o) => o.key === statusFilter)!; + + // Apply text filter -> source filter -> status filter -> sort const filtered = useMemo(() => { const q = search.toLowerCase(); const result = skills.filter( @@ -857,10 +897,11 @@ export default function SkillsPage() { (s.name.toLowerCase().includes(q) || s.flatName.toLowerCase().includes(q) || (s.source ?? '').toLowerCase().includes(q)) && - matchFilter(s, filterType), + matchFilter(s, filterType) && + matchStatus(s, statusFilter), ); return sortSkills(result, sortType); - }, [skills, search, filterType, sortType]); + }, [skills, search, filterType, statusFilter, sortType]); const skillItems = useMemo(() => filtered.filter((s) => s.kind !== 'agent'), [filtered]); const agentItems = useMemo(() => filtered.filter((s) => s.kind === 'agent'), [filtered]); @@ -975,23 +1016,44 @@ export default function SkillsPage() { /> - {/* Filter tabs */} - ({ - value: opt.key, - label: {opt.icon}{opt.label}, - count: filterCounts[opt.key], - }))} - /> + {/* Filters — source chips (outlined) + status pill-group (connected), + two orthogonal dimensions distinguished by control style */} +
+ ({ + value: opt.key, + label: {opt.icon}{opt.label}, + count: filterCounts[opt.key], + }))} + /> +
{/* Result count — hidden in folder view (merged into folder toolbar) */} - {(filterType !== 'all' || search) && viewType !== 'grouped' && ( + {(filterType !== 'all' || statusFilter !== 'all' || search) && viewType !== 'grouped' && (

{t('resources.showing', { count: tabFiltered.length, total: skills.length })} - {filterType !== 'all' && ( + {(filterType !== 'all' || statusFilter !== 'all') && ( <> {' '} ·{' '} @@ -999,6 +1061,7 @@ export default function SkillsPage() { variant="link" onClick={() => { setFilterType('all'); + setStatusFilter('all'); setSearch(''); }} >