mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-20 10:20:15 +01:00
feat: clearing convos requires confirmation
This commit is contained in:
parent
655e7ce6d6
commit
0a671849b5
4 changed files with 73 additions and 3 deletions
|
|
@ -247,7 +247,6 @@ export default function TextChat({ messages }) {
|
||||||
} else {
|
} else {
|
||||||
let text = data.text || data.response;
|
let text = data.text || data.response;
|
||||||
if (data.initial) {
|
if (data.initial) {
|
||||||
console.log(data);
|
|
||||||
dispatch(toggleCursor());
|
dispatch(toggleCursor());
|
||||||
}
|
}
|
||||||
if (data.message) {
|
if (data.message) {
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,6 @@ export default function Messages({ messages, messageTree }) {
|
||||||
}, [messages]);
|
}, [messages]);
|
||||||
|
|
||||||
const scrollToBottom = useCallback(throttle(() => {
|
const scrollToBottom = useCallback(throttle(() => {
|
||||||
console.log('scrollToBottom');
|
|
||||||
messagesEndRef.current?.scrollIntoView({ behavior: 'smooth' });
|
messagesEndRef.current?.scrollIntoView({ behavior: 'smooth' });
|
||||||
setShowScrollButton(false);
|
setShowScrollButton(false);
|
||||||
}, 750, { leading: true }), [messagesEndRef]);
|
}, 750, { leading: true }), [messagesEndRef]);
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,8 @@ import { useDispatch } from 'react-redux';
|
||||||
import { setNewConvo, removeAll } from '~/store/convoSlice';
|
import { setNewConvo, removeAll } from '~/store/convoSlice';
|
||||||
import { setMessages } from '~/store/messageSlice';
|
import { setMessages } from '~/store/messageSlice';
|
||||||
import { setSubmission } from '~/store/submitSlice';
|
import { setSubmission } from '~/store/submitSlice';
|
||||||
|
import { Dialog, DialogTrigger } from '../ui/Dialog.tsx';
|
||||||
|
import DialogTemplate from '../ui/DialogTemplate';
|
||||||
|
|
||||||
export default function ClearConvos() {
|
export default function ClearConvos() {
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
|
|
@ -25,12 +27,25 @@ export default function ClearConvos() {
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
<Dialog>
|
||||||
|
<DialogTrigger asChild>
|
||||||
<a
|
<a
|
||||||
className="flex cursor-pointer items-center gap-3 rounded-md py-3 px-3 text-sm text-white transition-colors duration-200 hover:bg-gray-500/10"
|
className="flex cursor-pointer items-center gap-3 rounded-md py-3 px-3 text-sm text-white transition-colors duration-200 hover:bg-gray-500/10"
|
||||||
onClick={clickHandler}
|
// onClick={clickHandler}
|
||||||
>
|
>
|
||||||
<TrashIcon />
|
<TrashIcon />
|
||||||
Clear conversations
|
Clear conversations
|
||||||
</a>
|
</a>
|
||||||
|
</DialogTrigger>
|
||||||
|
<DialogTemplate
|
||||||
|
title="Clear conversations"
|
||||||
|
description="Are you sure you want to clear all conversations? This is irreversible."
|
||||||
|
selection={{
|
||||||
|
selectHandler: clickHandler,
|
||||||
|
selectClasses: 'bg-red-600 hover:bg-red-700 dark:hover:bg-red-800 text-white',
|
||||||
|
selectText: 'Clear',
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</Dialog>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
57
client/src/components/ui/DialogTemplate.jsx
Normal file
57
client/src/components/ui/DialogTemplate.jsx
Normal file
|
|
@ -0,0 +1,57 @@
|
||||||
|
import React from 'react';
|
||||||
|
|
||||||
|
import {
|
||||||
|
DialogClose,
|
||||||
|
DialogContent,
|
||||||
|
DialogDescription,
|
||||||
|
DialogFooter,
|
||||||
|
DialogHeader,
|
||||||
|
DialogTitle
|
||||||
|
} from './Dialog.tsx';
|
||||||
|
|
||||||
|
export default function DialogTemplate({ title, description, main, buttons, selection }) {
|
||||||
|
const { selectHandler, selectClasses, selectText } = selection;
|
||||||
|
|
||||||
|
const defaultSelect = "bg-gray-900 text-white transition-colors hover:bg-gray-700 focus:outline-none focus:ring-2 focus:ring-gray-400 focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 dark:bg-gray-100 dark:text-gray-900 dark:hover:bg-gray-200 dark:focus:ring-gray-400 dark:focus:ring-offset-gray-900"
|
||||||
|
return (
|
||||||
|
<DialogContent className="shadow-2xl dark:bg-gray-800">
|
||||||
|
<DialogHeader>
|
||||||
|
<DialogTitle className="text-gray-800 dark:text-white">{title}</DialogTitle>
|
||||||
|
<DialogDescription className="text-gray-600 dark:text-gray-300">
|
||||||
|
{description}
|
||||||
|
</DialogDescription>
|
||||||
|
</DialogHeader>
|
||||||
|
{/* <div className="grid gap-4 py-4">
|
||||||
|
<div className="grid grid-cols-4 items-center gap-4"> //input template
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div className="grid grid-cols-4 items-center gap-4">
|
||||||
|
<Label
|
||||||
|
htmlFor="promptPrefix"
|
||||||
|
className="text-right"
|
||||||
|
>
|
||||||
|
Prompt Prefix
|
||||||
|
</Label>
|
||||||
|
<TextareaAutosize
|
||||||
|
id="promptPrefix"
|
||||||
|
value={promptPrefix}
|
||||||
|
onChange={(e) => setPromptPrefix(e.target.value)}
|
||||||
|
placeholder="Set custom instructions. Defaults to: 'You are ChatGPT, a large language model trained by OpenAI.'"
|
||||||
|
className="col-span-3 flex h-20 w-full resize-none rounded-md border border-gray-300 bg-transparent py-2 px-3 text-sm shadow-[0_0_10px_rgba(0,0,0,0.10)] outline-none placeholder:text-gray-400 focus:outline-none focus:ring-gray-400 focus:ring-opacity-20 focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 dark:border-none dark:bg-gray-700 dark:text-gray-50 dark:shadow-[0_0_15px_rgba(0,0,0,0.10)] dark:focus:border-none dark:focus:border-transparent dark:focus:outline-none dark:focus:ring-0 dark:focus:ring-gray-400 dark:focus:ring-offset-0"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div> */}
|
||||||
|
{main ? main : null}
|
||||||
|
<DialogFooter>
|
||||||
|
<DialogClose className="dark:hover:gray-400 border-gray-700">Cancel</DialogClose>
|
||||||
|
{ buttons ? buttons : null}
|
||||||
|
<DialogClose
|
||||||
|
onClick={selectHandler}
|
||||||
|
className={`${selectClasses || defaultSelect} inline-flex h-10 items-center justify-center rounded-md border-none py-2 px-4 text-sm font-semibold`}
|
||||||
|
>
|
||||||
|
{selectText}
|
||||||
|
</DialogClose>
|
||||||
|
</DialogFooter>
|
||||||
|
</DialogContent>
|
||||||
|
);
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue