diff --git a/ui/components/sidebar/navigation-mode-toggle.tsx b/ui/components/sidebar/navigation-mode-toggle.tsx
index 8983abdb0d..548c55dbef 100644
--- a/ui/components/sidebar/navigation-mode-toggle.tsx
+++ b/ui/components/sidebar/navigation-mode-toggle.tsx
@@ -19,10 +19,12 @@ export function SidebarNavigationModeToggle({
isOpen,
value,
onChange,
+ chatEnabled = true,
}: {
isOpen: boolean;
value: SidebarNavigationMode;
onChange: (value: SidebarNavigationMode) => void;
+ chatEnabled?: boolean;
}) {
const router = useRouter();
const modes = [
@@ -38,7 +40,8 @@ export function SidebarNavigationModeToggle({
},
] as const;
- const handleModeChange = (mode: SidebarNavigationMode) => {
+ const handleModeChange = (mode: SidebarNavigationMode, disabled: boolean) => {
+ if (disabled) return;
onChange(mode);
if (mode === SIDEBAR_NAVIGATION_MODE.CHAT) {
router.push("/lighthouse");
@@ -56,11 +59,16 @@ export function SidebarNavigationModeToggle({
{modes.map((mode) => {
const Icon = mode.icon;
const active = value === mode.value;
+ const disabled =
+ mode.value === SIDEBAR_NAVIGATION_MODE.CHAT && !chatEnabled;
const button = (
);
- if (isOpen) {
+ const tooltipContent = disabled
+ ? "Available in Prowler Cloud"
+ : !isOpen
+ ? mode.label
+ : null;
+
+ if (!tooltipContent) {
return button;
}
return (
{button}
- {mode.label}
+ {tooltipContent}
);
})}
diff --git a/ui/components/ui/sidebar/menu.test.tsx b/ui/components/ui/sidebar/menu.test.tsx
index 62be707418..01cc4900b5 100644
--- a/ui/components/ui/sidebar/menu.test.tsx
+++ b/ui/components/ui/sidebar/menu.test.tsx
@@ -162,6 +162,19 @@ describe("Menu", () => {
).not.toBeInTheDocument();
expect(screen.getByRole("button", { name: "Home" })).toBeInTheDocument();
});
+
+ it("shows the mode toggle with Chat disabled outside cloud", () => {
+ pathnameValue.current = "/findings";
+ vi.stubEnv("NEXT_PUBLIC_IS_CLOUD_ENV", "false");
+
+ render();
+
+ expect(screen.getByRole("button", { name: "Home" })).toBeInTheDocument();
+ expect(screen.getByRole("button", { name: "Chat" })).toHaveAttribute(
+ "aria-disabled",
+ "true",
+ );
+ });
});
describe("SidebarNavigationModeToggle", () => {
@@ -210,4 +223,34 @@ describe("SidebarNavigationModeToggle", () => {
expect(onChange).toHaveBeenCalledWith(SIDEBAR_NAVIGATION_MODE.BROWSE);
expect(pushMock).not.toHaveBeenCalled();
});
+
+ it("blocks Chat and shows the cloud tooltip when chat is unavailable", async () => {
+ // Given
+ const user = userEvent.setup();
+ const onChange = vi.fn();
+
+ render(
+ ,
+ );
+
+ // When
+ const chatButton = screen.getByRole("button", { name: "Chat" });
+ await user.hover(chatButton);
+
+ // Then
+ const tooltip = await screen.findByRole("tooltip");
+ expect(tooltip).toHaveTextContent("Available in Prowler Cloud");
+
+ // When
+ await user.click(chatButton);
+
+ // Then
+ expect(onChange).not.toHaveBeenCalled();
+ expect(pushMock).not.toHaveBeenCalled();
+ });
});
diff --git a/ui/components/ui/sidebar/menu.tsx b/ui/components/ui/sidebar/menu.tsx
index 454e0932a2..76ae3e2765 100644
--- a/ui/components/ui/sidebar/menu.tsx
+++ b/ui/components/ui/sidebar/menu.tsx
@@ -116,13 +116,12 @@ export const Menu = ({ isOpen }: { isOpen: boolean }) => {
- {isCloudEnv && (
-
- )}
+
{/* Menu Items */}