diff --git a/site/e2e/tests/deployment/appearance.spec.ts b/site/e2e/tests/deployment/appearance.spec.ts index c2b129c632..83b743814e 100644 --- a/site/e2e/tests/deployment/appearance.spec.ts +++ b/site/e2e/tests/deployment/appearance.spec.ts @@ -83,6 +83,7 @@ test("set service banner", async ({ page }) => { await page.goto("/workspaces", { waitUntil: "domcontentloaded" }); await expectUrl(page).toHavePathName("/workspaces"); - const bar = page.locator("div.service-banner", { hasText: message }); - await expect(bar).toBeVisible(); + const banner = page.getByTestId("service-banner"); + await expect(banner).toBeVisible(); + await expect(banner).toHaveText(message); }); diff --git a/site/src/modules/dashboard/AnnouncementBanners/AnnouncementBannerView.tsx b/site/src/modules/dashboard/AnnouncementBanners/AnnouncementBannerView.tsx index 84df0b9796..f26e85709d 100644 --- a/site/src/modules/dashboard/AnnouncementBanners/AnnouncementBannerView.tsx +++ b/site/src/modules/dashboard/AnnouncementBanners/AnnouncementBannerView.tsx @@ -1,29 +1,24 @@ -import { css, type Interpolation, type Theme } from "@emotion/react"; import { InlineMarkdown } from "components/Markdown/Markdown"; import type { FC } from "react"; import { readableForegroundColor } from "utils/colors"; interface AnnouncementBannerViewProps { - message?: string; - backgroundColor?: string; + message: string; + backgroundColor: string; } export const AnnouncementBannerView: FC = ({ message, backgroundColor, }) => { - if (!message || !backgroundColor) { - return null; - } - return (
{message} @@ -31,20 +26,3 @@ export const AnnouncementBannerView: FC = ({
); }; - -const styles = { - banner: css` - padding: 12px; - display: flex; - align-items: center; - `, - wrapper: css` - margin-right: auto; - margin-left: auto; - font-weight: 400; - - & a { - color: inherit; - } - `, -} satisfies Record>; diff --git a/site/src/modules/dashboard/AnnouncementBanners/AnnouncementBanners.tsx b/site/src/modules/dashboard/AnnouncementBanners/AnnouncementBanners.tsx index a962c291d1..1e4411edf7 100644 --- a/site/src/modules/dashboard/AnnouncementBanners/AnnouncementBanners.tsx +++ b/site/src/modules/dashboard/AnnouncementBanners/AnnouncementBanners.tsx @@ -1,3 +1,4 @@ +import type { BannerConfig } from "api/typesGenerated"; import { useDashboard } from "modules/dashboard/useDashboard"; import type { FC } from "react"; import { AnnouncementBannerView } from "./AnnouncementBannerView"; @@ -15,7 +16,12 @@ export const AnnouncementBanners: FC = () => { return ( <> {announcementBanners - .filter((banner) => banner.enabled) + .filter( + (banner): banner is Required => + banner.enabled && + Boolean(banner.message) && + Boolean(banner.background_color), + ) .map((banner) => (