From f2f8bb13582ebfea44827aeab9c1a32fdfd53610 Mon Sep 17 00:00:00 2001 From: "Pablo F.G" Date: Fri, 17 Jul 2026 12:11:08 +0200 Subject: [PATCH] fix(ui): gate import scan copy gated by cloud --- .../scans-providers-empty-state.test.tsx | 30 ++++++++++++++++++- .../scans/scans-providers-empty-state.tsx | 8 ++++- 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/ui/components/scans/scans-providers-empty-state.test.tsx b/ui/components/scans/scans-providers-empty-state.test.tsx index a0a6c7d438..e6d2817abc 100644 --- a/ui/components/scans/scans-providers-empty-state.test.tsx +++ b/ui/components/scans/scans-providers-empty-state.test.tsx @@ -1,11 +1,15 @@ import { render, screen } from "@testing-library/react"; -import { describe, expect, it } from "vitest"; +import { afterEach, describe, expect, it, vi } from "vitest"; import { ADD_PROVIDER_HREF } from "@/lib/providers-navigation"; import { ScansProvidersEmptyState } from "./scans-providers-empty-state"; describe("ScansProvidersEmptyState", () => { + afterEach(() => { + vi.unstubAllEnvs(); + }); + it("shows the add-provider hint with a providers page CTA when there are no providers", () => { render(); @@ -24,6 +28,30 @@ describe("ScansProvidersEmptyState", () => { expect(cta.tagName).toBe("A"); }); + it("mentions imported scans in the disconnected hint only in Cloud", () => { + vi.stubEnv("NEXT_PUBLIC_IS_CLOUD_ENV", "true"); + + render(); + + expect( + screen.getByText(/imported scans still appear below/i), + ).toBeInTheDocument(); + }); + + it("omits the imported-scans copy in the disconnected hint outside Cloud", () => { + vi.stubEnv("NEXT_PUBLIC_IS_CLOUD_ENV", "false"); + + render(); + + expect( + screen.queryByText(/imported scans still appear below/i), + ).not.toBeInTheDocument(); + // The base guidance still shows so the hint stays actionable. + expect( + screen.getByText(/connect one to launch on-demand scans/i), + ).toBeInTheDocument(); + }); + it("does not render the provider wizard dialog in Scans", () => { render(); diff --git a/ui/components/scans/scans-providers-empty-state.tsx b/ui/components/scans/scans-providers-empty-state.tsx index 7f3afe0559..bc99dca6c0 100644 --- a/ui/components/scans/scans-providers-empty-state.tsx +++ b/ui/components/scans/scans-providers-empty-state.tsx @@ -1,5 +1,6 @@ import { CustomBanner } from "@/components/shadcn/custom/custom-banner"; import { ADD_PROVIDER_HREF } from "@/lib/providers-navigation"; +import { isCloud } from "@/lib/shared/env"; interface ScansProvidersEmptyStateProps { thereIsNoProviders: boolean; @@ -8,6 +9,11 @@ interface ScansProvidersEmptyStateProps { export function ScansProvidersEmptyState({ thereIsNoProviders, }: ScansProvidersEmptyStateProps) { + // Imported scans are Cloud-only, so only Cloud mentions that they stay visible. + const disconnectedMessage = isCloud() + ? "None of your providers are connected yet. Connect one to launch on-demand scans — imported scans still appear below." + : "None of your providers are connected yet. Connect one to launch on-demand scans."; + return thereIsNoProviders ? (