Skip to content

The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:

Update Security Center promo card layout (#73918)

Stas Gavryloved54e5c079d1
diff --git a/enterprise/frontend/src/metabase-enterprise/security_center/components/SecurityCenterBanner/SecurityCenterBanner.tsx b/enterprise/frontend/src/metabase-enterprise/security_center/components/SecurityCenterBanner/SecurityCenterBanner.tsx
index e947f34df9e..f91b7681b63 100644
--- a/enterprise/frontend/src/metabase-enterprise/security_center/components/SecurityCenterBanner/SecurityCenterBanner.tsx
+++ b/enterprise/frontend/src/metabase-enterprise/security_center/components/SecurityCenterBanner/SecurityCenterBanner.tsx
@@ -1,4 +1,3 @@
-import { useCallback, useState } from "react";
import { Link } from "react-router";
import { jt, t } from "ttag";
@@ -13,21 +12,6 @@ import { Anchor, Text } from "metabase/ui";
import { isAffected } from "../../utils";
-const DISMISSED_KEY = "security-center-banner-dismissed";
-
-function useDismissed() {
- const [dismissed, setDismissedState] = useState(
- () => localStorage.getItem(DISMISSED_KEY) === "true",
- );
-
- const dismiss = useCallback(() => {
- localStorage.setItem(DISMISSED_KEY, "true");
- setDismissedState(true);
- }, []);
-
- return { dismissed, dismiss };
-}
-
export function SecurityCenterBanner() {
const tokenFeatures = useSetting("token-features");
const plan = getPlan(tokenFeatures);
@@ -35,7 +19,6 @@ export function SecurityCenterBanner() {
useGetChannelInfoQuery();
const { data: advisoriesResponse, isLoading: isAdvisoriesLoading } =
useListSecurityAdvisoriesQuery();
- const { dismissed, dismiss } = useDismissed();
if (plan !== "pro-self-hosted") {
return null;
@@ -55,7 +38,7 @@ export function SecurityCenterBanner() {
const advisories = advisoriesResponse?.advisories ?? [];
const hasActiveAdvisory = advisories.some(isAffected);
- if (dismissed && !hasActiveAdvisory) {
+ if (!hasActiveAdvisory) {
return null;
}
@@ -75,30 +58,12 @@ export function SecurityCenterBanner() {
// eslint-disable-next-line metabase/no-literal-metabase-strings -- only visible to admins on self-hosted instances
const body = jt`Please configure notification channels in the ${securityCenterLink} so that you get notified about security vulnerabilities in your Metabase instance`;
- if (hasActiveAdvisory) {
- return (
- <Banner
- contentGroupProps={{ wrap: "nowrap" }}
- icon="warning_round_filled"
- bg="error"
- body={<Text lh="inherit">{body}</Text>}
- py="md"
- />
- );
- }
-
return (
<Banner
contentGroupProps={{ wrap: "nowrap" }}
icon="warning_round_filled"
- bg="warning"
- body={
- <Text lh="inherit" c="text-primary">
- {body}
- </Text>
- }
- closable
- onClose={dismiss}
+ bg="error"
+ body={<Text lh="inherit">{body}</Text>}
py="md"
/>
);
diff --git a/enterprise/frontend/src/metabase-enterprise/security_center/components/SecurityCenterBanner/SecurityCenterBanner.unit.spec.tsx b/enterprise/frontend/src/metabase-enterprise/security_center/components/SecurityCenterBanner/SecurityCenterBanner.unit.spec.tsx
index 8cf7fbb9609..ed5d15d4e73 100644
--- a/enterprise/frontend/src/metabase-enterprise/security_center/components/SecurityCenterBanner/SecurityCenterBanner.unit.spec.tsx
+++ b/enterprise/frontend/src/metabase-enterprise/security_center/components/SecurityCenterBanner/SecurityCenterBanner.unit.spec.tsx
@@ -14,8 +14,6 @@ import { createAdvisory } from "metabase-types/api/mocks/security-center";
import { SecurityCenterBanner } from "./SecurityCenterBanner";
-const DISMISSED_KEY = "security-center-banner-dismissed";
-
interface SetupOpts {
isProSelfHosted?: boolean;
emailConfigured?: boolean;
@@ -60,22 +58,16 @@ function setup({
}
describe("SecurityCenterBanner", () => {
- afterEach(() => {
- localStorage.removeItem(DISMISSED_KEY);
- });
-
- it("renders warning banner when no channels are configured", async () => {
+ it("does not render when there is no active advisory", async () => {
setup();
- expect(
- await screen.findByText(/Please configure notification channels/),
- ).toBeInTheDocument();
+ await screen.findByText(() => false).catch(() => {});
+ expect(screen.queryByTestId("app-banner")).not.toBeInTheDocument();
});
it("does not render when email is configured", async () => {
setup({ emailConfigured: true });
- // Wait for API responses to settle, then assert no banner
await screen.findByText(() => false).catch(() => {});
expect(screen.queryByTestId("app-banner")).not.toBeInTheDocument();
});
@@ -104,47 +96,20 @@ describe("SecurityCenterBanner", () => {
).toBeInTheDocument();
});
- it("is dismissible when there are no active advisories", async () => {
- setup();
-
- await screen.findByTestId("app-banner");
- expect(screen.getByLabelText("close icon")).toBeInTheDocument();
- });
-
- it("is not dismissible when there are active advisories", async () => {
+ it("is not dismissible", async () => {
setup({
advisories: [createAdvisory({ match_status: "active" })],
});
- // Wait for the error banner text to confirm advisory data has loaded
await screen.findByText(/Please configure notification channels/);
expect(screen.queryByLabelText("close icon")).not.toBeInTheDocument();
});
- it("stays hidden after dismissal when there are no active advisories", async () => {
- localStorage.setItem(DISMISSED_KEY, "true");
-
- setup();
-
- await screen.findByText(() => false).catch(() => {});
- expect(screen.queryByTestId("app-banner")).not.toBeInTheDocument();
- });
-
- it("shows banner despite dismissal when there are active advisories", async () => {
- localStorage.setItem(DISMISSED_KEY, "true");
-
+ it("includes a link to security center notification settings", async () => {
setup({
advisories: [createAdvisory({ match_status: "active" })],
});
- expect(
- await screen.findByText(/Please configure notification channels/),
- ).toBeInTheDocument();
- });
-
- it("includes a link to security center notification settings", async () => {
- setup();
-
const link = await screen.findByText("Security center");
expect(link).toHaveAttribute(
"href",
diff --git a/enterprise/frontend/src/metabase-enterprise/security_center/components/SecurityCenterPromoCard/SecurityCenterPromoCard.tsx b/enterprise/frontend/src/metabase-enterprise/security_center/components/SecurityCenterPromoCard/SecurityCenterPromoCard.tsx
new file mode 100644
index 00000000000..76fa9674c6b
--- /dev/null
+++ b/enterprise/frontend/src/metabase-enterprise/security_center/components/SecurityCenterPromoCard/SecurityCenterPromoCard.tsx
@@ -0,0 +1,84 @@
+import { useCallback, useState } from "react";
+import { t } from "ttag";
+
+import {
+ useGetChannelInfoQuery,
+ useListSecurityAdvisoriesQuery,
+} from "metabase/api";
+import { useSetting } from "metabase/common/hooks";
+import { getPlan } from "metabase/common/utils/plan";
+import { NavbarPromoCard } from "metabase/nav/components/NavbarPromoCard";
+import { Icon } from "metabase/ui";
+
+import { isAffected } from "../../utils";
+
+const DISMISSED_KEY = "security-center-promo-dismissed";
+
+function useDismissed() {
+ const [dismissed, setDismissedState] = useState(
+ () => localStorage.getItem(DISMISSED_KEY) === "true",
+ );
+
+ const dismiss = useCallback(() => {
+ localStorage.setItem(DISMISSED_KEY, "true");
+ setDismissedState(true);
+ }, []);
+
+ return { dismissed, dismiss };
+}
+
+export function SecurityCenterPromoCard() {
+ const tokenFeatures = useSetting("token-features");
+ const plan = getPlan(tokenFeatures);
+ const { data: channelInfo, isLoading: isChannelInfoLoading } =
+ useGetChannelInfoQuery();
+ const { data: advisoriesResponse, isLoading: isAdvisoriesLoading } =
+ useListSecurityAdvisoriesQuery();
+ const { dismissed, dismiss } = useDismissed();
+
+ if (plan !== "pro-self-hosted") {
+ return null;
+ }
+
+ if (isChannelInfoLoading || isAdvisoriesLoading) {
+ return null;
+ }
+
+ const hasEmail = !!channelInfo?.channels?.email?.configured;
+ const hasSlack = !!channelInfo?.channels?.slack?.configured;
+
+ if (hasEmail || hasSlack) {
+ return null;
+ }
+
+ const advisories = advisoriesResponse?.advisories ?? [];
+ const hasActiveAdvisory = advisories.some(isAffected);
+
+ // Active advisories are shown in the red top-of-page banner instead.
+ if (hasActiveAdvisory) {
+ return null;
+ }
+
+ if (dismissed) {
+ return null;
+ }
+
+ return (
+ <NavbarPromoCard
+ icon={
+ <Icon
+ name="shield_stroke"
+ height={24}
+ width={24}
+ style={{ stroke: "var(--mb-color-brand)", fill: "transparent" }}
+ />
+ }
+ title={t`Stay safe with security alerts`}
+ // eslint-disable-next-line metabase/no-literal-metabase-strings -- This only shows for admins
+ body={t`Metabase's Security Center can send you alerts via email or Slack immediately about security vulnerabilities.`}
+ linkText={t`Set up security alerts`}
+ linkTo="/admin/security-center?open=notifications"
+ onDismiss={dismiss}
+ />
+ );
+}
diff --git a/enterprise/frontend/src/metabase-enterprise/security_center/components/SecurityCenterPromoCard/SecurityCenterPromoCard.unit.spec.tsx b/enterprise/frontend/src/metabase-enterprise/security_center/components/SecurityCenterPromoCard/SecurityCenterPromoCard.unit.spec.tsx
new file mode 100644
index 00000000000..aa5ca05dbc8
--- /dev/null
+++ b/enterprise/frontend/src/metabase-enterprise/security_center/components/SecurityCenterPromoCard/SecurityCenterPromoCard.unit.spec.tsx
@@ -0,0 +1,141 @@
+import fetchMock from "fetch-mock";
+import { Route } from "react-router";
+
+import { setupNotificationChannelsEndpoints } from "__support__/server-mocks";
+import { mockSettings } from "__support__/settings";
+import { renderWithProviders, screen, waitFor } from "__support__/ui";
+import { createMockState } from "metabase/redux/store/mocks";
+import type { Advisory } from "metabase-types/api";
+import {
+ createMockTokenFeatures,
+ createMockUser,
+} from "metabase-types/api/mocks";
+import { createAdvisory } from "metabase-types/api/mocks/security-center";
+
+import { SecurityCenterPromoCard } from "./SecurityCenterPromoCard";
+
+const DISMISSED_KEY = "security-center-promo-dismissed";
+
+interface SetupOpts {
+ isProSelfHosted?: boolean;
+ emailConfigured?: boolean;
+ slackConfigured?: boolean;
+ advisories?: Advisory[];
+}
+
+function setup({
+ isProSelfHosted = true,
+ emailConfigured = false,
+ slackConfigured = false,
+ advisories = [],
+}: SetupOpts = {}) {
+ const tokenFeatures = createMockTokenFeatures(
+ isProSelfHosted
+ ? { advanced_permissions: true, hosting: false }
+ : { hosting: false },
+ );
+
+ setupNotificationChannelsEndpoints({
+ email: { configured: emailConfigured } as any,
+ slack: { configured: slackConfigured } as any,
+ });
+
+ fetchMock.get("path:/api/ee/security-center", {
+ last_checked_at: null,
+ advisories,
+ });
+
+ const state = createMockState({
+ currentUser: createMockUser({ is_superuser: true }),
+ settings: mockSettings({
+ "token-features": tokenFeatures,
+ }),
+ });
+
+ renderWithProviders(<Route path="*" component={SecurityCenterPromoCard} />, {
+ initialRoute: "/",
+ storeInitialState: state,
+ withRouter: true,
+ });
+}
+
+describe("SecurityCenterPromoCard", () => {
+ afterEach(() => {
+ localStorage.removeItem(DISMISSED_KEY);
+ });
+
+ it("renders the promo when no channels are configured and no active advisory", async () => {
+ setup();
+
+ expect(
+ await screen.findByText(/Stay safe with security alerts/),
+ ).toBeInTheDocument();
+ expect(
+ screen.getByRole("link", { name: /Set up security alerts/i }),
+ ).toHaveAttribute("href", "/admin/security-center?open=notifications");
+ });
+
+ it("does not render when email is configured", async () => {
+ setup({ emailConfigured: true });
+
+ await screen.findByText(() => false).catch(() => {});
+ expect(
+ screen.queryByText(/Stay safe with security alerts/),
+ ).not.toBeInTheDocument();
+ });
+
+ it("does not render when slack is configured", async () => {
+ setup({ slackConfigured: true });
+
+ await screen.findByText(() => false).catch(() => {});
+ expect(
+ screen.queryByText(/Stay safe with security alerts/),
+ ).not.toBeInTheDocument();
+ });
+
+ it("does not render for non-pro-self-hosted plans", async () => {
+ setup({ isProSelfHosted: false });
+
+ await screen.findByText(() => false).catch(() => {});
+ expect(
+ screen.queryByText(/Stay safe with security alerts/),
+ ).not.toBeInTheDocument();
+ });
+
+ it("does not render when there is an active advisory (red banner takes over)", async () => {
+ setup({
+ advisories: [createAdvisory({ match_status: "active" })],
+ });
+
+ await screen.findByText(() => false).catch(() => {});
+ expect(
+ screen.queryByText(/Stay safe with security alerts/),
+ ).not.toBeInTheDocument();
+ });
+
+ it("is dismissible", async () => {
+ setup();
+
+ await screen.findByText(/Stay safe with security alerts/);
+ const close = screen.getByRole("button", { name: /close/i });
+ close.click();
+
+ await waitFor(() => {
+ expect(
+ screen.queryByText(/Stay safe with security alerts/),
+ ).not.toBeInTheDocument();
+ });
+ expect(localStorage.getItem(DISMISSED_KEY)).toBe("true");
+ });
+
+ it("stays hidden after dismissal", async () => {
+ localStorage.setItem(DISMISSED_KEY, "true");
+
+ setup();
+
+ await screen.findByText(() => false).catch(() => {});
+ expect(
+ screen.queryByText(/Stay safe with security alerts/),
+ ).not.toBeInTheDocument();
+ });
+});
diff --git a/enterprise/frontend/src/metabase-enterprise/security_center/index.ts b/enterprise/frontend/src/metabase-enterprise/security_center/index.ts
index d96a034ed8c..de03cb4e2fb 100644
--- a/enterprise/frontend/src/metabase-enterprise/security_center/index.ts
+++ b/enterprise/frontend/src/metabase-enterprise/security_center/index.ts
@@ -5,12 +5,14 @@ import { SecurityCenterBanner } from "./components/SecurityCenterBanner/Security
import { SecurityCenterMobileNavItem } from "./components/SecurityCenterNavItem/SecurityCenterMobileNavItem";
import { SecurityCenterNavItem } from "./components/SecurityCenterNavItem/SecurityCenterNavItem";
import { SecurityCenterPage } from "./components/SecurityCenterPage/SecurityCenterPage";
+import { SecurityCenterPromoCard } from "./components/SecurityCenterPromoCard/SecurityCenterPromoCard";
export function initializePlugin() {
if (hasPremiumFeature("admin_security_center")) {
PLUGIN_SECURITY_CENTER.isEnabled = true;
PLUGIN_SECURITY_CENTER.SecurityCenterPage = SecurityCenterPage;
PLUGIN_SECURITY_CENTER.SecurityCenterBanner = SecurityCenterBanner;
+ PLUGIN_SECURITY_CENTER.SecurityCenterPromoCard = SecurityCenterPromoCard;
PLUGIN_SECURITY_CENTER.SecurityCenterNavItem = SecurityCenterNavItem;
PLUGIN_SECURITY_CENTER.SecurityCenterMobileNavItem =
SecurityCenterMobileNavItem;
diff --git a/frontend/src/metabase-types/api/icon.ts b/frontend/src/metabase-types/api/icon.ts
index 7ceff900df4..f1adb5bde2a 100644
--- a/frontend/src/metabase-types/api/icon.ts
+++ b/frontend/src/metabase-types/api/icon.ts
@@ -234,6 +234,7 @@ export type IconName =
| "segment"
| "shield"
| "shield_outline"
+ | "shield_stroke"
| "sidebar_closed"
| "sidebar_open"
| "slack"
diff --git a/frontend/src/metabase/admin/settings/components/SettingsNav/SettingsNav.tsx b/frontend/src/metabase/admin/settings/components/SettingsNav/SettingsNav.tsx
index 64b297547ab..b605737066a 100644
--- a/frontend/src/metabase/admin/settings/components/SettingsNav/SettingsNav.tsx
+++ b/frontend/src/metabase/admin/settings/components/SettingsNav/SettingsNav.tsx
@@ -4,10 +4,10 @@ import { AdminNavWrapper } from "metabase/admin/components/AdminNav";
import { UpsellGem } from "metabase/common/components/upsells/components/UpsellGem";
import { useHasTokenFeature, useSetting } from "metabase/common/hooks";
import { getPlan, isProPlan } from "metabase/common/utils/plan";
-import { PLUGIN_REMOTE_SYNC } from "metabase/plugins";
+import { PLUGIN_REMOTE_SYNC, PLUGIN_SECURITY_CENTER } from "metabase/plugins";
import { useSelector } from "metabase/redux";
import { getUserIsAdmin } from "metabase/selectors/user";
-import { Divider, Flex } from "metabase/ui";
+import { Box, Divider, Flex } from "metabase/ui";
import { CustomVisualizationsNav } from "./CustomVisualizationsNav";
import { SettingsNavItem } from "./SettingsNavItem";
@@ -27,6 +27,8 @@ export function SettingsNav() {
const tokenFeatures = useSetting("token-features");
const isAdmin = useSelector(getUserIsAdmin);
const isPro = isProPlan(getPlan(tokenFeatures));
+ const { isEnabled: isSecurityCenterEnabled, SecurityCenterPromoCard } =
+ PLUGIN_SECURITY_CENTER;
return (
<AdminNavWrapper>
@@ -130,6 +132,17 @@ export function SettingsNav() {
}
icon="cloud"
/>
+ {isSecurityCenterEnabled && (
+ <Box
+ pos="sticky"
+ bottom={0}
+ pt="md"
+ bg="background-primary"
+ style={{ marginTop: "auto", zIndex: 1 }}
+ >
+ <SecurityCenterPromoCard />
+ </Box>
+ )}
</AdminNavWrapper>
);
}
diff --git a/frontend/src/metabase/admin/settings/tests/setup.tsx b/frontend/src/metabase/admin/settings/tests/setup.tsx
index 04a9fe1d6d5..8f81db84f7c 100644
--- a/frontend/src/metabase/admin/settings/tests/setup.tsx
+++ b/frontend/src/metabase/admin/settings/tests/setup.tsx
@@ -12,6 +12,7 @@ import {
setupDatabasesEndpoints,
setupEmailEndpoints,
setupGroupsEndpoint,
+ setupNotificationChannelsEndpoints,
setupPropertiesEndpoints,
setupSettingEndpoint,
setupSettingsEndpoints,
@@ -161,6 +162,14 @@ export const setup = async ({
value: true,
});
+ setupNotificationChannelsEndpoints({
+ email: { configured: false } as any,
+ slack: { configured: false } as any,
+ });
+ fetchMock.get("path:/api/ee/security-center", {
+ last_checked_at: null,
+ advisories: [],
+ });
fetchMock.get("path:/api/cloud-migration", { status: 204 });
fetchMock.get("path:/api/ee/sso/oidc", []);
fetchMock.get("path:/api/ee/remote-sync/dirty", {
diff --git a/frontend/src/metabase/api/slack.ts b/frontend/src/metabase/api/slack.ts
index f7f81288241..24081d92643 100644
--- a/frontend/src/metabase/api/slack.ts
+++ b/frontend/src/metabase/api/slack.ts
@@ -1,6 +1,7 @@
import type { SlackAppInfo, SlackSettings } from "metabase-types/api";
import { Api } from "./api";
+import { listTag } from "./tags";
export const slackApi = Api.injectEndpoints({
endpoints: (builder) => ({
@@ -23,7 +24,11 @@ export const slackApi = Api.injectEndpoints({
url: `/api/slack/settings`,
body: settings,
}),
- invalidatesTags: ["session-properties", "slack-app-info"],
+ invalidatesTags: [
+ "session-properties",
+ "slack-app-info",
+ listTag("subscription-channel"),
+ ],
}),
}),
});
diff --git a/frontend/src/metabase/nav/components/NavbarPromoCard/NavbarPromoCard.module.css b/frontend/src/metabase/nav/components/NavbarPromoCard/NavbarPromoCard.module.css
new file mode 100644
index 00000000000..412f5e01225
--- /dev/null
+++ b/frontend/src/metabase/nav/components/NavbarPromoCard/NavbarPromoCard.module.css
@@ -0,0 +1,19 @@
+.IconWrapper {
+ display: inline-flex;
+ align-items: center;
+ justify-content: center;
+ flex-shrink: 0;
+ color: var(--mb-color-brand);
+}
+
+.DismissIconButtonWrapper {
+ color: var(--mb-color-text-tertiary);
+}
+
+.DismissIconButtonWrapper:hover {
+ color: var(--mb-color-text-secondary);
+}
+
+.Body {
+ color: var(--mb-color-text-secondary);
+}
diff --git a/frontend/src/metabase/nav/components/NavbarPromoCard/NavbarPromoCard.tsx b/frontend/src/metabase/nav/components/NavbarPromoCard/NavbarPromoCard.tsx
new file mode 100644
index 00000000000..08ed95b431e
--- /dev/null
+++ b/frontend/src/metabase/nav/components/NavbarPromoCard/NavbarPromoCard.tsx
@@ -0,0 +1,76 @@
+import type { ReactNode } from "react";
+import { Link } from "react-router";
+
+import { IconButtonWrapper } from "metabase/common/components/IconButtonWrapper";
+import { Anchor, Flex, Icon, Paper, Stack, Text } from "metabase/ui";
+
+import S from "./NavbarPromoCard.module.css";
+
+type LinkTarget =
+ | { linkTo: string; linkHref?: never }
+ | { linkHref: string; linkTo?: never };
+
+type Props = {
+ icon: ReactNode;
+ title: string;
+ body?: ReactNode;
+ linkText: string;
+ onDismiss?: () => void;
+ external?: boolean;
+} & LinkTarget;
+
+export function NavbarPromoCard({
+ icon,
+ title,
+ body,
+ linkText,
+ linkTo,
+ linkHref,
+ onDismiss,
+ external,
+}: Props) {
+ return (
+ <Paper p="md" shadow="md" withBorder>
+ <Stack gap="sm">
+ <Flex justify="space-between" align="flex-start">
+ <span className={S.IconWrapper}>{icon}</span>
+ {onDismiss && (
+ <IconButtonWrapper
+ className={S.DismissIconButtonWrapper}
+ onClick={onDismiss}
+ >
+ <Icon name="close" />
+ </IconButtonWrapper>
+ )}
+ </Flex>
+
+ <Stack gap={4}>
+ <Text fw="bold" size="sm">
+ {title}
+ </Text>
+ {body && (
+ <Text className={S.Body} size="sm">
+ {body}
+ </Text>
+ )}
+ </Stack>
+
+ {linkHref ? (
+ <Anchor
+ component="a"
+ href={linkHref}
+ size="sm"
+ fw="bold"
+ {...(external ? { target: "_blank", rel: "noreferrer" } : {})}
+ >
+ {linkText}
+ </Anchor>
+ ) : (
+ <Anchor component={Link} to={linkTo as string} size="sm" fw="bold">
+ {linkText}
+ </Anchor>
+ )}
+ </Stack>
+ </Paper>
+ );
+}
diff --git a/frontend/src/metabase/nav/components/NavbarPromoCard/index.ts b/frontend/src/metabase/nav/components/NavbarPromoCard/index.ts
new file mode 100644
index 00000000000..4acfc51f6ec
--- /dev/null
+++ b/frontend/src/metabase/nav/components/NavbarPromoCard/index.ts
@@ -0,0 +1 @@
+export { NavbarPromoCard } from "./NavbarPromoCard";
diff --git a/frontend/src/metabase/nav/components/NavbarPromoSlot/NavbarPromoSlot.module.css b/frontend/src/metabase/nav/components/NavbarPromoSlot/NavbarPromoSlot.module.css
new file mode 100644
index 00000000000..bbba1abecba
--- /dev/null
+++ b/frontend/src/metabase/nav/components/NavbarPromoSlot/NavbarPromoSlot.module.css
@@ -0,0 +1,15 @@
+.PromoSlot {
+ position: sticky;
+ bottom: 0;
+ display: flex;
+ flex-direction: column;
+ gap: var(--mantine-spacing-md);
+ padding: var(--mantine-spacing-md) var(--mantine-spacing-md)
+ calc(var(--mantine-spacing-md) * 2);
+ background-color: var(--mb-color-background-primary);
+ z-index: 1;
+}
+
+.PromoSlot:empty {
+ display: none;
+}
diff --git a/frontend/src/metabase/nav/components/NavbarPromoSlot/NavbarPromoSlot.tsx b/frontend/src/metabase/nav/components/NavbarPromoSlot/NavbarPromoSlot.tsx
new file mode 100644
index 00000000000..13a03f264e4
--- /dev/null
+++ b/frontend/src/metabase/nav/components/NavbarPromoSlot/NavbarPromoSlot.tsx
@@ -0,0 +1,15 @@
+import { WhatsNewNotification } from "metabase/nav/components/WhatsNewNotification";
+import { PLUGIN_SECURITY_CENTER } from "metabase/plugins";
+
+import S from "./NavbarPromoSlot.module.css";
+
+export function NavbarPromoSlot() {
+ const { SecurityCenterPromoCard } = PLUGIN_SECURITY_CENTER;
+
+ return (
+ <div className={S.PromoSlot}>
+ <SecurityCenterPromoCard />
+ <WhatsNewNotification />
+ </div>
+ );
+}
diff --git a/frontend/src/metabase/nav/components/NavbarPromoSlot/index.ts b/frontend/src/metabase/nav/components/NavbarPromoSlot/index.ts
new file mode 100644
index 00000000000..3eb054e0a27
--- /dev/null
+++ b/frontend/src/metabase/nav/components/NavbarPromoSlot/index.ts
@@ -0,0 +1 @@
+export { NavbarPromoSlot } from "./NavbarPromoSlot";
diff --git a/frontend/src/metabase/nav/components/WhatsNewNotification/WhatsNewNotification.module.css b/frontend/src/metabase/nav/components/WhatsNewNotification/WhatsNewNotification.module.css
deleted file mode 100644
index 78b29b2c6f9..00000000000
--- a/frontend/src/metabase/nav/components/WhatsNewNotification/WhatsNewNotification.module.css
+++ /dev/null
@@ -1,7 +0,0 @@
-.DismissIconButtonWrapper {
- color: var(--mb-color-background-tertiary);
-}
-
-.DismissIconButtonWrapper:hover {
- color: var(--mb-color-text-secondary);
-}
diff --git a/frontend/src/metabase/nav/components/WhatsNewNotification/WhatsNewNotification.tsx b/frontend/src/metabase/nav/components/WhatsNewNotification/WhatsNewNotification.tsx
index 12b2d18da93..8bcbe53271f 100644
--- a/frontend/src/metabase/nav/components/WhatsNewNotification/WhatsNewNotification.tsx
+++ b/frontend/src/metabase/nav/components/WhatsNewNotification/WhatsNewNotification.tsx
@@ -2,16 +2,13 @@ import { useCallback, useMemo } from "react";
import { t } from "ttag";
import { useGetVersionInfoQuery } from "metabase/api";
-import { IconButtonWrapper } from "metabase/common/components/IconButtonWrapper";
import { useSetting } from "metabase/common/hooks";
+import { NavbarPromoCard } from "metabase/nav/components/NavbarPromoCard";
import { useDispatch, useSelector } from "metabase/redux";
import { updateSetting } from "metabase/redux/settings";
import { getIsEmbeddingIframe } from "metabase/selectors/embed";
import { getIsWhiteLabeling } from "metabase/selectors/whitelabel";
-import { Anchor, Flex, Icon, Paper, Stack, Text } from "metabase/ui";
-import { color } from "metabase/ui/utils/colors";
-import S from "./WhatsNewNotification.module.css";
import Sparkles from "./sparkles.svg?component";
import { getLatestEligibleReleaseNotes } from "./utils";
@@ -53,33 +50,16 @@ export function WhatsNewNotification() {
if (!url) {
return null;
}
- return (
- <Paper my="lg" mx="auto" p="md" shadow="md" withBorder w={244}>
- <Stack gap="sm">
- <Flex justify="space-between">
- <Sparkles color={color("brand")} />
- <IconButtonWrapper
- className={S.DismissIconButtonWrapper}
- onClick={dismiss}
- >
- <Icon name="close" />
- </IconButtonWrapper>
- </Flex>
-
- {/* eslint-disable-next-line metabase/no-literal-metabase-strings -- This only shows for admins */}
- <Text fw="bold" size="sm">{t`Metabase has been updated`}</Text>
- <Anchor
- size="sm"
- fw="bold"
- component="a"
- href={url}
- target="_blank"
- rel="noreferrer"
- >
- {t`See what's new`}
- </Anchor>
- </Stack>
- </Paper>
+ return (
+ <NavbarPromoCard
+ icon={<Sparkles />}
+ // eslint-disable-next-line metabase/no-literal-metabase-strings -- This only shows for admins
+ title={t`Metabase has been updated`}
+ linkText={t`See what's new`}
+ linkHref={url}
+ external
+ onDismiss={dismiss}
+ />
);
}
diff --git a/frontend/src/metabase/nav/containers/MainNavbar/MainNavbar.styled.tsx b/frontend/src/metabase/nav/containers/MainNavbar/MainNavbar.styled.tsx
index 105f64f4e0a..b1e005dfc61 100644
--- a/frontend/src/metabase/nav/containers/MainNavbar/MainNavbar.styled.tsx
+++ b/frontend/src/metabase/nav/containers/MainNavbar/MainNavbar.styled.tsx
@@ -50,7 +50,7 @@ export const NavRoot = styled.nav<{ isOpen: boolean }>`
overflow-y: auto;
${breakpointMinSmall} {
- width: ${(props) => (props.isOpen ? NAV_SIDEBAR_WIDTH : 0)};
+ width: ${(props) => (props.isOpen ? "100%" : 0)};
}
${breakpointMaxSmall} {
diff --git a/frontend/src/metabase/nav/containers/MainNavbar/MainNavbar.tsx b/frontend/src/metabase/nav/containers/MainNavbar/MainNavbar.tsx
index d4953f2e65b..07188ab5f3a 100644
--- a/frontend/src/metabase/nav/containers/MainNavbar/MainNavbar.tsx
+++ b/frontend/src/metabase/nav/containers/MainNavbar/MainNavbar.tsx
@@ -9,6 +9,7 @@ import {
useGetCollectionQuery,
} from "metabase/api";
import { getDashboard } from "metabase/dashboard/selectors";
+import { NavbarPromoSlot } from "metabase/nav/components/NavbarPromoSlot";
import { connect } from "metabase/redux";
import { closeNavbar, openNavbar } from "metabase/redux/app";
import type { State } from "metabase/redux/store";
@@ -139,6 +140,7 @@ function MainNavbar({
onChangeLocation={onChangeLocation}
{...props}
/>
+ <NavbarPromoSlot />
</NavRoot>
</Sidebar>
);
diff --git a/frontend/src/metabase/nav/containers/MainNavbar/MainNavbarContainer/MainNavbarView.tsx b/frontend/src/metabase/nav/containers/MainNavbar/MainNavbarContainer/MainNavbarView.tsx
index a23648d6126..f1e117945b0 100644
--- a/frontend/src/metabase/nav/containers/MainNavbar/MainNavbarContainer/MainNavbarView.tsx
+++ b/frontend/src/metabase/nav/containers/MainNavbar/MainNavbarContainer/MainNavbarView.tsx
@@ -21,7 +21,6 @@ import {
getCanAccessOnboardingPage,
getIsNewInstance,
} from "metabase/home/selectors";
-import { WhatsNewNotification } from "metabase/nav/components/WhatsNewNotification";
import { PLUGIN_REMOTE_SYNC, PLUGIN_TENANTS } from "metabase/plugins";
import { useSelector } from "metabase/redux";
import {
@@ -328,9 +327,6 @@ export function MainNavbarView({
</ErrorBoundary>
</TrashSidebarSection>
)}
- <div>
- <WhatsNewNotification />
- </div>
</div>
</SidebarContentRoot>
diff --git a/frontend/src/metabase/plugins/oss/security-center.ts b/frontend/src/metabase/plugins/oss/security-center.ts
index cf3ec9b1fdd..e83715b6ac8 100644
--- a/frontend/src/metabase/plugins/oss/security-center.ts
+++ b/frontend/src/metabase/plugins/oss/security-center.ts
@@ -10,6 +10,7 @@ type SecurityCenterPlugin = {
isEnabled: boolean;
SecurityCenterPage: ComponentType;
SecurityCenterBanner: ComponentType;
+ SecurityCenterPromoCard: ComponentType;
SecurityCenterNavItem: ComponentType<SecurityCenterNavItemProps>;
SecurityCenterMobileNavItem: ComponentType<SecurityCenterNavItemProps>;
};
@@ -18,6 +19,7 @@ const getDefaultPlugin = (): SecurityCenterPlugin => ({
isEnabled: false,
SecurityCenterPage: PluginPlaceholder,
SecurityCenterBanner: PluginPlaceholder,
+ SecurityCenterPromoCard: PluginPlaceholder,
SecurityCenterNavItem: PluginPlaceholder,
SecurityCenterMobileNavItem: PluginPlaceholder,
});
diff --git a/frontend/src/metabase/ui/components/icons/Icon/icons/index.ts b/frontend/src/metabase/ui/components/icons/Icon/icons/index.ts
index 6782d39bc6f..18d66c7b745 100644
--- a/frontend/src/metabase/ui/components/icons/Icon/icons/index.ts
+++ b/frontend/src/metabase/ui/components/icons/Icon/icons/index.ts
@@ -448,6 +448,8 @@ import shield_component from "./shield.svg?component";
import shield_source from "./shield.svg?source";
import shield_outline_component from "./shield_outline.svg?component";
import shield_outline_source from "./shield_outline.svg?source";
+import shield_stroke_component from "./shield_stroke.svg?component";
+import shield_stroke_source from "./shield_stroke.svg?source";
import sidebar_closed_component from "./sidebar_closed.svg?component";
import sidebar_closed_source from "./sidebar_closed.svg?source";
import sidebar_open_component from "./sidebar_open.svg?component";
@@ -1489,6 +1491,10 @@ export const Icons: Record<IconName, { component: React.VFC; source: string }> =
component: shield_outline_component,
source: shield_outline_source,
},
+ shield_stroke: {
+ component: shield_stroke_component,
+ source: shield_stroke_source,
+ },
sidebar_closed: {
component: sidebar_closed_component,
source: sidebar_closed_source,
diff --git a/frontend/src/metabase/ui/components/icons/Icon/icons/shield_stroke.svg b/frontend/src/metabase/ui/components/icons/Icon/icons/shield_stroke.svg
new file mode 100644
index 00000000000..7fb52ea371e
--- /dev/null
+++ b/frontend/src/metabase/ui/components/icons/Icon/icons/shield_stroke.svg
@@ -0,0 +1,4 @@
+<svg width="23" height="26" viewBox="0 0 23 26" fill="none" xmlns="http://www.w3.org/2000/svg">
+<path d="M0.75 6.43829C0.75 5.94945 1.10794 5.5315 1.59012 5.45114C4.39257 4.98407 7.04327 3.77534 9.22586 1.95652L10.3955 0.98179C10.7664 0.672752 11.3051 0.672752 11.6759 0.98179L12.8456 1.95652C15.0282 3.77534 17.6789 4.98407 20.4813 5.45114C20.9635 5.5315 21.3214 5.94945 21.3214 6.43829V10.6569C21.3214 16.8455 17.3614 22.3397 11.4904 24.2968C11.1952 24.3951 10.8762 24.3951 10.5811 24.2968C4.71004 22.3397 0.75 16.8455 0.75 10.6569V6.43829Z" stroke-width="1.5" stroke-linejoin="round"/>
+<path d="M11.0357 24.4483L11.0357 0.448303" stroke-width="1.5" stroke-linejoin="round"/>
+</svg>