Elffuss BraidHub

kikocis/continue public

e31fcddb0dec · 2.1 KiBRawPermalink
1import { IndexingStatus } from "core";
2import { useMemo } from "react";
3import { useDispatch } from "react-redux";
4import { useNavigate } from "react-router-dom";
5import {
6 setDialogMessage,
7 setShowDialog,
8} from "../../../../redux/slices/uiSlice";
9
10export interface DocsIndexingPeekProps {
11 status: IndexingStatus;
12}
13
14function DocsIndexingPeek({ status }: DocsIndexingPeekProps) {
15 const navigate = useNavigate();
16 const dispatch = useDispatch();
17
18 const progressPercentage = useMemo(() => {
19 return Math.min(100, Math.max(0, status.progress * 100));
20 }, [status.progress]);
21
22 return (
23 <div
24 className="text-lightgray flex cursor-pointer flex-row items-center gap-2 rounded-md px-1 hover:bg-gray-700/10"
25 onClick={() => {
26 // navigate("/more"); TODO
27 dispatch(setShowDialog(false));
28 dispatch(setDialogMessage(undefined));
29 }}
30 >
31 <p className="text-lightgray m-0 p-0 group-hover:underline">
32 {status.title}
33 </p>
34 <div className="my-2 h-1.5 flex-1 rounded-md border border-solid border-gray-400">
35 <div
36 className={`h-full rounded-lg bg-stone-500 transition-all duration-200 ease-in-out`}
37 style={{
38 width: `${progressPercentage}%`,
39 }}
40 />
41 </div>
42 <div className="xs:flex text-lightgray hidden flex-row items-center gap-1">
43 <span className="text-xs no-underline">
44 {progressPercentage.toFixed(0)}%
45 </span>
46 {/* <ArrowPathIcon
47 className={`animate-spin-slow inline-block h-4 w-4 text-lightgray`}
48 ></ArrowPathIcon> */}
49 </div>
50 </div>
51 );
52}
53
54interface DocsIndexingPeeksProps {
55 statuses: IndexingStatus[];
56}
57
58function DocsIndexingPeekList({ statuses }: DocsIndexingPeeksProps) {
59 return (
60 <div className="border-vsc-input-border mt-2 flex flex-col border-0 border-t border-solid pt-2">
61 <div className="max-h-[100px] overflow-y-auto pr-2">
62 {statuses.map((status) => {
63 return <DocsIndexingPeek key={status.id} status={status} />;
64 })}
65 </div>
66 </div>
67 );
68}
69
70export default DocsIndexingPeekList;