Skip to content

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

Copy and link update for security center banner (#72935)

Sébastien6d1b6b5da833
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 14dfea8f4a6..e947f34df9e 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
@@ -59,30 +59,29 @@ export function SecurityCenterBanner() {
return null;
}
- const settingsLink = (
+ const securityCenterLink = (
<Anchor
key="link"
component={Link}
fw="bold"
- to="/admin/security-center"
+ to="/admin/security-center?open=notifications"
c="inherit"
td="underline"
>
- {t`Set up notifications`}
+ {t`Security center`}
</Anchor>
);
+ // 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">
- {jt`Active security advisories require attention, but no notification channels are configured. ${settingsLink}`}
- </Text>
- }
+ body={<Text lh="inherit">{body}</Text>}
py="md"
/>
);
@@ -95,7 +94,7 @@ export function SecurityCenterBanner() {
bg="warning"
body={
<Text lh="inherit" c="text-primary">
- {jt`No notification channels are configured for security alerts. ${settingsLink}`}
+ {body}
</Text>
}
closable
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 4cdc3e78d78..8cf7fbb9609 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
@@ -68,7 +68,7 @@ describe("SecurityCenterBanner", () => {
setup();
expect(
- await screen.findByText(/No notification channels are configured/),
+ await screen.findByText(/Please configure notification channels/),
).toBeInTheDocument();
});
@@ -100,7 +100,7 @@ describe("SecurityCenterBanner", () => {
});
expect(
- await screen.findByText(/Active security advisories require attention/),
+ await screen.findByText(/Please configure notification channels/),
).toBeInTheDocument();
});
@@ -117,7 +117,7 @@ describe("SecurityCenterBanner", () => {
});
// Wait for the error banner text to confirm advisory data has loaded
- await screen.findByText(/Active security advisories require attention/);
+ await screen.findByText(/Please configure notification channels/);
expect(screen.queryByLabelText("close icon")).not.toBeInTheDocument();
});
@@ -138,14 +138,17 @@ describe("SecurityCenterBanner", () => {
});
expect(
- await screen.findByText(/Active security advisories require attention/),
+ await screen.findByText(/Please configure notification channels/),
).toBeInTheDocument();
});
- it("includes a link to security center settings", async () => {
+ it("includes a link to security center notification settings", async () => {
setup();
- const link = await screen.findByText("Set up notifications");
- expect(link).toHaveAttribute("href", "/admin/security-center");
+ const link = await screen.findByText("Security center");
+ expect(link).toHaveAttribute(
+ "href",
+ "/admin/security-center?open=notifications",
+ );
});
});
diff --git a/enterprise/frontend/src/metabase-enterprise/security_center/components/SecurityCenterPage/SecurityCenterPage.tsx b/enterprise/frontend/src/metabase-enterprise/security_center/components/SecurityCenterPage/SecurityCenterPage.tsx
index 7d872e3c4b9..0bf58854f37 100644
--- a/enterprise/frontend/src/metabase-enterprise/security_center/components/SecurityCenterPage/SecurityCenterPage.tsx
+++ b/enterprise/frontend/src/metabase-enterprise/security_center/components/SecurityCenterPage/SecurityCenterPage.tsx
@@ -1,3 +1,4 @@
+import type { Location } from "history";
import { useCallback, useEffect, useRef, useState } from "react";
import { t } from "ttag";
@@ -39,7 +40,11 @@ const DEFAULT_FILTER: AdvisoryFilter = {
const MAX_POLL_COUNT = 30;
-export function SecurityCenterPage() {
+type SecurityCenterPageProps = {
+ location?: Location<{ open?: string }>;
+};
+
+export function SecurityCenterPage({ location }: SecurityCenterPageProps = {}) {
const [isPolling, setIsPolling] = useState(false);
const {
data: advisories,
@@ -51,7 +56,9 @@ export function SecurityCenterPage() {
const [syncAdvisories, { isLoading: isSyncing }] =
useSyncSecurityAdvisoriesMutation();
const [filter, setFilter] = useState<AdvisoryFilter>(DEFAULT_FILTER);
- const [settingsOpen, setSettingsOpen] = useState(false);
+ const [settingsOpen, setSettingsOpen] = useState(
+ () => location?.query?.open === "notifications",
+ );
const notificationConfig = useNotificationConfigState();
const version = useSetting("version");
const [sendToast] = useToast();
diff --git a/enterprise/frontend/src/metabase-enterprise/security_center/components/SecurityCenterPage/SecurityCenterPage.unit.spec.tsx b/enterprise/frontend/src/metabase-enterprise/security_center/components/SecurityCenterPage/SecurityCenterPage.unit.spec.tsx
index 44e1422f5ee..2e0546b683e 100644
--- a/enterprise/frontend/src/metabase-enterprise/security_center/components/SecurityCenterPage/SecurityCenterPage.unit.spec.tsx
+++ b/enterprise/frontend/src/metabase-enterprise/security_center/components/SecurityCenterPage/SecurityCenterPage.unit.spec.tsx
@@ -1,5 +1,6 @@
import userEvent from "@testing-library/user-event";
import fetchMock from "fetch-mock";
+import type { Location } from "history";
import { setupRecentViewsAndSelectionsEndpoints } from "__support__/server-mocks";
import { renderWithProviders, screen, within } from "__support__/ui";
@@ -24,7 +25,13 @@ const mockAcknowledgeAll = jest.fn();
function setup(
advisories: Advisory[] = [],
- { lastCheckedAt = null }: { lastCheckedAt?: string | null } = {},
+ {
+ lastCheckedAt = null,
+ location,
+ }: {
+ lastCheckedAt?: string | null;
+ location?: Location<{ open?: string }>;
+ } = {},
) {
jest.spyOn(advisoriesHook, "useSecurityAdvisories").mockReturnValue({
data: advisories,
@@ -57,7 +64,7 @@ function setup(
resetConfig: jest.fn(),
});
- renderWithProviders(<SecurityCenterPage />, {
+ renderWithProviders(<SecurityCenterPage location={location} />, {
storeInitialState: {
settings: createMockSettingsState({
version: createMockVersion({ tag: "v0.59.3" }),
@@ -347,6 +354,28 @@ describe("SecurityCenterPage", () => {
});
});
+ describe("notification settings modal", () => {
+ it("opens the modal when the 'open=notifications' query param is set", async () => {
+ setup([], {
+ location: {
+ query: { open: "notifications" },
+ } as Location<{ open?: string }>,
+ });
+
+ expect(
+ await screen.findByRole("dialog", { name: "Notification settings" }),
+ ).toBeInTheDocument();
+ });
+
+ it("does not open the modal when the query param is not set", async () => {
+ setup();
+
+ expect(
+ screen.queryByRole("dialog", { name: "Notification settings" }),
+ ).not.toBeInTheDocument();
+ });
+ });
+
describe("sync polling", () => {
it("disables the sync button while syncing", async () => {
fetchMock.post("path:/api/ee/security-center/sync", 200);