mirror of
https://github.com/xCyanGrizzly/DragonsStash.git
synced 2026-05-10 22:01:16 +00:00
feat: show file match count badge in search results
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -23,12 +23,15 @@ export interface PackageRow {
|
|||||||
id: string;
|
id: string;
|
||||||
title: string;
|
title: string;
|
||||||
};
|
};
|
||||||
|
matchedFileCount: number;
|
||||||
|
matchedByContent: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface PackageColumnsProps {
|
interface PackageColumnsProps {
|
||||||
onViewFiles: (pkg: PackageRow) => void;
|
onViewFiles: (pkg: PackageRow) => void;
|
||||||
onSetCreator: (pkg: PackageRow) => void;
|
onSetCreator: (pkg: PackageRow) => void;
|
||||||
onSetTags: (pkg: PackageRow) => void;
|
onSetTags: (pkg: PackageRow) => void;
|
||||||
|
searchTerm: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
function formatBytes(bytesStr: string): string {
|
function formatBytes(bytesStr: string): string {
|
||||||
@@ -62,6 +65,7 @@ export function getPackageColumns({
|
|||||||
onViewFiles,
|
onViewFiles,
|
||||||
onSetCreator,
|
onSetCreator,
|
||||||
onSetTags,
|
onSetTags,
|
||||||
|
searchTerm,
|
||||||
}: PackageColumnsProps): ColumnDef<PackageRow, unknown>[] {
|
}: PackageColumnsProps): ColumnDef<PackageRow, unknown>[] {
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
@@ -76,7 +80,8 @@ export function getPackageColumns({
|
|||||||
accessorKey: "fileName",
|
accessorKey: "fileName",
|
||||||
header: ({ column }) => <DataTableColumnHeader column={column} title="File Name" />,
|
header: ({ column }) => <DataTableColumnHeader column={column} title="File Name" />,
|
||||||
cell: ({ row }) => (
|
cell: ({ row }) => (
|
||||||
<div className="flex items-center gap-2 min-w-0">
|
<div className="min-w-0">
|
||||||
|
<div className="flex items-center gap-2">
|
||||||
<span className="font-medium truncate max-w-[300px]">{row.original.fileName}</span>
|
<span className="font-medium truncate max-w-[300px]">{row.original.fileName}</span>
|
||||||
{row.original.isMultipart && (
|
{row.original.isMultipart && (
|
||||||
<Badge variant="outline" className="text-[10px] shrink-0">
|
<Badge variant="outline" className="text-[10px] shrink-0">
|
||||||
@@ -84,6 +89,15 @@ export function getPackageColumns({
|
|||||||
</Badge>
|
</Badge>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
{searchTerm && row.original.matchedByContent && (
|
||||||
|
<button
|
||||||
|
className="text-[11px] text-amber-500 hover:text-amber-400 hover:underline cursor-pointer mt-0.5"
|
||||||
|
onClick={() => onViewFiles(row.original)}
|
||||||
|
>
|
||||||
|
{row.original.matchedFileCount.toLocaleString()} file match{row.original.matchedFileCount !== 1 ? "es" : ""}
|
||||||
|
</button>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
),
|
),
|
||||||
enableHiding: false,
|
enableHiding: false,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ interface StlTableProps {
|
|||||||
totalCount: number;
|
totalCount: number;
|
||||||
ingestionStatus: IngestionAccountStatus[];
|
ingestionStatus: IngestionAccountStatus[];
|
||||||
availableTags: string[];
|
availableTags: string[];
|
||||||
|
searchTerm: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function StlTable({
|
export function StlTable({
|
||||||
@@ -37,6 +38,7 @@ export function StlTable({
|
|||||||
totalCount,
|
totalCount,
|
||||||
ingestionStatus,
|
ingestionStatus,
|
||||||
availableTags,
|
availableTags,
|
||||||
|
searchTerm,
|
||||||
}: StlTableProps) {
|
}: StlTableProps) {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const pathname = usePathname();
|
const pathname = usePathname();
|
||||||
@@ -77,6 +79,7 @@ export function StlTable({
|
|||||||
|
|
||||||
const columns = getPackageColumns({
|
const columns = getPackageColumns({
|
||||||
onViewFiles: (pkg) => setViewPkg(pkg),
|
onViewFiles: (pkg) => setViewPkg(pkg),
|
||||||
|
searchTerm,
|
||||||
onSetCreator: (pkg) => {
|
onSetCreator: (pkg) => {
|
||||||
const value = prompt("Enter creator name:", pkg.creator ?? "");
|
const value = prompt("Enter creator name:", pkg.creator ?? "");
|
||||||
if (value === null) return;
|
if (value === null) return;
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ export default async function StlFilesPage({ searchParams }: Props) {
|
|||||||
totalCount={result.pagination.total}
|
totalCount={result.pagination.total}
|
||||||
ingestionStatus={ingestionStatus}
|
ingestionStatus={ingestionStatus}
|
||||||
availableTags={availableTags}
|
availableTags={availableTags}
|
||||||
|
searchTerm={search}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user