docs indexing style

This commit is contained in:
Nate 2025-03-21 16:34:40 -07:00
parent 83dce65dfa
commit 3b0cc0e618
3 changed files with 40 additions and 18 deletions

View file

@ -11,6 +11,7 @@ import {
setDialogMessage,
setShowDialog,
} from "../../../../../redux/slices/uiSlice";
import { getFontSize } from "../../../../../util";
import ConfirmationDialog from "../../../../dialogs/ConfirmationDialog";
import { StatusIndicator } from "./StatusIndicator";
@ -83,7 +84,7 @@ function DocsIndexingStatus({ docConfig }: IndexingStatusViewerProps) {
className={`flex flex-row items-center justify-between gap-2 text-sm`}
>
<div
className={`flex flex-row items-center gap-2 ${status?.url ? "cursor-pointer hover:underline" : ""}`}
className={`flex flex-row items-center gap-1 ${status?.url ? "cursor-pointer hover:underline" : ""}`}
onClick={() => {
if (status?.url) {
ideMessenger.post("openUrl", status.url);
@ -94,19 +95,33 @@ function DocsIndexingStatus({ docConfig }: IndexingStatusViewerProps) {
<img
src={docConfig.faviconUrl}
alt="doc icon"
className="h-4 w-4"
className="h-3 w-3"
/>
) : null}
<p className="lines lines-1 m-0 p-0 text-left">
<p
style={{
fontSize: `${getFontSize() - 3}px`,
}}
className="lines lines-1 m-0 p-0 text-left"
>
{docConfig.title ?? docConfig.startUrl}
</p>
<ArrowTopRightOnSquareIcon className="mb-0.5 h-3 w-3 text-stone-500" />
<ArrowTopRightOnSquareIcon className="h-2 w-2 text-stone-500" />
</div>
{status?.status === "pending" ? (
<div className="text-xs text-stone-500">Pending...</div>
) : (
<div className="flex flex-row items-center gap-1 text-stone-500">
{true && <span className="text-xs">{progressPercentage}%</span>}
{true && (
<span
className="text-xs"
style={{
fontSize: `${getFontSize() - 3}px`,
}}
>
{progressPercentage}%
</span>
)}
{status?.status !== "indexing" ? (
<TrashIcon

View file

@ -23,20 +23,27 @@ function DocsIndexingStatuses() {
const sortedConfigDocs = useMemo(() => {
const sorter = (status: IndexingStatus["status"]) => {
// TODO - further sorting?
if (status === "indexing" || status === "paused") return 0;
if (status === "failed") return 1;
if (status === "aborted" || status === "pending") return 2;
return 3;
if (status === "complete") return 0;
if (status === "indexing" || status === "paused") return 1;
if (status === "failed") return 2;
if (status === "aborted" || status === "pending") return 3;
return 4;
};
const docs = [...(config.docs ?? [])];
docs.sort((a, b) =>
sorter(indexingStatuses[b.startUrl]?.status ?? "pending") >
sorter(indexingStatuses[a.startUrl]?.status ?? "pending")
? -1
: 1,
);
docs.sort((a, b) => {
const statusA = indexingStatuses[a.startUrl]?.status ?? "pending";
const statusB = indexingStatuses[b.startUrl]?.status ?? "pending";
// First, compare by status
const statusCompare = sorter(statusB) - sorter(statusA);
if (statusCompare !== 0) return statusCompare;
// If status is the same, sort by presence of icon
const hasIconA = !!a.faviconUrl;
const hasIconB = !!b.faviconUrl;
return hasIconB === hasIconA ? 0 : hasIconB ? 1 : -1;
});
return docs;
}, [config, indexingStatuses]);

View file

@ -7,8 +7,8 @@ interface StatusIndicatorProps {
}
const STATUS_TO_COLOR: Record<IndexingStatus["status"], string> = {
indexing: "bg-blue-500",
paused: "bg-yellow-500",
indexing: "bg-yellow-500",
paused: "bg-blue-500",
complete: "bg-green-500",
aborted: "bg-gray-500",
pending: "bg-gray-300",