mirror of
https://github.com/khoaliber/khoj.git
synced 2026-03-10 05:39:11 +00:00
Eliminate the drawer component from the Agents view
This commit is contained in:
@@ -32,7 +32,6 @@ import {
|
|||||||
Globe,
|
Globe,
|
||||||
LockOpen,
|
LockOpen,
|
||||||
FloppyDisk,
|
FloppyDisk,
|
||||||
DotsThreeCircleVertical,
|
|
||||||
DotsThreeVertical,
|
DotsThreeVertical,
|
||||||
Pencil,
|
Pencil,
|
||||||
Trash,
|
Trash,
|
||||||
@@ -46,16 +45,6 @@ import {
|
|||||||
DialogHeader,
|
DialogHeader,
|
||||||
DialogTrigger,
|
DialogTrigger,
|
||||||
} from "@/components/ui/dialog";
|
} from "@/components/ui/dialog";
|
||||||
import {
|
|
||||||
Drawer,
|
|
||||||
DrawerClose,
|
|
||||||
DrawerContent,
|
|
||||||
DrawerDescription,
|
|
||||||
DrawerFooter,
|
|
||||||
DrawerHeader,
|
|
||||||
DrawerTitle,
|
|
||||||
DrawerTrigger,
|
|
||||||
} from "@/components/ui/drawer";
|
|
||||||
import LoginPrompt from "../components/loginPrompt/loginPrompt";
|
import LoginPrompt from "../components/loginPrompt/loginPrompt";
|
||||||
import { InlineLoading } from "../components/loading/loading";
|
import { InlineLoading } from "../components/loading/loading";
|
||||||
import SidePanel from "../components/sidePanel/chatHistorySidePanel";
|
import SidePanel from "../components/sidePanel/chatHistorySidePanel";
|
||||||
@@ -340,7 +329,6 @@ function AgentCard(props: AgentCardProps) {
|
|||||||
)}
|
)}
|
||||||
<CardHeader>
|
<CardHeader>
|
||||||
<CardTitle>
|
<CardTitle>
|
||||||
{!props.isMobileWidth ? (
|
|
||||||
<Dialog
|
<Dialog
|
||||||
open={showModal}
|
open={showModal}
|
||||||
onOpenChange={() => {
|
onOpenChange={() => {
|
||||||
@@ -396,12 +384,9 @@ function AgentCard(props: AgentCardProps) {
|
|||||||
className="items-center justify-start"
|
className="items-center justify-start"
|
||||||
variant={"destructive"}
|
variant={"destructive"}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
fetch(
|
fetch(`/api/agents/${props.data.slug}`, {
|
||||||
`/api/agents/${props.data.slug}`,
|
|
||||||
{
|
|
||||||
method: "DELETE",
|
method: "DELETE",
|
||||||
},
|
}).then(() => {
|
||||||
).then(() => {
|
|
||||||
props.setAgentChangeTriggered(true);
|
props.setAgentChangeTriggered(true);
|
||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
@@ -457,7 +442,7 @@ function AgentCard(props: AgentCardProps) {
|
|||||||
/>
|
/>
|
||||||
</DialogContent>
|
</DialogContent>
|
||||||
) : (
|
) : (
|
||||||
<DialogContent className="whitespace-pre-line max-h-[80vh]">
|
<DialogContent className="whitespace-pre-line max-h-[80vh] max-w-[90vw] rounded-lg">
|
||||||
<DialogHeader>
|
<DialogHeader>
|
||||||
<div className="flex items-center">
|
<div className="flex items-center">
|
||||||
{getIconFromIconName(props.data.icon, props.data.color)}
|
{getIconFromIconName(props.data.icon, props.data.color)}
|
||||||
@@ -487,134 +472,6 @@ function AgentCard(props: AgentCardProps) {
|
|||||||
</DialogContent>
|
</DialogContent>
|
||||||
)}
|
)}
|
||||||
</Dialog>
|
</Dialog>
|
||||||
) : (
|
|
||||||
<Drawer
|
|
||||||
open={showModal}
|
|
||||||
onOpenChange={(open) => {
|
|
||||||
setShowModal(open);
|
|
||||||
window.history.pushState({}, `Khoj AI - Agents`, `/agents`);
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<DrawerTrigger>
|
|
||||||
<div className="flex items-center">
|
|
||||||
{getIconFromIconName(props.data.icon, props.data.color)}
|
|
||||||
{props.data.name}
|
|
||||||
</div>
|
|
||||||
</DrawerTrigger>
|
|
||||||
<div className="flex float-right">
|
|
||||||
{props.editCard && (
|
|
||||||
<div className="float-right">
|
|
||||||
<Popover>
|
|
||||||
<PopoverTrigger>
|
|
||||||
<Button
|
|
||||||
className={`bg-[hsl(var(--background))] w-10 h-10 p-0 rounded-xl border dark:border-neutral-700 shadow-sm hover:bg-stone-100 dark:hover:bg-neutral-900`}
|
|
||||||
>
|
|
||||||
<DotsThreeVertical
|
|
||||||
className={`w-6 h-6 ${convertColorToTextClass(props.data.color)}`}
|
|
||||||
/>
|
|
||||||
</Button>
|
|
||||||
</PopoverTrigger>
|
|
||||||
<PopoverContent
|
|
||||||
className="w-fit grid p-1"
|
|
||||||
side={"bottom"}
|
|
||||||
align={"end"}
|
|
||||||
>
|
|
||||||
<Button
|
|
||||||
className="items-center justify-start"
|
|
||||||
variant={"ghost"}
|
|
||||||
onClick={() => setShowModal(true)}
|
|
||||||
>
|
|
||||||
<Pencil className="w-4 h-4 mr-2" />
|
|
||||||
Edit
|
|
||||||
</Button>
|
|
||||||
{props.editCard &&
|
|
||||||
props.data.privacy_level !== "private" && (
|
|
||||||
<ShareLink
|
|
||||||
buttonTitle="Share"
|
|
||||||
title="Share Agent"
|
|
||||||
description="Share a link to this agent with others. They'll be able to chat with it, and ask questions to all of its knowledge base."
|
|
||||||
buttonVariant={"ghost" as const}
|
|
||||||
includeIcon={true}
|
|
||||||
url={`${window.location.origin}/agents?agent=${props.data.slug}`}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
{props.data.creator === userData?.username && (
|
|
||||||
<Button
|
|
||||||
className="items-center justify-start"
|
|
||||||
variant={"destructive"}
|
|
||||||
onClick={() => {
|
|
||||||
fetch(
|
|
||||||
`/api/agents/${props.data.slug}`,
|
|
||||||
{
|
|
||||||
method: "DELETE",
|
|
||||||
},
|
|
||||||
).then(() => {
|
|
||||||
props.setAgentChangeTriggered(true);
|
|
||||||
});
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Trash className="w-4 h-4 mr-2" />
|
|
||||||
Delete
|
|
||||||
</Button>
|
|
||||||
)}
|
|
||||||
</PopoverContent>
|
|
||||||
</Popover>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
<div className="float-right">
|
|
||||||
{props.userProfile ? (
|
|
||||||
<Button
|
|
||||||
className={`bg-[hsl(var(--background))] w-10 h-10 p-0 rounded-xl border dark:border-neutral-700 shadow-sm hover:bg-stone-100 dark:hover:bg-neutral-900`}
|
|
||||||
onClick={() => openChat(props.data.slug, userData)}
|
|
||||||
>
|
|
||||||
<PaperPlaneTilt
|
|
||||||
className={`w-6 h-6 ${convertColorToTextClass(props.data.color)}`}
|
|
||||||
/>
|
|
||||||
</Button>
|
|
||||||
) : (
|
|
||||||
<Button
|
|
||||||
className={`bg-[hsl(var(--background))] w-14 h-14 rounded-xl border dark:border-neutral-700 shadow-sm hover:bg-stone-100 dark:hover:bg-neutral-900`}
|
|
||||||
onClick={() => setShowLoginPrompt(true)}
|
|
||||||
>
|
|
||||||
<PaperPlaneTilt
|
|
||||||
className={`w-6 h-6 ${convertColorToTextClass(props.data.color)}`}
|
|
||||||
/>
|
|
||||||
</Button>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{props.editCard ? (
|
|
||||||
<DrawerContent className="whitespace-pre-line p-2">
|
|
||||||
<AgentModificationForm
|
|
||||||
form={form}
|
|
||||||
onSubmit={onSubmit}
|
|
||||||
create={false}
|
|
||||||
errors={errors}
|
|
||||||
filesOptions={props.filesOptions}
|
|
||||||
modelOptions={props.modelOptions}
|
|
||||||
slug={props.data.slug}
|
|
||||||
inputToolOptions={props.inputToolOptions}
|
|
||||||
outputModeOptions={props.outputModeOptions}
|
|
||||||
isSubscribed={props.isSubscribed}
|
|
||||||
/>
|
|
||||||
</DrawerContent>
|
|
||||||
) : (
|
|
||||||
<DrawerContent className="whitespace-pre-line p-2">
|
|
||||||
<DrawerHeader>
|
|
||||||
<DrawerTitle>{props.data.name}</DrawerTitle>
|
|
||||||
<DrawerDescription>Persona</DrawerDescription>
|
|
||||||
</DrawerHeader>
|
|
||||||
{props.data.persona}
|
|
||||||
<div className="flex flex-wrap items-center gap-1">
|
|
||||||
{makeBadgeFooter()}
|
|
||||||
</div>
|
|
||||||
<DrawerFooter>
|
|
||||||
<DrawerClose>Done</DrawerClose>
|
|
||||||
</DrawerFooter>
|
|
||||||
</DrawerContent>
|
|
||||||
)}
|
|
||||||
</Drawer>
|
|
||||||
)}
|
|
||||||
</CardTitle>
|
</CardTitle>
|
||||||
</CardHeader>
|
</CardHeader>
|
||||||
<CardContent>
|
<CardContent>
|
||||||
@@ -930,7 +787,7 @@ function AgentModificationForm(props: AgentModificationFormProps) {
|
|||||||
/>
|
/>
|
||||||
<div className="grid">
|
<div className="grid">
|
||||||
<FormLabel className="mb-2">Look & Feel</FormLabel>
|
<FormLabel className="mb-2">Look & Feel</FormLabel>
|
||||||
<div className="flex gap-1 justify-left">
|
<div className="flex gap-1 justify-left flex-col md:flex-row">
|
||||||
<FormField
|
<FormField
|
||||||
control={props.form.control}
|
control={props.form.control}
|
||||||
name="color"
|
name="color"
|
||||||
@@ -1378,44 +1235,6 @@ function CreateAgentCard(props: CreateAgentCardProps) {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
if (props.isMobileWidth) {
|
|
||||||
return (
|
|
||||||
<Drawer open={showModal} onOpenChange={setShowModal}>
|
|
||||||
<DrawerTrigger>
|
|
||||||
<div className="flex items-center">
|
|
||||||
<Plus />
|
|
||||||
Create Agent
|
|
||||||
</div>
|
|
||||||
</DrawerTrigger>
|
|
||||||
<DrawerContent className="p-2">
|
|
||||||
<DrawerHeader>
|
|
||||||
<DrawerTitle>Create Agent</DrawerTitle>
|
|
||||||
</DrawerHeader>
|
|
||||||
{!props.userProfile && showLoginPrompt && (
|
|
||||||
<LoginPrompt
|
|
||||||
loginRedirectMessage="Sign in to start chatting with a specialized agent"
|
|
||||||
onOpenChange={setShowLoginPrompt}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
<AgentModificationForm
|
|
||||||
form={form}
|
|
||||||
onSubmit={onSubmit}
|
|
||||||
create={true}
|
|
||||||
errors={errors}
|
|
||||||
filesOptions={props.filesOptions}
|
|
||||||
modelOptions={props.modelOptions}
|
|
||||||
inputToolOptions={props.inputToolOptions}
|
|
||||||
outputModeOptions={props.outputModeOptions}
|
|
||||||
isSubscribed={props.isSubscribed}
|
|
||||||
/>
|
|
||||||
<DrawerFooter>
|
|
||||||
<DrawerClose>Dismiss</DrawerClose>
|
|
||||||
</DrawerFooter>
|
|
||||||
</DrawerContent>
|
|
||||||
</Drawer>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Dialog open={showModal} onOpenChange={setShowModal}>
|
<Dialog open={showModal} onOpenChange={setShowModal}>
|
||||||
<DialogTrigger>
|
<DialogTrigger>
|
||||||
|
|||||||
Reference in New Issue
Block a user