Elffuss BraidHub

kikocis/continue public

4248554ef60b · 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 indexing: ArrowPathIcon,
17 paused: PauseCircleIcon,
18 done: CheckCircleIcon,
19 failed: null, // Since we show an erorr message below
20 cancelled: null,
21};
22
23function IndexingProgressIndicator({ update }: IndexingProgressIndicatorProps) {
24 const progressPercentage = getProgressPercentage(update.progress).toFixed(0);
25 const Icon = STATUS_TO_ICON[update.status];
26 const animateIcon = update.status === "indexing";
27 const showProgress =
28 update.status !== "disabled" && progressPercentage !== "100";
29
30 return (
31 <div className="text-lightgray flex items-center justify-between gap-1">
32 {showProgress && <span className="text-xs">{progressPercentage}%</span>}
33
34 {Icon && (
35 <div className="flex items-center">
36 <Icon
37 className={`text-lightgray inline-block h-4 w-4 align-top ${
38 animateIcon ? "animate-spin-slow" : ""
39 }`}
40 ></Icon>
41 </div>
42 )}
43 </div>
44 );
45}
46
47export default IndexingProgressIndicator;