mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-09-21 21:50:49 +02:00
feat: delete button confirm (#875)
* base for confirm delete * more like OpenAI
This commit is contained in:
parent
2b54e3f9fe
commit
28230d9305
4 changed files with 40 additions and 11 deletions
|
@ -126,6 +126,7 @@ export default function Conversation({ conversation, retainView }) {
|
||||||
renaming={renaming}
|
renaming={renaming}
|
||||||
cancelHandler={cancelHandler}
|
cancelHandler={cancelHandler}
|
||||||
retainView={retainView}
|
retainView={retainView}
|
||||||
|
title={title}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
|
|
|
@ -3,14 +3,21 @@ import TrashIcon from '../svg/TrashIcon';
|
||||||
import CrossIcon from '../svg/CrossIcon';
|
import CrossIcon from '../svg/CrossIcon';
|
||||||
import { useRecoilValue } from 'recoil';
|
import { useRecoilValue } from 'recoil';
|
||||||
import { useDeleteConversationMutation } from 'librechat-data-provider';
|
import { useDeleteConversationMutation } from 'librechat-data-provider';
|
||||||
|
import { Dialog, DialogTrigger, Label } from '~/components/ui/';
|
||||||
|
import DialogTemplate from '~/components/ui/DialogTemplate';
|
||||||
import store from '~/store';
|
import store from '~/store';
|
||||||
|
import { useLocalize } from '~/hooks';
|
||||||
|
|
||||||
export default function DeleteButton({ conversationId, renaming, cancelHandler, retainView }) {
|
export default function DeleteButton({ conversationId, renaming, retainView, title }) {
|
||||||
|
const localize = useLocalize();
|
||||||
const currentConversation = useRecoilValue(store.conversation) || {};
|
const currentConversation = useRecoilValue(store.conversation) || {};
|
||||||
const { newConversation } = store.useConversation();
|
const { newConversation } = store.useConversation();
|
||||||
const { refreshConversations } = store.useConversations();
|
const { refreshConversations } = store.useConversations();
|
||||||
|
|
||||||
|
const confirmDelete = () => {
|
||||||
|
deleteConvoMutation.mutate({ conversationId, source: 'button' });
|
||||||
|
};
|
||||||
|
|
||||||
const deleteConvoMutation = useDeleteConversationMutation(conversationId);
|
const deleteConvoMutation = useDeleteConversationMutation(conversationId);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
@ -25,15 +32,31 @@ export default function DeleteButton({ conversationId, renaming, cancelHandler,
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, [deleteConvoMutation.isSuccess]);
|
}, [deleteConvoMutation.isSuccess]);
|
||||||
|
|
||||||
const clickHandler = () => {
|
|
||||||
deleteConvoMutation.mutate({ conversationId, source: 'button' });
|
|
||||||
};
|
|
||||||
|
|
||||||
const handler = renaming ? cancelHandler : clickHandler;
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<button className="p-1 hover:text-white" onClick={handler}>
|
<Dialog>
|
||||||
{renaming ? <CrossIcon /> : <TrashIcon />}
|
<DialogTrigger asChild>
|
||||||
</button>
|
<button className="p-1 hover:text-white">{renaming ? <CrossIcon /> : <TrashIcon />}</button>
|
||||||
|
</DialogTrigger>
|
||||||
|
<DialogTemplate
|
||||||
|
title={localize('com_ui_delete_conversation')}
|
||||||
|
className="max-w-[450px]"
|
||||||
|
main={
|
||||||
|
<>
|
||||||
|
<div className="flex w-full flex-col items-center gap-2">
|
||||||
|
<div className="grid w-full items-center gap-2">
|
||||||
|
<Label htmlFor="chatGptLabel" className="text-left text-sm font-medium">
|
||||||
|
{localize('com_ui_delete_conversation_confirm')} <strong>{title}</strong>
|
||||||
|
</Label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
}
|
||||||
|
selection={{
|
||||||
|
selectHandler: confirmDelete,
|
||||||
|
selectClasses: 'bg-red-600 hover:bg-red-700 dark:hover:bg-red-800 text-white',
|
||||||
|
selectText: localize('com_ui_delete'),
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</Dialog>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,9 @@ export default {
|
||||||
com_ui_of: 'of',
|
com_ui_of: 'of',
|
||||||
com_ui_entries: 'Entries',
|
com_ui_entries: 'Entries',
|
||||||
com_ui_pay_per_call: 'All AI conversations in one place. Pay per call and not per month',
|
com_ui_pay_per_call: 'All AI conversations in one place. Pay per call and not per month',
|
||||||
|
com_ui_delete: 'Delete',
|
||||||
|
com_ui_delete_conversation: 'Delete chat?',
|
||||||
|
com_ui_delete_conversation_confirm: 'This will delete',
|
||||||
com_auth_error_login:
|
com_auth_error_login:
|
||||||
'Unable to login with the information provided. Please check your credentials and try again.',
|
'Unable to login with the information provided. Please check your credentials and try again.',
|
||||||
com_auth_no_account: 'Don\'t have an account?',
|
com_auth_no_account: 'Don\'t have an account?',
|
||||||
|
|
|
@ -29,6 +29,8 @@ export default {
|
||||||
com_ui_entries: 'Voci',
|
com_ui_entries: 'Voci',
|
||||||
com_ui_pay_per_call:
|
com_ui_pay_per_call:
|
||||||
'Tutte le conversazioni con l\'IA in un unico posto. Paga per chiamata e non al mese',
|
'Tutte le conversazioni con l\'IA in un unico posto. Paga per chiamata e non al mese',
|
||||||
|
com_ui_delete_conversation: 'Elimina chat?',
|
||||||
|
com_ui_delete_conversation_confirm: 'Questo eliminerà',
|
||||||
com_auth_error_login:
|
com_auth_error_login:
|
||||||
'Impossibile effettuare l\'accesso con le informazioni fornite. Controlla le tue credenziali e riprova.',
|
'Impossibile effettuare l\'accesso con le informazioni fornite. Controlla le tue credenziali e riprova.',
|
||||||
com_auth_no_account: 'Non hai un account?',
|
com_auth_no_account: 'Non hai un account?',
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue