Elffuss BraidHub

kikocis/continue public

main · 1.4 KiBRawPermalink
1import {
2 ArrowPathIcon,
3 CheckCircleIcon,
4 PauseCircleIcon,
5} from "@heroicons/react/24/outline";
6import { IndexingProgressUpdate } from "core";
7import { getProgressPercentage } from "./IndexingProgress";
8
9export interface IndexingProgressIndicatorProps {
10 update: IndexingProgressUpdate;
11}
12
13const STATUS_TO_ICON: Record<IndexingProgressUpdate["status"], any> = {
14 disabled: null,
15 loading: null,
16 waiting: null,
17 indexing: ArrowPathIcon,
18 paused: PauseCircleIcon,
19 done: CheckCircleIcon,
20 failed: null, // Since we show an erorr message below
21 cancelled: null,
22};
23
24function IndexingProgressIndicator({ update }: IndexingProgressIndicatorProps) {
25 const progressPercentage = getProgressPercentage(update.progress).toFixed(0);
26 const Icon = STATUS_TO_ICON[update.status];
27 const animateIcon = update.status === "indexing";
28 const showProgress =
29 update.status !== "disabled" && progressPercentage !== "100";
30
31 return (
32 <div className="text-lightgray flex items-center justify-between gap-1">
33 {showProgress && <span className="text-xs">{progressPercentage}%</span>}
34
35 {Icon && (
36 <div className="flex items-center">
37 <Icon
38 className={`text-lightgray inline-block h-4 w-4 align-top ${
39 animateIcon ? "animate-spin-slow" : ""
40 }`}
41 ></Icon>
42 </div>
43 )}
44 </div>
45 );
46}
47
48export default IndexingProgressIndicator;