Skip to content

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

Show the embedding hub checklist in embedding homepage (#63596)

Phoomparin Manob5878d9bf51e
diff --git a/e2e/test/scenarios/embedding/embedding-hub/embedding-hub.cy.spec.ts b/e2e/test/scenarios/embedding/embedding-hub/embedding-hub.cy.spec.ts
index 6a3e35b8530..0e703ad4f4c 100644
--- a/e2e/test/scenarios/embedding/embedding-hub/embedding-hub.cy.spec.ts
+++ b/e2e/test/scenarios/embedding/embedding-hub/embedding-hub.cy.spec.ts
@@ -145,5 +145,81 @@ describe("scenarios - embedding hub", () => {
.icon("lock")
.should("not.exist");
});
+
+ it("embedding checklist should show up on the embedding homepage", () => {
+ cy.request("PUT", "/api/setting/embedding-homepage", {
+ value: "visible",
+ });
+
+ cy.visit("/");
+
+ cy.findAllByText("Get started with Embedded Analytics JS")
+ .first()
+ .should("be.visible");
+
+ cy.get("main").within(() => {
+ cy.findByText("Create models").should("be.visible");
+ cy.findByText("Generate a dashboard").should("be.visible");
+ cy.findByText("Add data").should("be.visible").click();
+ });
+
+ cy.log("Sanity check: add data modal should open");
+ cy.findByRole("dialog").within(() => {
+ cy.findByRole("heading", { name: "Add data" }).should("be.visible");
+ });
+ });
+
+ it("embedding checklist should not show up on the embedding homepage if not enabled", () => {
+ cy.visit("/");
+
+ cy.get("main")
+ .findByText("Get started with Embedded Analytics JS")
+ .should("not.exist");
+ });
+
+ it("overflow menu > customize homepage opens modal with correct title", () => {
+ cy.request("PUT", "/api/setting/embedding-homepage", {
+ value: "visible",
+ });
+
+ cy.visit("/");
+
+ cy.log("Click overflow menu button on the embedding homepage");
+ cy.get("main").within(() => {
+ cy.findByLabelText("More options").click();
+ });
+
+ H.menu().findByText("Customize homepage").click();
+
+ cy.findByRole("dialog").within(() => {
+ cy.findByText("Pick a dashboard to appear on the homepage").should(
+ "be.visible",
+ );
+ });
+ });
+
+ it("overflow menu > dismiss guide hides the embedding homepage", () => {
+ cy.request("PUT", "/api/setting/embedding-homepage", {
+ value: "visible",
+ });
+
+ cy.visit("/");
+
+ cy.get("main")
+ .findByText("Get started with Embedded Analytics JS")
+ .should("be.visible");
+
+ cy.log("Click overflow menu button on the embedding homepage");
+ cy.get("main").within(() => {
+ cy.findByLabelText("More options").click();
+ });
+
+ H.menu().findByText("Dismiss guide").click();
+
+ cy.log("Verify guide is dismissed and no longer visible");
+ cy.get("main")
+ .findByText("Get started with Embedded Analytics JS")
+ .should("not.exist");
+ });
});
});
diff --git a/frontend/src/metabase/admin/routes.jsx b/frontend/src/metabase/admin/routes.jsx
index a9d1413752d..c22f28c681e 100644
--- a/frontend/src/metabase/admin/routes.jsx
+++ b/frontend/src/metabase/admin/routes.jsx
@@ -37,7 +37,7 @@ import {
import { TaskModal } from "metabase/admin/tools/components/TaskModal";
import { TasksApp } from "metabase/admin/tools/components/TasksApp";
import { ToolsApp } from "metabase/admin/tools/components/ToolsApp";
-import { EmbeddingHub } from "metabase/embedding/embedding-hub";
+import { EmbeddingHubAdminSettingsPage } from "metabase/embedding/embedding-hub";
import { ModalRoute } from "metabase/hoc/ModalRoute";
import { Route } from "metabase/hoc/Title";
import { DataModel } from "metabase/metadata/pages/DataModel";
@@ -150,7 +150,7 @@ const getRoutes = (store, CanAccessSettings, IsAdmin) => (
<Route
path="setup-guide"
title={t`Setup guide`}
- component={EmbeddingHub}
+ component={EmbeddingHubAdminSettingsPage}
/>
<Route
path="modular"
diff --git a/frontend/src/metabase/embedding/embedding-hub/components/EmbeddingHub.tsx b/frontend/src/metabase/embedding/embedding-hub/components/EmbeddingHub.tsx
index dccb7ec8615..26ed7af00f6 100644
--- a/frontend/src/metabase/embedding/embedding-hub/components/EmbeddingHub.tsx
+++ b/frontend/src/metabase/embedding/embedding-hub/components/EmbeddingHub.tsx
@@ -1,14 +1,8 @@
import { useMemo, useState } from "react";
import { P, match } from "ts-pattern";
-import { t } from "ttag";
-import {
- RelatedSettingsSection,
- getModularEmbeddingRelatedSettingItems,
-} from "metabase/admin/components/RelatedSettingsSection";
import { CreateDashboardModal } from "metabase/dashboard/containers/CreateDashboardModal";
import { AddDataModal } from "metabase/nav/containers/MainNavbar/MainNavbarContainer/AddDataModal";
-import { Stack, Text, Title } from "metabase/ui";
import { useCompletedEmbeddingHubSteps } from "../hooks";
import type {
@@ -77,19 +71,9 @@ export const EmbeddingHub = () => {
}, [embeddingSteps, completedSteps, lockedSteps]);
return (
- <Stack mx="auto" py="xl" gap="xl" maw={800}>
- <Stack gap="xs" ml="3rem">
- <Title
- order={1}
- c="var(--mb-color-text-primary)"
- >{t`Embedding setup guide`}</Title>
-
- <Text c="var(--mb-color-text-secondary)">{t`Follow the guide to get started with Embedded Analytics JS`}</Text>
- </Stack>
+ <>
<StepperWithCards steps={stepperSteps} />
- <RelatedSettingsSection
- items={getModularEmbeddingRelatedSettingItems()}
- />
+
<AddDataModal
opened={openedModal?.type === "add-data"}
onClose={closeModal}
@@ -105,6 +89,6 @@ export const EmbeddingHub = () => {
opened={openedModal?.type === "xray-dashboard"}
onClose={closeModal}
/>
- </Stack>
+ </>
);
};
diff --git a/frontend/src/metabase/embedding/embedding-hub/components/EmbeddingHubAdminSettingsPage.tsx b/frontend/src/metabase/embedding/embedding-hub/components/EmbeddingHubAdminSettingsPage.tsx
new file mode 100644
index 00000000000..afd1c5eec3d
--- /dev/null
+++ b/frontend/src/metabase/embedding/embedding-hub/components/EmbeddingHubAdminSettingsPage.tsx
@@ -0,0 +1,30 @@
+import { t } from "ttag";
+
+import {
+ RelatedSettingsSection,
+ getModularEmbeddingRelatedSettingItems,
+} from "metabase/admin/components/RelatedSettingsSection";
+import { Stack, Text, Title } from "metabase/ui";
+
+import { EmbeddingHub } from "./EmbeddingHub";
+
+export const EmbeddingHubAdminSettingsPage = () => {
+ return (
+ <Stack mx="auto" py="xl" gap="xl" maw={800}>
+ <Stack gap="xs" ml="3rem">
+ <Title
+ order={1}
+ c="var(--mb-color-text-primary)"
+ >{t`Embedding setup guide`}</Title>
+
+ <Text c="var(--mb-color-text-secondary)">{t`Follow the guide to get started with Embedded Analytics JS`}</Text>
+ </Stack>
+
+ <EmbeddingHub />
+
+ <RelatedSettingsSection
+ items={getModularEmbeddingRelatedSettingItems()}
+ />
+ </Stack>
+ );
+};
diff --git a/frontend/src/metabase/embedding/embedding-hub/components/EmbeddingHubHomePage.tsx b/frontend/src/metabase/embedding/embedding-hub/components/EmbeddingHubHomePage.tsx
new file mode 100644
index 00000000000..269748480d3
--- /dev/null
+++ b/frontend/src/metabase/embedding/embedding-hub/components/EmbeddingHubHomePage.tsx
@@ -0,0 +1,72 @@
+import { useDisclosure } from "@mantine/hooks";
+import type { ReactNode } from "react";
+import { t } from "ttag";
+
+import { CustomHomePageModal } from "metabase/home/components/CustomHomePageModal";
+import { dismissEmbeddingHomepage } from "metabase/home/components/EmbedHomepage/actions";
+import { MetabotGreeting } from "metabase/home/components/HomeGreeting";
+import { useDispatch } from "metabase/lib/redux";
+import { ActionIcon, Group, Icon, Menu, Stack, Text } from "metabase/ui";
+
+import { EmbeddingHub } from "./EmbeddingHub";
+
+/**
+ * Embedding Hub shown in the embedding home page for admins in EE instances.
+ */
+export const EmbeddingHubHomePage = (): ReactNode => {
+ const [
+ isCustomHomePageModalOpened,
+ { open: openCustomHomePageModal, close: closeCustomHomePageModal },
+ ] = useDisclosure(false);
+
+ const dispatch = useDispatch();
+
+ const handleDismissGuide = () =>
+ dispatch(dismissEmbeddingHomepage("dismissed-done"));
+
+ return (
+ <Stack mx="auto" py="xl" maw={800}>
+ <Group gap="sm" justify="space-between" mb="xl">
+ <Group gap="sm">
+ <MetabotGreeting />
+
+ <Text
+ fw={700}
+ fz="lg"
+ >{t`Get started with Embedded Analytics JS`}</Text>
+ </Group>
+
+ <Menu position="bottom-end">
+ <Menu.Target>
+ <ActionIcon variant="subtle" aria-label={t`More options`}>
+ <Icon name="ellipsis" />
+ </ActionIcon>
+ </Menu.Target>
+
+ <Menu.Dropdown>
+ <Menu.Item
+ leftSection={<Icon name="pencil" />}
+ onClick={openCustomHomePageModal}
+ >
+ {t`Customize homepage`}
+ </Menu.Item>
+
+ <Menu.Item
+ leftSection={<Icon name="close" />}
+ onClick={handleDismissGuide}
+ >
+ {t`Dismiss guide`}
+ </Menu.Item>
+ </Menu.Dropdown>
+ </Menu>
+ </Group>
+
+ <EmbeddingHub />
+
+ <CustomHomePageModal
+ isOpen={isCustomHomePageModalOpened}
+ onClose={closeCustomHomePageModal}
+ />
+ </Stack>
+ );
+};
diff --git a/frontend/src/metabase/embedding/embedding-hub/components/index.ts b/frontend/src/metabase/embedding/embedding-hub/components/index.ts
index e397fb532c2..6f2da5e236b 100644
--- a/frontend/src/metabase/embedding/embedding-hub/components/index.ts
+++ b/frontend/src/metabase/embedding/embedding-hub/components/index.ts
@@ -1 +1,3 @@
export { EmbeddingHub } from "./EmbeddingHub";
+export { EmbeddingHubAdminSettingsPage } from "./EmbeddingHubAdminSettingsPage";
+export { EmbeddingHubHomePage } from "./EmbeddingHubHomePage";
diff --git a/frontend/src/metabase/home/components/HomeContent/HomeContent.tsx b/frontend/src/metabase/home/components/HomeContent/HomeContent.tsx
index 51d23a31517..0c99d622c65 100644
--- a/frontend/src/metabase/home/components/HomeContent/HomeContent.tsx
+++ b/frontend/src/metabase/home/components/HomeContent/HomeContent.tsx
@@ -20,6 +20,7 @@ export const HomeContent = (): JSX.Element | null => {
const user = useSelector(getUser);
const embeddingHomepage = useSetting("embedding-homepage");
const isXrayEnabled = useSelector(getIsXrayEnabled);
+
const { data: databases, error: databasesError } = useDatabaseListQuery();
const { data: recentItemsRaw, error: recentItemsError } = useListRecentsQuery(
undefined,
diff --git a/frontend/src/metabase/home/components/HomeGreeting/HomeGreeting.tsx b/frontend/src/metabase/home/components/HomeGreeting/HomeGreeting.tsx
index efe5c10e7c8..09d406e79ee 100644
--- a/frontend/src/metabase/home/components/HomeGreeting/HomeGreeting.tsx
+++ b/frontend/src/metabase/home/components/HomeGreeting/HomeGreeting.tsx
@@ -45,7 +45,7 @@ const getMessage = (name: string | null | undefined): string => {
return _.sample(options) ?? "";
};
-const MetabotGreeting = () => {
+export const MetabotGreeting = () => {
const [buffer, setBuffer] = useState<string[]>([]);
const [isCooling, setIsCooling] = useState(false);
const [isCool, setIsCool] = useState(false);
diff --git a/frontend/src/metabase/home/components/HomeLayout/HomeLayout.tsx b/frontend/src/metabase/home/components/HomeLayout/HomeLayout.tsx
index b881b8f1e80..690ebcc1eef 100644
--- a/frontend/src/metabase/home/components/HomeLayout/HomeLayout.tsx
+++ b/frontend/src/metabase/home/components/HomeLayout/HomeLayout.tsx
@@ -2,8 +2,10 @@ import type { ReactNode } from "react";
import { useState } from "react";
import { t } from "ttag";
+import { useHasTokenFeature, useSetting } from "metabase/common/hooks";
+import { EmbeddingHubHomePage } from "metabase/embedding/embedding-hub";
import { useSelector } from "metabase/lib/redux";
-import { getUserIsAdmin } from "metabase/selectors/user";
+import { getUser, getUserIsAdmin } from "metabase/selectors/user";
import { getLandingPageIllustration } from "metabase/selectors/whitelabel";
import { Tooltip } from "metabase/ui";
@@ -21,11 +23,23 @@ interface HomeLayoutProps {
children?: ReactNode;
}
-export const HomeLayout = ({ children }: HomeLayoutProps): JSX.Element => {
+export const HomeLayout = ({ children }: HomeLayoutProps): ReactNode => {
const [showModal, setShowModal] = useState(false);
const isAdmin = useSelector(getUserIsAdmin);
const landingPageIllustration = useSelector(getLandingPageIllustration);
+ const user = useSelector(getUser);
+ const embeddingHomepage = useSetting("embedding-homepage");
+ const isSimpleEmbeddingAvailable = useHasTokenFeature("embedding_simple");
+
+ if (
+ embeddingHomepage === "visible" &&
+ user?.is_superuser &&
+ isSimpleEmbeddingAvailable
+ ) {
+ return <EmbeddingHubHomePage />;
+ }
+
return (
<LayoutRoot data-testid="home-page">
{landingPageIllustration && (