Elffuss BraidHub

kikocis/continue public

95c91a48de4e · 2.1 KiBRawPermalink
1import { useState } from "react";
2import { useAuth } from "../../../context/Auth";
3import { useAppSelector } from "../../../redux/hooks";
4import { getLocalStorage, setLocalStorage } from "../../../util/localStorage";
5import Alert from "../../gui/Alert";
6import { ReusableCard } from "../../ReusableCard";
7import { TabTitle } from "../components/OnboardingCardTabs";
8import OnboardingLocalTab from "../components/OnboardingLocalTab";
9import { useOnboardingCard } from "../hooks";
10import MainTab from "./tabs/main";
11
12export interface OnboardingCardState {
13 show?: boolean;
14 activeTab?: TabTitle;
15}
16
17interface OnboardingCardProps {
18 isDialog: boolean;
19}
20
21export function PlatformOnboardingCard({ isDialog }: OnboardingCardProps) {
22 const onboardingCard = useOnboardingCard();
23 const config = useAppSelector((store) => store.config.config);
24 const auth = useAuth();
25 const [currentTab, setCurrentTab] = useState<"main" | "local">("main");
26
27 if (getLocalStorage("onboardingStatus") === undefined) {
28 setLocalStorage("onboardingStatus", "Started");
29 }
30
31 function onGetStarted() {
32 auth.login(true).then((success) => {
33 if (success) {
34 onboardingCard.close(isDialog);
35 }
36 });
37 }
38
39 return (
40 <ReusableCard
41 showCloseButton={!isDialog && !!config.modelsByRole.chat.length}
42 onClose={() => onboardingCard.close()}
43 >
44 <div className="flex h-full w-full items-center justify-center">
45 {currentTab === "main" ? (
46 <MainTab
47 onRemainLocal={() => setCurrentTab("local")}
48 isDialog={isDialog}
49 />
50 ) : (
51 <div className="mt-4 flex flex-col">
52 <Alert type="info">
53 By choosing this option, Continue will be configured by a local
54 config.yaml file. If you're just looking to use Ollama and still
55 want to manage your configuration through Continue, click{" "}
56 <a href="#" onClick={onGetStarted}>
57 here
58 </a>
59 </Alert>
60 <OnboardingLocalTab isDialog={isDialog} />
61 </div>
62 )}
63 </div>
64 </ReusableCard>
65 );
66}