Skip to content

Commit

Permalink
added confirm model for reset btn
Browse files Browse the repository at this point in the history
  • Loading branch information
TwanLuttik committed Sep 22, 2023
1 parent 14e47ba commit 928b1e8
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 3 deletions.
37 changes: 37 additions & 0 deletions src/components/ConfirmModal.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import React from 'react';
import {
AlertDialogCancel,
AlertDialogDescription,
AlertDialogFooter,
AlertDialogHeader,
AlertDialogTitle,
AlertDialog,
AlertDialogAction,
AlertDialogContent,
AlertDialogTrigger,
} from './ui/alert-dialog';

interface IConfirmModalProps {
onResponse: (e: boolean) => void;
}

export const ConfirmModal: React.FC<IConfirmModalProps> = () => {
return (
<AlertDialog>
<AlertDialogTrigger>Open</AlertDialogTrigger>
<AlertDialogContent>
<AlertDialogHeader>
<AlertDialogTitle>Are you absolutely sure?</AlertDialogTitle>
<AlertDialogDescription>
This action cannot be undone. This will permanently delete your
account and remove your data from our servers.
</AlertDialogDescription>
</AlertDialogHeader>
<AlertDialogFooter>
<AlertDialogCancel>Cancel</AlertDialogCancel>
<AlertDialogAction>Continue</AlertDialogAction>
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
);
};
18 changes: 15 additions & 3 deletions src/pages/index/parts/SideInfoSheet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import { OLLAMA_COMMAND, core } from '@/core';
import { useSimple } from 'simple-core-state';
import { TryConnect } from '../helper';
import { Badge } from '@/components/ui/badge';
import { ConfirmModal } from '@/components/ConfirmModal';
import { useState } from 'react';

interface ISideInfoSheetProps {
loading: boolean;
Expand Down Expand Up @@ -52,14 +54,21 @@ export const SideInfoSheet: React.FC<ISideInfoSheetProps> = ({ loading }) => {
});
};

const [showResetConfirm, setShowResetConfirm] = useState(false);
const onResetResponse = (e: boolean) => {
if (e) clearConversations();
setShowResetConfirm(false);
};

return (
<Sheet>
{showResetConfirm && <ConfirmModal onResponse={onResetResponse} />}
<SheetTrigger asChild>
<Button variant="outline" className="whitespace-nowrap dark:text-white">
Settings & Info
</Button>
</SheetTrigger>
<SheetContent className="border-neutral-100 dark:border-neutral-900">
<SheetContent className="border-neutral-100 dark:border-neutral-900 overflow-auto">
<SheetHeader>
<SheetTitle>Welcome to Ollama Web Interface</SheetTitle>
<SheetDescription>
Expand All @@ -80,7 +89,7 @@ export const SideInfoSheet: React.FC<ISideInfoSheetProps> = ({ loading }) => {
</a>
<div className="flex flex-col mt-4">
<Label className="mb-1 font-medium text-neutral-900 dark:text-neutral-100">
Ollama remote address:
Ollama remote address:https://twitter.com/twanluttik
</Label>

<Input
Expand Down Expand Up @@ -158,7 +167,7 @@ export const SideInfoSheet: React.FC<ISideInfoSheetProps> = ({ loading }) => {
</div>
</div>
<Button
onClick={clearConversations}
onClick={() => setShowResetConfirm(true)}
variant="destructive"
className="mt-6 w-fit"
>
Expand All @@ -171,12 +180,15 @@ export const SideInfoSheet: React.FC<ISideInfoSheetProps> = ({ loading }) => {
>
<a
href="https://twitter.com/twanluttik"
target="_blank"
className="mt-10 text-sm font-semibold hover:opacity-60 tracking-tight dark:text-white"
>
Twan Luttik - X (Twitter)
</a>

<a
href="https://github.com/ollama-interface/Ollama-Gui"
target="_blank"
className="mt-2 text-sm underline hover:opacity-60 dark:text-white"
>
https://github.com/ollama-interface/Ollama-Gui
Expand Down

0 comments on commit 928b1e8

Please sign in to comment.