Skip to content

Commit d78a6f0

Browse files
authored
♻️ Unify dialog&modal
2 parents b18673a + 4a70506 commit d78a6f0

File tree

16 files changed

+189
-998
lines changed

16 files changed

+189
-998
lines changed

frontend/app/[locale]/agents/components/AgentSetupOrchestrator.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2003,7 +2003,7 @@ export default function AgentSetupOrchestrator({
20032003
content: t("agentConfig.agents.copyConfirmContent", {
20042004
name: agent?.display_name || agent?.name || "",
20052005
}),
2006-
onConfirm: () => handleCopyAgentFromList(agent),
2006+
onOk: () => handleCopyAgentFromList(agent),
20072007
});
20082008
};
20092009

@@ -2326,10 +2326,6 @@ export default function AgentSetupOrchestrator({
23262326
>
23272327
<div className="py-2">
23282328
<div className="flex items-center">
2329-
<WarningFilled
2330-
className="text-yellow-500 mt-1 mr-2"
2331-
style={{ fontSize: "48px" }}
2332-
/>
23332329
<div className="ml-3 mt-2">
23342330
<div className="text-sm leading-6">
23352331
{t("businessLogic.config.modal.deleteContent", {

frontend/app/[locale]/agents/components/McpConfigModal.tsx

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import {
3434
checkMcpServerHealth,
3535
} from "@/services/mcpService";
3636
import { McpServer, McpTool } from "@/types/agentConfig";
37+
import { useConfirmModal } from "@/hooks/useConfirmModal";
3738
import log from "@/lib/logger";
3839

3940
const { Text, Title } = Typography;
@@ -43,7 +44,8 @@ export default function McpConfigModal({
4344
onCancel,
4445
}: McpConfigModalProps) {
4546
const { t } = useTranslation("common");
46-
const { message, modal } = App.useApp();
47+
const { message } = App.useApp();
48+
const { confirm } = useConfirmModal();
4749
const [serverList, setServerList] = useState<McpServer[]>([]);
4850
const [loading, setLoading] = useState(false);
4951
const [addingServer, setAddingServer] = useState(false);
@@ -159,16 +161,12 @@ export default function McpConfigModal({
159161

160162
// Delete MCP server
161163
const handleDeleteServer = async (server: McpServer) => {
162-
modal.confirm({
164+
confirm({
163165
title: t("mcpConfig.delete.confirmTitle"),
164166
content: t("mcpConfig.delete.confirmContent", {
165167
name: server.service_name,
166168
}),
167169
okText: t("common.delete", "Delete"),
168-
cancelText: t("common.cancel", "Cancel"),
169-
okType: "danger",
170-
cancelButtonProps: { disabled: updatingTools },
171-
okButtonProps: { disabled: updatingTools, loading: updatingTools },
172170
onOk: async () => {
173171
try {
174172
const result = await deleteMcpServer(

frontend/app/[locale]/chat/components/chatHeader.tsx

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ import { useAuth } from "@/hooks/useAuth";
1414
import { USER_ROLES } from "@/const/modelConfig";
1515
import { saveView } from "@/lib/viewPersistence";
1616

17-
import MemoryManageModal from "../internal/memory/memoryManageModal";
18-
1917
interface ChatHeaderProps {
2018
title: string;
2119
onRename?: (newTitle: string) => void;
@@ -25,8 +23,7 @@ export function ChatHeader({ title, onRename }: ChatHeaderProps) {
2523
const router = useRouter();
2624
const [isEditing, setIsEditing] = useState(false);
2725
const [editTitle, setEditTitle] = useState(title);
28-
const [memoryModalVisible, setMemoryModalVisible] = useState(false);
29-
const [embeddingConfigured, setEmbeddingConfigured] = useState<boolean>(true);
26+
3027
const [showConfigPrompt, setShowConfigPrompt] = useState(false);
3128
const [showAutoOffPrompt, setShowAutoOffPrompt] = useState(false);
3229
const inputRef = useRef<HTMLInputElement>(null);
@@ -62,9 +59,8 @@ export function ChatHeader({ title, onRename }: ChatHeaderProps) {
6259
const modelConfig = configStore.getModelConfig();
6360
const configured = Boolean(
6461
modelConfig?.embedding?.modelName ||
65-
modelConfig?.multiEmbedding?.modelName
62+
modelConfig?.multiEmbedding?.modelName
6663
);
67-
setEmbeddingConfigured(configured);
6864

6965
if (!configured) {
7066
// If memory switch is on, turn it off automatically and notify the user
@@ -85,7 +81,6 @@ export function ChatHeader({ title, onRename }: ChatHeaderProps) {
8581
});
8682
}
8783
} catch (e) {
88-
setEmbeddingConfigured(false);
8984
log.error("Failed to read model config for embedding check", e);
9085
}
9186
}, []);
@@ -227,10 +222,6 @@ export function ChatHeader({ title, onRename }: ChatHeaderProps) {
227222
</div>
228223
</div>
229224
</Modal>
230-
<MemoryManageModal
231-
visible={memoryModalVisible}
232-
onClose={() => setMemoryModalVisible(false)}
233-
/>
234225
</>
235226
);
236227
}

frontend/app/[locale]/chat/components/chatLeftSidebar.tsx

Lines changed: 11 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,7 @@ import {
1818
DropdownMenuTrigger,
1919
} from "@/components/ui/dropdownMenu";
2020
import { Input } from "@/components/ui/input";
21-
import {
22-
Dialog,
23-
DialogContent,
24-
DialogDescription,
25-
DialogFooter,
26-
DialogHeader,
27-
DialogTitle,
28-
} from "@/components/ui/dialog";
21+
import { App } from "antd";
2922
import {
3023
Tooltip,
3124
TooltipContent,
@@ -35,6 +28,7 @@ import {
3528
import { StaticScrollArea } from "@/components/ui/scrollArea";
3629
import { USER_ROLES } from "@/const/modelConfig";
3730
import { useTranslation } from "react-i18next";
31+
import { useConfirmModal } from "@/hooks/useConfirmModal";
3832
import { ConversationListItem, ChatSidebarProps } from "@/types/chat";
3933

4034
// conversation status indicator component
@@ -68,7 +62,6 @@ const ConversationStatusIndicator = ({
6862
return null;
6963
};
7064

71-
7265
// Helper function - dialog classification
7366
const categorizeDialogs = (dialogs: ConversationListItem[]) => {
7467
const now = new Date();
@@ -122,16 +115,13 @@ export function ChatSidebar({
122115
userRole = USER_ROLES.USER,
123116
}: ChatSidebarProps) {
124117
const { t } = useTranslation();
118+
const { confirm } = useConfirmModal();
125119
const router = useRouter();
126120
const { today, week, older } = categorizeDialogs(conversationList);
127121
const [editingId, setEditingId] = useState<number | null>(null);
128122
const [editingTitle, setEditingTitle] = useState("");
129123
const inputRef = useRef<HTMLInputElement>(null);
130124

131-
// Add delete dialog status
132-
const [isDeleteDialogOpen, setIsDeleteDialogOpen] = useState(false);
133-
const [dialogToDelete, setDialogToDelete] = useState<number | null>(null);
134-
135125
const [animationComplete, setAnimationComplete] = useState(false);
136126

137127
useEffect(() => {
@@ -186,19 +176,17 @@ export function ChatSidebar({
186176

187177
// Handle delete click
188178
const handleDeleteClick = (dialogId: number) => {
189-
setDialogToDelete(dialogId);
190-
setIsDeleteDialogOpen(true);
191179
// Close dropdown menus
192180
onDropdownOpenChange(false, null);
193-
};
194181

195-
// Confirm delete
196-
const confirmDelete = () => {
197-
if (dialogToDelete !== null) {
198-
onDelete(dialogToDelete);
199-
setIsDeleteDialogOpen(false);
200-
setDialogToDelete(null);
201-
}
182+
// Show confirmation modal
183+
confirm({
184+
title: t("chatLeftSidebar.confirmDeletionTitle"),
185+
content: t("chatLeftSidebar.confirmDeletionDescription"),
186+
onOk: () => {
187+
onDelete(dialogId);
188+
},
189+
});
202190
};
203191

204192
// Render dialog list items
@@ -439,31 +427,6 @@ export function ChatSidebar({
439427
renderCollapsedSidebar()
440428
)}
441429
</div>
442-
443-
{/* Delete confirmation dialog */}
444-
<Dialog open={isDeleteDialogOpen} onOpenChange={setIsDeleteDialogOpen}>
445-
<DialogContent className="sm:max-w-[425px]">
446-
<DialogHeader>
447-
<DialogTitle>
448-
{t("chatLeftSidebar.confirmDeletionTitle")}
449-
</DialogTitle>
450-
<DialogDescription>
451-
{t("chatLeftSidebar.confirmDeletionDescription")}
452-
</DialogDescription>
453-
</DialogHeader>
454-
<DialogFooter>
455-
<Button
456-
variant="outline"
457-
onClick={() => setIsDeleteDialogOpen(false)}
458-
>
459-
{t("chatLeftSidebar.cancel")}
460-
</Button>
461-
<Button variant="destructive" onClick={confirmDelete}>
462-
{t("chatLeftSidebar.delete")}
463-
</Button>
464-
</DialogFooter>
465-
</DialogContent>
466-
</Dialog>
467430
</>
468431
);
469432
}

0 commit comments

Comments
 (0)