mirror of
https://github.com/khoaliber/khoj.git
synced 2026-03-09 13:25:11 +00:00
Add mobile friendliness and replace the login page redirects
This commit is contained in:
@@ -143,6 +143,7 @@ function CreateAgentCard(props: CreateAgentCardProps) {
|
|||||||
<LoginPrompt
|
<LoginPrompt
|
||||||
loginRedirectMessage="Sign in to start chatting with a specialized agent"
|
loginRedirectMessage="Sign in to start chatting with a specialized agent"
|
||||||
onOpenChange={setShowLoginPrompt}
|
onOpenChange={setShowLoginPrompt}
|
||||||
|
isMobileWidth={props.isMobileWidth}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
<AgentModificationForm
|
<AgentModificationForm
|
||||||
@@ -317,6 +318,7 @@ export default function Agents() {
|
|||||||
<LoginPrompt
|
<LoginPrompt
|
||||||
loginRedirectMessage="Sign in to start chatting with a specialized agent"
|
loginRedirectMessage="Sign in to start chatting with a specialized agent"
|
||||||
onOpenChange={setShowLoginPrompt}
|
onOpenChange={setShowLoginPrompt}
|
||||||
|
isMobileWidth={isMobileWidth}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
<Alert className="bg-secondary border-none my-4">
|
<Alert className="bg-secondary border-none my-4">
|
||||||
|
|||||||
@@ -1064,6 +1064,7 @@ export default function Automations() {
|
|||||||
<LoginPrompt
|
<LoginPrompt
|
||||||
loginRedirectMessage={"Create an account to make your own automation"}
|
loginRedirectMessage={"Create an account to make your own automation"}
|
||||||
onOpenChange={setShowLoginPrompt}
|
onOpenChange={setShowLoginPrompt}
|
||||||
|
isMobileWidth={isMobileWidth}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
<Alert className="bg-secondary border-none my-4">
|
<Alert className="bg-secondary border-none my-4">
|
||||||
|
|||||||
@@ -328,6 +328,7 @@ export function AgentCard(props: AgentCardProps) {
|
|||||||
<LoginPrompt
|
<LoginPrompt
|
||||||
loginRedirectMessage={`Sign in to start chatting with ${props.data.name}`}
|
loginRedirectMessage={`Sign in to start chatting with ${props.data.name}`}
|
||||||
onOpenChange={setShowLoginPrompt}
|
onOpenChange={setShowLoginPrompt}
|
||||||
|
isMobileWidth={props.isMobileWidth}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
<CardHeader>
|
<CardHeader>
|
||||||
|
|||||||
@@ -408,6 +408,7 @@ export const ChatInputArea = forwardRef<HTMLTextAreaElement, ChatInputProps>((pr
|
|||||||
{showLoginPrompt && loginRedirectMessage && (
|
{showLoginPrompt && loginRedirectMessage && (
|
||||||
<LoginPrompt
|
<LoginPrompt
|
||||||
onOpenChange={setShowLoginPrompt}
|
onOpenChange={setShowLoginPrompt}
|
||||||
|
isMobileWidth={props.isMobileWidth}
|
||||||
loginRedirectMessage={loginRedirectMessage}
|
loginRedirectMessage={loginRedirectMessage}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import Link from "next/link";
|
|||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import useSWR from "swr";
|
import useSWR from "swr";
|
||||||
import { GoogleSignIn } from "./GoogleSignIn";
|
import { GoogleSignIn } from "./GoogleSignIn";
|
||||||
|
import { Drawer, DrawerContent } from "@/components/ui/drawer";
|
||||||
|
|
||||||
export interface LoginPromptProps {
|
export interface LoginPromptProps {
|
||||||
loginRedirectMessage: string;
|
loginRedirectMessage: string;
|
||||||
@@ -143,19 +144,50 @@ export default function LoginPrompt(props: LoginPromptProps) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (props.isMobileWidth) {
|
||||||
|
return (
|
||||||
|
<Drawer open={true} onOpenChange={props.onOpenChange}>
|
||||||
|
<DrawerContent
|
||||||
|
className={`flex flex-col gap-4 max-w-xl ${!useEmailSignIn ? "p-0 pb-4 m-0" : ""}`}
|
||||||
|
>
|
||||||
|
<div>
|
||||||
|
{useEmailSignIn && (
|
||||||
|
<EmailSignInContext
|
||||||
|
email={email}
|
||||||
|
setEmail={setEmail}
|
||||||
|
checkEmail={checkEmail}
|
||||||
|
setCheckEmail={setCheckEmail}
|
||||||
|
setUseEmailSignIn={setUseEmailSignIn}
|
||||||
|
recheckEmail={recheckEmail}
|
||||||
|
setRecheckEmail={setRecheckEmail}
|
||||||
|
handleMagicLinkSignIn={handleMagicLinkSignIn}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
{!useEmailSignIn && (
|
||||||
|
<MainSignInContext
|
||||||
|
tips={tips}
|
||||||
|
currentTip={currentTip}
|
||||||
|
nextSlide={nextSlide}
|
||||||
|
prevSlide={prevSlide}
|
||||||
|
handleGoogleScriptLoad={handleGoogleScriptLoad}
|
||||||
|
handleGoogleSignIn={handleGoogleSignIn}
|
||||||
|
isLoading={isLoading}
|
||||||
|
data={data}
|
||||||
|
setUseEmailSignIn={setUseEmailSignIn}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</DrawerContent>
|
||||||
|
</Drawer>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Dialog open={true} onOpenChange={props.onOpenChange}>
|
<Dialog open={true} onOpenChange={props.onOpenChange}>
|
||||||
<DialogContent
|
<DialogContent
|
||||||
className={`flex flex-col gap-4 max-w-xl ${!useEmailSignIn ? "p-0 pb-4 m-0" : ""}`}
|
className={`flex flex-col gap-4 max-w-xl ${!useEmailSignIn ? "p-0 pb-4 m-0" : ""}`}
|
||||||
>
|
>
|
||||||
<div>
|
<div>
|
||||||
{/* <DialogHeader>
|
|
||||||
<DialogTitle>Sign in to Khoj to continue</DialogTitle>
|
|
||||||
</DialogHeader>
|
|
||||||
<DialogDescription className="py-4">
|
|
||||||
{props.loginRedirectMessage}.
|
|
||||||
</DialogDescription> */}
|
|
||||||
|
|
||||||
{useEmailSignIn && (
|
{useEmailSignIn && (
|
||||||
<EmailSignInContext
|
<EmailSignInContext
|
||||||
email={email}
|
email={email}
|
||||||
|
|||||||
@@ -25,6 +25,8 @@ import {
|
|||||||
import { Moon, Sun, UserCircle, Question, GearFine, ArrowRight, Code } from "@phosphor-icons/react";
|
import { Moon, Sun, UserCircle, Question, GearFine, ArrowRight, Code } from "@phosphor-icons/react";
|
||||||
import { KhojAgentLogo, KhojAutomationLogo, KhojSearchLogo } from "../logo/khojLogo";
|
import { KhojAgentLogo, KhojAutomationLogo, KhojSearchLogo } from "../logo/khojLogo";
|
||||||
import { useIsMobileWidth } from "@/app/common/utils";
|
import { useIsMobileWidth } from "@/app/common/utils";
|
||||||
|
import LoginPrompt from "../loginPrompt/loginPrompt";
|
||||||
|
import { Button } from "@/components/ui/button";
|
||||||
|
|
||||||
function SubscriptionBadge({ is_active }: { is_active: boolean }) {
|
function SubscriptionBadge({ is_active }: { is_active: boolean }) {
|
||||||
return (
|
return (
|
||||||
@@ -51,6 +53,7 @@ export default function NavMenu() {
|
|||||||
const [darkMode, setDarkMode] = useState(false);
|
const [darkMode, setDarkMode] = useState(false);
|
||||||
const [initialLoadDone, setInitialLoadDone] = useState(false);
|
const [initialLoadDone, setInitialLoadDone] = useState(false);
|
||||||
const isMobileWidth = useIsMobileWidth();
|
const isMobileWidth = useIsMobileWidth();
|
||||||
|
const [showLoginPrompt, setShowLoginPrompt] = useState(false);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (localStorage.getItem("theme") === "dark") {
|
if (localStorage.getItem("theme") === "dark") {
|
||||||
@@ -87,6 +90,13 @@ export default function NavMenu() {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={styles.titleBar}>
|
<div className={styles.titleBar}>
|
||||||
|
{showLoginPrompt && (
|
||||||
|
<LoginPrompt
|
||||||
|
onOpenChange={setShowLoginPrompt}
|
||||||
|
isMobileWidth={isMobileWidth}
|
||||||
|
loginRedirectMessage={"Login to your second brain"}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
{isMobileWidth ? (
|
{isMobileWidth ? (
|
||||||
<DropdownMenu>
|
<DropdownMenu>
|
||||||
<DropdownMenuTrigger>
|
<DropdownMenuTrigger>
|
||||||
@@ -197,12 +207,16 @@ export default function NavMenu() {
|
|||||||
</DropdownMenuItem>
|
</DropdownMenuItem>
|
||||||
) : (
|
) : (
|
||||||
<DropdownMenuItem>
|
<DropdownMenuItem>
|
||||||
<Link href="/login" className="no-underline w-full">
|
<Button
|
||||||
<div className="flex flex-rows">
|
variant={"ghost"}
|
||||||
|
onClick={() => setShowLoginPrompt(true)}
|
||||||
|
className="no-underline w-full text-left p-0 content-start justify-start items-start h-fit"
|
||||||
|
>
|
||||||
|
<div className="flex flex-rows text-left content-start justify-start items-start p-0">
|
||||||
<ArrowRight className="w-6 h-6" />
|
<ArrowRight className="w-6 h-6" />
|
||||||
<p className="ml-3 font-semibold">Login</p>
|
<p className="ml-3 font-semibold">Login</p>
|
||||||
</div>
|
</div>
|
||||||
</Link>
|
</Button>
|
||||||
</DropdownMenuItem>
|
</DropdownMenuItem>
|
||||||
)}
|
)}
|
||||||
</>
|
</>
|
||||||
@@ -323,12 +337,16 @@ export default function NavMenu() {
|
|||||||
</MenubarItem>
|
</MenubarItem>
|
||||||
) : (
|
) : (
|
||||||
<MenubarItem>
|
<MenubarItem>
|
||||||
<Link href="/login" className="no-underline w-full">
|
<Button
|
||||||
<div className="flex flex-rows">
|
variant={"ghost"}
|
||||||
|
onClick={() => setShowLoginPrompt(true)}
|
||||||
|
className="no-underline w-full text-left p-0 content-start justify-start items-start h-fit"
|
||||||
|
>
|
||||||
|
<div className="flex flex-rows text-left content-start justify-start items-start p-0">
|
||||||
<ArrowRight className="w-6 h-6" />
|
<ArrowRight className="w-6 h-6" />
|
||||||
<p className="ml-3 font-semibold">Login</p>
|
<p className="ml-3 font-semibold">Login</p>
|
||||||
</div>
|
</div>
|
||||||
</Link>
|
</Button>
|
||||||
</MenubarItem>
|
</MenubarItem>
|
||||||
)}
|
)}
|
||||||
</>
|
</>
|
||||||
|
|||||||
@@ -217,6 +217,7 @@ function ChatBodyData(props: ChatBodyDataProps) {
|
|||||||
{showLoginPrompt && (
|
{showLoginPrompt && (
|
||||||
<LoginPrompt
|
<LoginPrompt
|
||||||
onOpenChange={setShowLoginPrompt}
|
onOpenChange={setShowLoginPrompt}
|
||||||
|
isMobileWidth={props.isMobileWidth}
|
||||||
loginRedirectMessage={"Login to your second brain"}
|
loginRedirectMessage={"Login to your second brain"}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|||||||
Reference in New Issue
Block a user