fix: Allow Host Manager button to switch to existing tab instead of being disabled

Changes Host Manager button behavior to match Admin and User Profile tabs:
- Button is always clickable (except during split screen mode)
- If Host Manager tab already exists, clicking switches to it
- If tab doesn't exist, creates new tab and switches to it
- Removes 'Already Open' disabled state and tooltip

This improves UX by allowing users to quickly return to Host Manager tab without needing to manually find and click the tab.
This commit is contained in:
ZacharyZcR
2025-11-09 17:38:21 +08:00
parent 82f1e043ae
commit 2eb6c26c42

View File

@@ -115,7 +115,11 @@ export function LeftSidebar({
Array.isArray(allSplitScreenTab) && allSplitScreenTab.length > 0;
const sshManagerTab = tabList.find((t) => t.type === "ssh_manager");
const openSshManagerTab = () => {
if (sshManagerTab || isSplitScreenActive) return;
if (isSplitScreenActive) return;
if (sshManagerTab) {
setCurrentTab(sshManagerTab.id);
return;
}
const id = addTab({ type: "ssh_manager", title: "Host Manager" });
setCurrentTab(id);
};
@@ -416,13 +420,11 @@ export function LeftSidebar({
className="m-2 flex flex-row font-semibold border-2 !border-dark-border"
variant="outline"
onClick={openSshManagerTab}
disabled={!!sshManagerTab || isSplitScreenActive}
disabled={isSplitScreenActive}
title={
sshManagerTab
? t("interface.sshManagerAlreadyOpen")
: isSplitScreenActive
? t("interface.disabledDuringSplitScreen")
: undefined
isSplitScreenActive
? t("interface.disabledDuringSplitScreen")
: undefined
}
>
<HardDrive strokeWidth="2.5" />