mirror of
https://github.com/Termix-SSH/Termix.git
synced 2026-07-15 04:43:36 +00:00
feat: add confirmation prompt before closing active session tabs (#793)
Shows a toast confirmation when closing terminal, RDP, VNC or telnet tabs to prevent accidental session loss from misclicks.
This commit is contained in:
+22
-1
@@ -383,7 +383,9 @@ export function AppShell({
|
||||
setActiveTabId(id);
|
||||
}
|
||||
|
||||
function closeTab(id: string) {
|
||||
const SESSION_TAB_TYPES: TabType[] = ["terminal", "rdp", "vnc", "telnet"];
|
||||
|
||||
function doCloseTab(id: string) {
|
||||
terminalRefs.current.delete(id);
|
||||
setTabs((prev) => {
|
||||
const next = prev.filter((t) => t.id !== id);
|
||||
@@ -392,6 +394,25 @@ export function AppShell({
|
||||
});
|
||||
}
|
||||
|
||||
function closeTab(id: string) {
|
||||
const tab = tabs.find((t) => t.id === id);
|
||||
if (tab && SESSION_TAB_TYPES.includes(tab.type)) {
|
||||
toast(t("nav.confirmClose"), {
|
||||
duration: 5000,
|
||||
action: {
|
||||
label: t("nav.close"),
|
||||
onClick: () => doCloseTab(id),
|
||||
},
|
||||
cancel: {
|
||||
label: t("nav.cancel"),
|
||||
onClick: () => {},
|
||||
},
|
||||
});
|
||||
return;
|
||||
}
|
||||
doCloseTab(id);
|
||||
}
|
||||
|
||||
// ─── Rail / sidebar ──────────────────────────────────────────────────────
|
||||
|
||||
function handleRailClick(view: RailView) {
|
||||
|
||||
@@ -385,6 +385,9 @@
|
||||
"newTab": "New Tab",
|
||||
"splitScreen": "Split Screen",
|
||||
"closeTab": "Close Tab",
|
||||
"confirmClose": "Close this active session?",
|
||||
"close": "Close",
|
||||
"cancel": "Cancel",
|
||||
"sshManager": "SSH Manager",
|
||||
"hostManager": "Host Manager",
|
||||
"cannotSplitTab": "Cannot split this tab",
|
||||
|
||||
@@ -555,6 +555,9 @@
|
||||
"newTab": "新选项卡",
|
||||
"splitScreen": "分屏",
|
||||
"closeTab": "关闭选项卡",
|
||||
"confirmClose": "确定关闭当前活跃会话?",
|
||||
"close": "关闭",
|
||||
"cancel": "取消",
|
||||
"sshManager": "SSH 管理器",
|
||||
"hostManager": "主机管理器",
|
||||
"cannotSplitTab": "无法拆分此选项卡",
|
||||
|
||||
Reference in New Issue
Block a user