mirror of
https://github.com/Termix-SSH/Termix.git
synced 2026-10-30 23:25:24 +00:00
fix: open plain settings from the profile button, navigation only from the rail menu
This commit is contained in:
1 parent
dbf6c0117f
commit
26a474bb3d
3 files changed
+51
-5
No files matched your search
+20
-2
@@ -238,7 +238,10 @@ import {
|
|||||||
setShellLayoutProvider,
|
setShellLayoutProvider,
|
||||||
} from "@/plugin-host/shell-bridge";
|
} from "@/plugin-host/shell-bridge";
|
||||||
import { PluginViewPlaceholder } from "@/plugin-host/PluginViewPlaceholder";
|
import { PluginViewPlaceholder } from "@/plugin-host/PluginViewPlaceholder";
|
||||||
import { OPEN_PLUGINS_EVENT } from "@/plugins/open-plugins";
|
import {
|
||||||
|
OPEN_PLUGINS_EVENT,
|
||||||
|
OPEN_PLUGIN_SETTINGS_EVENT,
|
||||||
|
} from "@/plugins/open-plugins";
|
||||||
|
|
||||||
export { buildHostTree } from "@/sidebar/build-host-tree";
|
export { buildHostTree } from "@/sidebar/build-host-tree";
|
||||||
export { tabIcon, renderTabContent } from "@/shell/tabUtils";
|
export { tabIcon, renderTabContent } from "@/shell/tabUtils";
|
||||||
@@ -1784,6 +1787,20 @@ export function AppShell({
|
|||||||
return () => window.removeEventListener(OPEN_PLUGINS_EVENT, handler);
|
return () => window.removeEventListener(OPEN_PLUGINS_EVENT, handler);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const handler = (event: Event) => {
|
||||||
|
const pluginId = (event as CustomEvent<string>).detail;
|
||||||
|
if (typeof pluginId !== "string") return;
|
||||||
|
openSingletonTabRef.current("settings", undefined, undefined, {
|
||||||
|
section: `plugin:${pluginId}`,
|
||||||
|
revealAt: Date.now(),
|
||||||
|
});
|
||||||
|
};
|
||||||
|
window.addEventListener(OPEN_PLUGIN_SETTINGS_EVENT, handler);
|
||||||
|
return () =>
|
||||||
|
window.removeEventListener(OPEN_PLUGIN_SETTINGS_EVENT, handler);
|
||||||
|
}, []);
|
||||||
|
|
||||||
const getTabCloseLabel = useCallback((tab: Tab) => {
|
const getTabCloseLabel = useCallback((tab: Tab) => {
|
||||||
return tab.customLabel || tab.label || tab.host?.name || String(tab.id);
|
return tab.customLabel || tab.label || tab.host?.name || String(tab.id);
|
||||||
}, []);
|
}, []);
|
||||||
@@ -2969,7 +2986,8 @@ export function AppShell({
|
|||||||
onRailClick={handleRailClick}
|
onRailClick={handleRailClick}
|
||||||
onOpenTab={openSingletonTab}
|
onOpenTab={openSingletonTab}
|
||||||
onOpenInRightDock={openInRightDock}
|
onOpenInRightDock={openInRightDock}
|
||||||
onOpenSettings={() =>
|
onOpenSettings={() => openSingletonTab("settings")}
|
||||||
|
onOpenNavigationSettings={() =>
|
||||||
openSingletonTab("settings", undefined, undefined, {
|
openSingletonTab("settings", undefined, undefined, {
|
||||||
section: "appearance",
|
section: "appearance",
|
||||||
reveal: "settings-navigation",
|
reveal: "settings-navigation",
|
||||||
|
|||||||
@@ -130,6 +130,7 @@ export function AppRail({
|
|||||||
onOpenTab,
|
onOpenTab,
|
||||||
onOpenInRightDock,
|
onOpenInRightDock,
|
||||||
onOpenSettings,
|
onOpenSettings,
|
||||||
|
onOpenNavigationSettings,
|
||||||
onOpenPalette,
|
onOpenPalette,
|
||||||
onLogout,
|
onLogout,
|
||||||
}: {
|
}: {
|
||||||
@@ -143,6 +144,8 @@ export function AppRail({
|
|||||||
onOpenTab?: (type: TabType) => void;
|
onOpenTab?: (type: TabType) => void;
|
||||||
onOpenInRightDock?: (view: RailView) => void;
|
onOpenInRightDock?: (view: RailView) => void;
|
||||||
onOpenSettings: () => void;
|
onOpenSettings: () => void;
|
||||||
|
/** The rail menu's own entry, which jumps to the navigation settings. */
|
||||||
|
onOpenNavigationSettings: () => void;
|
||||||
onOpenPalette?: () => void;
|
onOpenPalette?: () => void;
|
||||||
onLogout: (options?: { manual?: boolean }) => void;
|
onLogout: (options?: { manual?: boolean }) => void;
|
||||||
}) {
|
}) {
|
||||||
@@ -543,7 +546,7 @@ export function AppRail({
|
|||||||
<MenuItem
|
<MenuItem
|
||||||
icon={<SlidersHorizontal className="size-3" />}
|
icon={<SlidersHorizontal className="size-3" />}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
onOpenSettings();
|
onOpenNavigationSettings();
|
||||||
setMenuPos(null);
|
setMenuPos(null);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { afterEach, describe, expect, it, vi } from "vitest";
|
import { afterEach, describe, expect, it, vi } from "vitest";
|
||||||
import { render, screen } from "@testing-library/react";
|
import { fireEvent, render, screen } from "@testing-library/react";
|
||||||
import userEvent from "@testing-library/user-event";
|
import userEvent from "@testing-library/user-event";
|
||||||
import { Bell, Boxes } from "lucide-react";
|
import { Bell, Boxes } from "lucide-react";
|
||||||
import { AppRail } from "../../sidebar/AppRail";
|
import { AppRail } from "../../sidebar/AppRail";
|
||||||
@@ -36,6 +36,7 @@ function renderRail(onRailClick = vi.fn()) {
|
|||||||
isAdmin={false}
|
isAdmin={false}
|
||||||
onRailClick={onRailClick}
|
onRailClick={onRailClick}
|
||||||
onOpenSettings={vi.fn()}
|
onOpenSettings={vi.fn()}
|
||||||
|
onOpenNavigationSettings={vi.fn()}
|
||||||
onLogout={vi.fn()}
|
onLogout={vi.fn()}
|
||||||
/>,
|
/>,
|
||||||
);
|
);
|
||||||
@@ -117,8 +118,9 @@ describe("AppRail", () => {
|
|||||||
expect(await screen.findByTitle("nav.connections")).toBeTruthy();
|
expect(await screen.findByTitle("nav.connections")).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("opens settings from the account button", async () => {
|
it("opens plain settings from the account button", async () => {
|
||||||
const onOpenSettings = vi.fn();
|
const onOpenSettings = vi.fn();
|
||||||
|
const onOpenNavigationSettings = vi.fn();
|
||||||
render(
|
render(
|
||||||
<AppRail
|
<AppRail
|
||||||
railView="hosts"
|
railView="hosts"
|
||||||
@@ -127,11 +129,34 @@ describe("AppRail", () => {
|
|||||||
isAdmin
|
isAdmin
|
||||||
onRailClick={vi.fn()}
|
onRailClick={vi.fn()}
|
||||||
onOpenSettings={onOpenSettings}
|
onOpenSettings={onOpenSettings}
|
||||||
|
onOpenNavigationSettings={onOpenNavigationSettings}
|
||||||
onLogout={vi.fn()}
|
onLogout={vi.fn()}
|
||||||
/>,
|
/>,
|
||||||
);
|
);
|
||||||
await userEvent.click(screen.getByLabelText("nav.openSettings"));
|
await userEvent.click(screen.getByLabelText("nav.openSettings"));
|
||||||
expect(onOpenSettings).toHaveBeenCalled();
|
expect(onOpenSettings).toHaveBeenCalled();
|
||||||
|
expect(onOpenNavigationSettings).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("opens the navigation settings from the rail menu", async () => {
|
||||||
|
const onOpenSettings = vi.fn();
|
||||||
|
const onOpenNavigationSettings = vi.fn();
|
||||||
|
render(
|
||||||
|
<AppRail
|
||||||
|
railView="hosts"
|
||||||
|
sidebarOpen={false}
|
||||||
|
username="alice"
|
||||||
|
isAdmin
|
||||||
|
onRailClick={vi.fn()}
|
||||||
|
onOpenSettings={onOpenSettings}
|
||||||
|
onOpenNavigationSettings={onOpenNavigationSettings}
|
||||||
|
onLogout={vi.fn()}
|
||||||
|
/>,
|
||||||
|
);
|
||||||
|
fireEvent.contextMenu(screen.getByTitle("nav.connections"));
|
||||||
|
await userEvent.click(screen.getByText("nav.openSettings"));
|
||||||
|
expect(onOpenNavigationSettings).toHaveBeenCalled();
|
||||||
|
expect(onOpenSettings).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user