mirror of
https://github.com/snapotter-hq/SnapOtter.git
synced 2026-08-03 07:46:42 +02:00
- Remove all lite/full variant logic from frontend, API, shared constants, docs, and tests (single unified Docker image only) - Replace single QEMU multi-arch Docker build with per-architecture native builds (amd64 + arm64) and manifest merge to fix disk space exhaustion - Add disk cleanup step and per-platform build cache scopes - Switch release trigger from push to workflow_dispatch - Add GitHub issue templates and PR template
67 lines
2.3 KiB
TypeScript
67 lines
2.3 KiB
TypeScript
import { CATEGORIES, TOOLS } from "@stirling-image/shared";
|
|
import { useEffect, useMemo, useState } from "react";
|
|
import { useSettingsStore } from "@/stores/settings-store";
|
|
import { SearchBar } from "../common/search-bar";
|
|
import { ToolCard } from "../common/tool-card";
|
|
|
|
export function ToolPanel() {
|
|
const [search, setSearch] = useState("");
|
|
const { disabledTools, experimentalEnabled, loaded, fetch } = useSettingsStore();
|
|
|
|
useEffect(() => {
|
|
fetch();
|
|
}, [fetch]);
|
|
|
|
const visibleTools = useMemo(() => {
|
|
if (!loaded) return [];
|
|
return TOOLS.filter((t) => {
|
|
if (disabledTools.includes(t.id)) return false;
|
|
if (t.experimental && !experimentalEnabled) return false;
|
|
return true;
|
|
});
|
|
}, [disabledTools, experimentalEnabled, loaded]);
|
|
|
|
const filteredTools = useMemo(() => {
|
|
if (!search) return visibleTools;
|
|
const q = search.toLowerCase();
|
|
return visibleTools.filter(
|
|
(t) => t.name.toLowerCase().includes(q) || t.description.toLowerCase().includes(q),
|
|
);
|
|
}, [search, visibleTools]);
|
|
|
|
const groupedTools = useMemo(() => {
|
|
const groups = new Map<string, typeof TOOLS>();
|
|
for (const tool of filteredTools) {
|
|
const list = groups.get(tool.category) || [];
|
|
list.push(tool);
|
|
groups.set(tool.category, list);
|
|
}
|
|
return groups;
|
|
}, [filteredTools]);
|
|
|
|
return (
|
|
<div className="w-72 border-r border-border bg-background overflow-y-auto flex flex-col shrink-0">
|
|
<div className="p-3 sticky top-0 bg-background z-10">
|
|
<SearchBar value={search} onChange={setSearch} />
|
|
</div>
|
|
<div className="px-3 pb-4 flex-1">
|
|
{CATEGORIES.filter((cat) => groupedTools.has(cat.id)).map((category) => (
|
|
<div key={category.id} className="mb-4">
|
|
<h3 className="text-xs font-semibold uppercase text-muted-foreground tracking-wider mb-2">
|
|
{category.name}
|
|
</h3>
|
|
<div className="space-y-0.5">
|
|
{groupedTools.get(category.id)?.map((tool) => (
|
|
<ToolCard key={tool.id} tool={tool} />
|
|
))}
|
|
</div>
|
|
</div>
|
|
))}
|
|
{filteredTools.length === 0 && (
|
|
<p className="text-sm text-muted-foreground text-center py-8">No tools found</p>
|
|
)}
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|