Elffuss BraidHub

kikocis/continue public

61bef27a1dcd · 2.2 KiBRawPermalink
1import {
2 ExclamationCircleIcon,
3 ExclamationTriangleIcon,
4} from "@heroicons/react/24/outline";
5import { useContext } from "react";
6import { useAuth } from "../../../../../context/Auth";
7import { IdeMessengerContext } from "../../../../../context/IdeMessenger";
8import { useAppSelector } from "../../../../../redux/hooks";
9
10export function ErrorSection() {
11 const configError = useAppSelector((state) => state.config.configError);
12 const configLoading = useAppSelector((state) => state.config.loading);
13 const ideMessenger = useContext(IdeMessengerContext);
14
15 const { refreshProfiles } = useAuth();
16
17 const sortedErrors = configError
18 ? [...configError].sort((a, b) => (b.fatal ? 1 : 0) - (a.fatal ? 1 : 0))
19 : [];
20
21 return (
22 <div className="flex flex-col gap-2 p-2">
23 <div className="flex flex-row items-center justify-end gap-1.5">
24 <div
25 className={`text-description cursor-pointer text-xs underline transition-all ${configLoading ? "opacity-0" : ""}`}
26 onClick={() => {
27 refreshProfiles("Clicked reload in Error section");
28 }}
29 >
30 Reload
31 </div>
32 <div
33 onClick={() => {
34 ideMessenger.post(
35 "openUrl",
36 "https://docs.continue.dev/troubleshooting",
37 );
38 }}
39 className="text-description cursor-pointer text-xs underline"
40 >
41 Help
42 </div>
43 </div>
44 <ul className="m-0 list-none space-y-4 p-0">
45 {sortedErrors.map((error, index) => (
46 <li
47 key={index}
48 className={`flex items-start rounded-md p-2 text-sm shadow-md ${
49 error.fatal
50 ? "bg-red-100 text-red-800"
51 : "bg-yellow-100 text-yellow-800"
52 }`}
53 >
54 {error.fatal ? (
55 <ExclamationCircleIcon className="mr-2 mt-1 h-3.5 w-3.5 shrink-0" />
56 ) : (
57 <ExclamationTriangleIcon className="mr-2 mt-1 h-3.5 w-3.5 shrink-0" />
58 )}
59 <p
60 className="m-0 whitespace-pre-wrap text-wrap"
61 style={{ wordBreak: "break-word" }}
62 >
63 {error.message}
64 </p>
65 </li>
66 ))}
67 </ul>
68 </div>
69 );
70}