Skip to content

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

feat(data-studio): add a header menu and History to Library dashboards (#84827)

Aleksandr Lesnenko8c33516e6c3c
diff --git a/enterprise/frontend/src/metabase-enterprise/data-studio/library/dashboards/components/DashboardHeader/DashboardBreadcrumbs/DashboardBreadcrumbs.tsx b/enterprise/frontend/src/metabase-enterprise/data-studio/library/dashboards/components/DashboardHeader/DashboardBreadcrumbs/DashboardBreadcrumbs.tsx
new file mode 100644
index 00000000000..ebefd007bd4
--- /dev/null
+++ b/enterprise/frontend/src/metabase-enterprise/data-studio/library/dashboards/components/DashboardHeader/DashboardBreadcrumbs/DashboardBreadcrumbs.tsx
@@ -0,0 +1,60 @@
+import { t } from "ttag";
+
+import { Link } from "metabase/common/components/Link";
+import { DataStudioBreadcrumbs } from "metabase/common/data-studio/components/DataStudioBreadcrumbs";
+import { useCollectionPath } from "metabase/common/data-studio/hooks/use-collection-path/useCollectionPath";
+import * as Urls from "metabase/urls";
+import type { CollectionId, Dashboard } from "metabase-types/api";
+
+import { type DashboardLocation, getDashboardLocation } from "../utils";
+
+type DashboardBreadcrumbsProps = {
+ dashboard: Dashboard;
+};
+
+export function DashboardBreadcrumbs({ dashboard }: DashboardBreadcrumbsProps) {
+ const { path, isLoadingPath } = useCollectionPath({
+ collectionId: dashboard.collection_id,
+ });
+ const crumbs = getCrumbs(getDashboardLocation(path ?? []));
+
+ return (
+ <DataStudioBreadcrumbs loading={isLoadingPath}>
+ {crumbs.map((crumb) => (
+ <Link key={crumb.key} to={crumb.to}>
+ {crumb.name}
+ </Link>
+ ))}
+ <span>{dashboard.name}</span>
+ </DataStudioBreadcrumbs>
+ );
+}
+
+type Crumb = {
+ key: CollectionId | "section";
+ name: string;
+ to: string;
+};
+
+function getCrumbs(location: DashboardLocation): Crumb[] {
+ if (location.type === "collection") {
+ return location.path.map((collection) => ({
+ key: collection.id,
+ name: collection.name,
+ to: Urls.collection(collection),
+ }));
+ }
+
+ return [
+ { key: "section", name: t`Dashboards`, to: Urls.dataStudioDashboards() },
+ ...location.folders.map((folder, index) => ({
+ key: folder.id,
+ name: folder.name,
+ to: Urls.dataStudioDashboards({
+ expandedIds: location.folders
+ .slice(0, index + 1)
+ .map((ancestor) => ancestor.id),
+ }),
+ })),
+ ];
+}
diff --git a/enterprise/frontend/src/metabase-enterprise/data-studio/library/dashboards/components/DashboardHeader/DashboardBreadcrumbs/DashboardBreadcrumbs.unit.spec.tsx b/enterprise/frontend/src/metabase-enterprise/data-studio/library/dashboards/components/DashboardHeader/DashboardBreadcrumbs/DashboardBreadcrumbs.unit.spec.tsx
new file mode 100644
index 00000000000..a301af4fec1
--- /dev/null
+++ b/enterprise/frontend/src/metabase-enterprise/data-studio/library/dashboards/components/DashboardHeader/DashboardBreadcrumbs/DashboardBreadcrumbs.unit.spec.tsx
@@ -0,0 +1,82 @@
+import { setupCollectionByIdEndpoint } from "__support__/server-mocks";
+import { renderWithProviders, screen } from "__support__/ui";
+import { ROOT_COLLECTION } from "metabase/common/collections/constants";
+import type { CollectionId } from "metabase-types/api";
+import {
+ createMockCollection,
+ createMockDashboard,
+} from "metabase-types/api/mocks";
+
+import { DashboardBreadcrumbs } from "./DashboardBreadcrumbs";
+
+const LIBRARY = createMockCollection({
+ id: 1,
+ name: "Library",
+ type: "library",
+});
+const DASHBOARDS = createMockCollection({
+ id: 2,
+ name: "Dashboards",
+ type: "library-dashboards",
+});
+const SALES = createMockCollection({
+ id: 3,
+ name: "Sales",
+ type: "library-dashboards",
+ effective_ancestors: [LIBRARY, DASHBOARDS],
+});
+const EXAMPLES = createMockCollection({ id: 5, name: "Examples" });
+
+type SetupOpts = {
+ collectionId: CollectionId;
+};
+
+function setup({ collectionId }: SetupOpts) {
+ setupCollectionByIdEndpoint({
+ collections: [
+ createMockCollection(ROOT_COLLECTION),
+ LIBRARY,
+ DASHBOARDS,
+ SALES,
+ EXAMPLES,
+ ],
+ });
+
+ renderWithProviders(
+ <DashboardBreadcrumbs
+ dashboard={createMockDashboard({
+ name: "Sales overview",
+ collection_id: collectionId,
+ })}
+ />,
+ { withRouter: true },
+ );
+}
+
+describe("DashboardBreadcrumbs", () => {
+ it("leads through the Dashboards section and its folders for a Library dashboard", async () => {
+ setup({ collectionId: SALES.id });
+
+ expect(await screen.findByRole("link", { name: "Sales" })).toHaveAttribute(
+ "href",
+ "/data-studio/dashboards?expandedId=3",
+ );
+ expect(screen.getByRole("link", { name: "Dashboards" })).toHaveAttribute(
+ "href",
+ "/data-studio/dashboards",
+ );
+ expect(screen.getByText("Sales overview")).toBeInTheDocument();
+ });
+
+ it("leads to the collection pages of a dashboard outside the Library", async () => {
+ setup({ collectionId: EXAMPLES.id });
+
+ expect(
+ await screen.findByRole("link", { name: "Examples" }),
+ ).toHaveAttribute("href", "/collection/5-examples");
+ expect(
+ screen.queryByRole("link", { name: "Dashboards" }),
+ ).not.toBeInTheDocument();
+ expect(screen.getByText("Sales overview")).toBeInTheDocument();
+ });
+});
diff --git a/enterprise/frontend/src/metabase-enterprise/data-studio/library/dashboards/components/DashboardHeader/DashboardBreadcrumbs/index.ts b/enterprise/frontend/src/metabase-enterprise/data-studio/library/dashboards/components/DashboardHeader/DashboardBreadcrumbs/index.ts
new file mode 100644
index 00000000000..0d173203c3e
--- /dev/null
+++ b/enterprise/frontend/src/metabase-enterprise/data-studio/library/dashboards/components/DashboardHeader/DashboardBreadcrumbs/index.ts
@@ -0,0 +1 @@
+export { DashboardBreadcrumbs } from "./DashboardBreadcrumbs";
diff --git a/enterprise/frontend/src/metabase-enterprise/data-studio/library/dashboards/components/DashboardHeader/DashboardHeader.tsx b/enterprise/frontend/src/metabase-enterprise/data-studio/library/dashboards/components/DashboardHeader/DashboardHeader.tsx
index bbbeebe0d3d..6c2380c26cd 100644
--- a/enterprise/frontend/src/metabase-enterprise/data-studio/library/dashboards/components/DashboardHeader/DashboardHeader.tsx
+++ b/enterprise/frontend/src/metabase-enterprise/data-studio/library/dashboards/components/DashboardHeader/DashboardHeader.tsx
@@ -1,19 +1,16 @@
-import { t } from "ttag";
-
-import { Link } from "metabase/common/components/Link";
-import { DataStudioBreadcrumbs } from "metabase/common/data-studio/components/DataStudioBreadcrumbs";
import { PaneHeader } from "metabase/common/data-studio/components/PaneHeader";
-import { useCollectionPath } from "metabase/common/data-studio/hooks/use-collection-path/useCollectionPath";
-import * as Urls from "metabase/urls";
+import { PLUGIN_MODERATION } from "metabase/plugins";
+import { Flex } from "metabase/ui";
import type { Dashboard } from "metabase-types/api";
import type { DashboardTabsInfo } from "../../hooks/use-dashboard-tabs-info";
import { DashboardArchivedBanner } from "./DashboardArchivedBanner";
+import { DashboardBreadcrumbs } from "./DashboardBreadcrumbs";
import { DashboardHeaderActions } from "./DashboardHeaderActions";
+import { DashboardMoreMenu } from "./DashboardMoreMenu";
import { DashboardNameInput } from "./DashboardNameInput";
import { DashboardTabs } from "./DashboardTabs";
-import { getDashboardFolders } from "./utils";
type DashboardHeaderProps = {
dashboard: Dashboard;
@@ -21,38 +18,24 @@ type DashboardHeaderProps = {
};
export function DashboardHeader({ dashboard, tabsInfo }: DashboardHeaderProps) {
- const { path, isLoadingPath } = useCollectionPath({
- collectionId: dashboard.collection_id,
- });
- const folders = getDashboardFolders(path ?? []);
-
return (
<>
{dashboard.archived && <DashboardArchivedBanner dashboard={dashboard} />}
<PaneHeader
data-testid="dashboard-pane-header"
- title={<DashboardNameInput dashboard={dashboard} />}
+ title={
+ <Flex align="center" gap="sm">
+ <DashboardNameInput dashboard={dashboard} />
+ <PLUGIN_MODERATION.EntityModerationIcon
+ moderationReviews={dashboard.moderation_reviews}
+ />
+ </Flex>
+ }
icon="dashboard"
+ menu={<DashboardMoreMenu dashboard={dashboard} />}
tabs={<DashboardTabs dashboardId={dashboard.id} tabsInfo={tabsInfo} />}
actions={<DashboardHeaderActions dashboard={dashboard} />}
- breadcrumbs={
- <DataStudioBreadcrumbs loading={isLoadingPath}>
- <Link to={Urls.dataStudioDashboards()}>{t`Dashboards`}</Link>
- {folders.map((folder, index) => (
- <Link
- key={folder.id}
- to={Urls.dataStudioDashboards({
- expandedIds: folders
- .slice(0, index + 1)
- .map((ancestor) => ancestor.id),
- })}
- >
- {folder.name}
- </Link>
- ))}
- <span>{dashboard.name}</span>
- </DataStudioBreadcrumbs>
- }
+ breadcrumbs={<DashboardBreadcrumbs dashboard={dashboard} />}
/>
</>
);
diff --git a/enterprise/frontend/src/metabase-enterprise/data-studio/library/dashboards/components/DashboardHeader/DashboardMoreMenu/DashboardModal/DashboardModal.tsx b/enterprise/frontend/src/metabase-enterprise/data-studio/library/dashboards/components/DashboardHeader/DashboardMoreMenu/DashboardModal/DashboardModal.tsx
new file mode 100644
index 00000000000..dcbfb68ce02
--- /dev/null
+++ b/enterprise/frontend/src/metabase-enterprise/data-studio/library/dashboards/components/DashboardHeader/DashboardMoreMenu/DashboardModal/DashboardModal.tsx
@@ -0,0 +1,49 @@
+import { match } from "ts-pattern";
+
+import { useSetArchive } from "metabase/archive/hooks";
+import CollectionCopyEntityModal from "metabase/collections/components/CollectionCopyEntityModal";
+import { DashboardMoveModal } from "metabase/dashboard/components/DashboardMoveModal";
+import { ArchiveDashboardModal } from "metabase/dashboard/containers/ArchiveDashboardModal";
+import { useNavigate } from "metabase/router";
+import * as Urls from "metabase/urls";
+import type { Dashboard } from "metabase-types/api";
+
+export type DashboardModalType = "move" | "duplicate" | "trash";
+
+type DashboardModalProps = {
+ dashboard: Dashboard;
+ modalType: DashboardModalType;
+ onClose: () => void;
+};
+
+export function DashboardModal({
+ dashboard,
+ modalType,
+ onClose,
+}: DashboardModalProps) {
+ const navigate = useNavigate();
+ const archive = useSetArchive();
+
+ return match(modalType)
+ .with("move", () => (
+ <DashboardMoveModal dashboard={dashboard} onClose={onClose} />
+ ))
+ .with("duplicate", () => (
+ <CollectionCopyEntityModal
+ entityObject={{ ...dashboard, model: "dashboard" }}
+ onClose={onClose}
+ onSaved={(copy: Pick<Dashboard, "id">) => {
+ onClose();
+ navigate(Urls.dataStudioDashboard(copy.id));
+ }}
+ />
+ ))
+ .with("trash", () => (
+ <ArchiveDashboardModal
+ dashboard={dashboard}
+ onArchive={() => archive({ model: "dashboard", id: dashboard.id })}
+ onClose={onClose}
+ />
+ ))
+ .exhaustive();
+}
diff --git a/enterprise/frontend/src/metabase-enterprise/data-studio/library/dashboards/components/DashboardHeader/DashboardMoreMenu/DashboardModal/DashboardModal.unit.spec.tsx b/enterprise/frontend/src/metabase-enterprise/data-studio/library/dashboards/components/DashboardHeader/DashboardMoreMenu/DashboardModal/DashboardModal.unit.spec.tsx
new file mode 100644
index 00000000000..aa8da66109c
--- /dev/null
+++ b/enterprise/frontend/src/metabase-enterprise/data-studio/library/dashboards/components/DashboardHeader/DashboardMoreMenu/DashboardModal/DashboardModal.unit.spec.tsx
@@ -0,0 +1,236 @@
+import userEvent from "@testing-library/user-event";
+import fetchMock from "fetch-mock";
+
+import {
+ setupCollectionByIdEndpoint,
+ setupCollectionItemsEndpoint,
+ setupCollectionsEndpoints,
+ setupDashboardEndpoints,
+ setupDatabasesEndpoints,
+ setupRecentViewsAndSelectionsEndpoints,
+ setupRootCollectionItemsEndpoint,
+ setupSearchEndpoints,
+ setupUserRecipientsEndpoint,
+} from "__support__/server-mocks";
+import {
+ mockGetBoundingClientRect,
+ renderWithProviders,
+ screen,
+ waitFor,
+ within,
+} from "__support__/ui";
+import { ROOT_COLLECTION } from "metabase/common/collections/constants";
+import { Route } from "metabase/router";
+import type { Dashboard } from "metabase-types/api";
+import {
+ createMockCard,
+ createMockCollection,
+ createMockCollectionItem,
+ createMockDashboard,
+ createMockDashboardCard,
+} from "metabase-types/api/mocks";
+
+import { DashboardModal, type DashboardModalType } from "./DashboardModal";
+
+const ROOT = createMockCollection(ROOT_COLLECTION);
+const SALES = createMockCollection({
+ id: 3,
+ name: "Sales",
+ type: "library-dashboards",
+});
+const EXAMPLES_ID = 5;
+const EXAMPLES = createMockCollection({ id: EXAMPLES_ID, name: "Examples" });
+
+const DASHBOARD = createMockDashboard({
+ id: 10,
+ name: "Sales overview",
+ collection_id: SALES.id,
+ dashcards: [],
+});
+
+type SetupOpts = {
+ modalType: DashboardModalType;
+ dashboard?: Dashboard;
+};
+
+function setup({ modalType, dashboard = DASHBOARD }: SetupOpts) {
+ const onClose = jest.fn();
+ setupDashboardEndpoints(dashboard, { updatedDashboard: dashboard });
+ setupCollectionByIdEndpoint({ collections: [ROOT, SALES, EXAMPLES] });
+
+ const { router } = renderWithProviders(
+ <Route
+ path="/data-studio/dashboards/:dashboardId"
+ element={
+ <DashboardModal
+ dashboard={dashboard}
+ modalType={modalType}
+ onClose={onClose}
+ />
+ }
+ />,
+ {
+ withRouter: true,
+ withUndos: true,
+ initialRoute: `/data-studio/dashboards/${dashboard.id}`,
+ },
+ );
+
+ return { onClose, router };
+}
+
+function setupPickerEndpoints() {
+ mockGetBoundingClientRect();
+ setupRecentViewsAndSelectionsEndpoints([], ["views", "selections"]);
+ setupDatabasesEndpoints([]);
+ setupCollectionsEndpoints({
+ collections: [SALES, EXAMPLES],
+ rootCollection: ROOT,
+ });
+ setupRootCollectionItemsEndpoint({
+ rootCollectionItems: [
+ createMockCollectionItem({
+ id: EXAMPLES_ID,
+ model: "collection",
+ name: EXAMPLES.name,
+ collection_id: null,
+ can_write: true,
+ }),
+ ],
+ });
+ setupCollectionItemsEndpoint({ collection: ROOT, collectionItems: [] });
+ setupCollectionItemsEndpoint({ collection: SALES, collectionItems: [] });
+ setupCollectionItemsEndpoint({ collection: EXAMPLES, collectionItems: [] });
+ setupSearchEndpoints([]);
+ setupUserRecipientsEndpoint({ users: [] });
+}
+
+async function getLastRequestBody(
+ matcher: string,
+ method: "PUT" | "POST",
+): Promise<unknown> {
+ return fetchMock.callHistory.lastCall(matcher, { method })?.request?.json();
+}
+
+describe("DashboardModal", () => {
+ describe("move", () => {
+ it("moves the dashboard to any collection the picker offers", async () => {
+ setupPickerEndpoints();
+ const { onClose } = setup({ modalType: "move" });
+
+ expect(await screen.findByText("Move dashboard to…")).toBeInTheDocument();
+ await userEvent.click(await screen.findByText("Our analytics"));
+ await userEvent.click(await screen.findByText("Examples"));
+ await userEvent.click(
+ within(screen.getByRole("dialog")).getByRole("button", {
+ name: "Move",
+ }),
+ );
+
+ await waitFor(() => expect(onClose).toHaveBeenCalled());
+ expect(
+ await getLastRequestBody("path:/api/dashboard/10", "PUT"),
+ ).toMatchObject({
+ collection_id: EXAMPLES.id,
+ });
+ expect(await screen.findByText(/Dashboard moved to/)).toBeInTheDocument();
+ });
+ });
+
+ describe("duplicate", () => {
+ const COPY = createMockDashboard({
+ id: 42,
+ name: "Sales overview - Duplicate",
+ });
+
+ it("opens the copy in Data Studio when it is saved in the Library", async () => {
+ fetchMock.post("path:/api/dashboard/10/copy", COPY);
+ const { onClose, router } = setup({ modalType: "duplicate" });
+
+ await userEvent.click(
+ await screen.findByRole("button", { name: "Duplicate" }),
+ );
+
+ await waitFor(() =>
+ expect(router?.location.pathname).toBe("/data-studio/dashboards/42"),
+ );
+ expect(onClose).toHaveBeenCalled();
+ expect(
+ await getLastRequestBody("path:/api/dashboard/10/copy", "POST"),
+ ).toMatchObject({
+ name: "Sales overview - Duplicate",
+ collection_id: SALES.id,
+ });
+ });
+
+ it("opens the copy in Data Studio when it is saved outside the Library", async () => {
+ setupPickerEndpoints();
+ fetchMock.post("path:/api/dashboard/10/copy", {
+ ...COPY,
+ collection_id: EXAMPLES_ID,
+ });
+ const { onClose, router } = setup({ modalType: "duplicate" });
+
+ await userEvent.click(
+ await screen.findByRole("button", {
+ name: /Which collection should this go in/,
+ }),
+ );
+ await userEvent.click(await screen.findByText("Our analytics"));
+ await userEvent.click(await screen.findByText("Examples"));
+ await userEvent.click(screen.getByRole("button", { name: "Select" }));
+ await userEvent.click(screen.getByRole("button", { name: "Duplicate" }));
+
+ await waitFor(() =>
+ expect(router?.location.pathname).toBe("/data-studio/dashboards/42"),
+ );
+ expect(onClose).toHaveBeenCalled();
+ expect(
+ await getLastRequestBody("path:/api/dashboard/10/copy", "POST"),
+ ).toMatchObject({ collection_id: EXAMPLES_ID });
+ });
+ });
+
+ describe("trash", () => {
+ it("moves the dashboard to the trash", async () => {
+ const { onClose } = setup({ modalType: "trash" });
+
+ expect(
+ await screen.findByText("Move this dashboard to trash?"),
+ ).toBeInTheDocument();
+ expect(
+ screen.getByText("Are you sure you want to do this?"),
+ ).toBeInTheDocument();
+ await userEvent.click(
+ screen.getByRole("button", { name: "Move to trash" }),
+ );
+
+ await waitFor(() => expect(onClose).toHaveBeenCalled());
+ expect(
+ await getLastRequestBody("path:/api/dashboard/10", "PUT"),
+ ).toMatchObject({
+ archived: true,
+ });
+ });
+
+ it("warns that the dashboard's own questions go with it", async () => {
+ setup({
+ modalType: "trash",
+ dashboard: createMockDashboard({
+ ...DASHBOARD,
+ dashcards: [
+ createMockDashboardCard({
+ card: createMockCard({ dashboard_id: DASHBOARD.id }),
+ }),
+ ],
+ }),
+ });
+
+ expect(
+ await screen.findByText(
+ "This will trash the dashboard and the questions that are saved in it. Are you sure you want to do this?",
+ ),
+ ).toBeInTheDocument();
+ });
+ });
+});
diff --git a/enterprise/frontend/src/metabase-enterprise/data-studio/library/dashboards/components/DashboardHeader/DashboardMoreMenu/DashboardModal/index.ts b/enterprise/frontend/src/metabase-enterprise/data-studio/library/dashboards/components/DashboardHeader/DashboardMoreMenu/DashboardModal/index.ts
new file mode 100644
index 00000000000..15c346de53f
--- /dev/null
+++ b/enterprise/frontend/src/metabase-enterprise/data-studio/library/dashboards/components/DashboardHeader/DashboardMoreMenu/DashboardModal/index.ts
@@ -0,0 +1 @@
+export { DashboardModal, type DashboardModalType } from "./DashboardModal";
diff --git a/enterprise/frontend/src/metabase-enterprise/data-studio/library/dashboards/components/DashboardHeader/DashboardMoreMenu/DashboardMoreMenu.tsx b/enterprise/frontend/src/metabase-enterprise/data-studio/library/dashboards/components/DashboardHeader/DashboardMoreMenu/DashboardMoreMenu.tsx
new file mode 100644
index 00000000000..86458d490bf
--- /dev/null
+++ b/enterprise/frontend/src/metabase-enterprise/data-studio/library/dashboards/components/DashboardHeader/DashboardMoreMenu/DashboardMoreMenu.tsx
@@ -0,0 +1,124 @@
+import { useState } from "react";
+import { c, t } from "ttag";
+
+import {
+ useCreateBookmarkMutation,
+ useDeleteBookmarkMutation,
+ useListBookmarksQuery,
+} from "metabase/api";
+import { MoreMenuButton } from "metabase/common/data-studio/components/MoreMenuButton";
+import { PLUGIN_MODERATION } from "metabase/plugins";
+import { Icon, Menu } from "metabase/ui";
+import type { Dashboard } from "metabase-types/api";
+
+import { useCanEditDashboard } from "../../../hooks/use-can-edit-dashboard";
+
+import { DashboardModal, type DashboardModalType } from "./DashboardModal";
+
+type DashboardMoreMenuProps = {
+ dashboard: Dashboard;
+};
+
+export function DashboardMoreMenu({ dashboard }: DashboardMoreMenuProps) {
+ const [modalType, setModalType] = useState<DashboardModalType>();
+
+ if (dashboard.archived) {
+ return null;
+ }
+
+ return (
+ <>
+ <DashboardMenu dashboard={dashboard} onOpenModal={setModalType} />
+ {modalType != null && (
+ <DashboardModal
+ dashboard={dashboard}
+ modalType={modalType}
+ onClose={() => setModalType(undefined)}
+ />
+ )}
+ </>
+ );
+}
+
+type DashboardMenuProps = {
+ dashboard: Dashboard;
+ onOpenModal: (modalType: DashboardModalType) => void;
+};
+
+function DashboardMenu({ dashboard, onOpenModal }: DashboardMenuProps) {
+ const canEdit = useCanEditDashboard(dashboard);
+ const { data: bookmarks = [] } = useListBookmarksQuery();
+ const isBookmarked = bookmarks.some(
+ (bookmark) =>
+ bookmark.type === "dashboard" && bookmark.item_id === dashboard.id,
+ );
+
+ return (
+ <Menu>
+ <Menu.Target>
+ <MoreMenuButton aria-label={t`More options`} />
+ </Menu.Target>
+ <Menu.Dropdown>
+ <BookmarkMenuItem dashboard={dashboard} isBookmarked={isBookmarked} />
+ {dashboard.can_write && <ModerationMenuItems dashboard={dashboard} />}
+ {canEdit && (
+ <Menu.Item
+ leftSection={<Icon name="move" />}
+ onClick={() => onOpenModal("move")}
+ >
+ {c("A verb, not a noun").t`Move`}
+ </Menu.Item>
+ )}
+ <Menu.Item
+ leftSection={<Icon name="clone" />}
+ onClick={() => onOpenModal("duplicate")}
+ >
+ {c("A verb, not a noun").t`Duplicate`}
+ </Menu.Item>
+ {canEdit && (
+ <>
+ <Menu.Divider role="separator" />
+ <Menu.Item
+ leftSection={<Icon name="trash" />}
+ onClick={() => onOpenModal("trash")}
+ >
+ {t`Move to trash`}
+ </Menu.Item>
+ </>
+ )}
+ </Menu.Dropdown>
+ </Menu>
+ );
+}
+
+type DashboardMenuItemProps = {
+ dashboard: Dashboard;
+};
+
+type BookmarkMenuItemProps = DashboardMenuItemProps & {
+ isBookmarked: boolean;
+};
+
+function BookmarkMenuItem({ dashboard, isBookmarked }: BookmarkMenuItemProps) {
+ const [createBookmark] = useCreateBookmarkMutation();
+ const [deleteBookmark] = useDeleteBookmarkMutation();
+
+ return (
+ <Menu.Item
+ leftSection={
+ <Icon name={isBookmarked ? "bookmark_filled" : "bookmark"} />
+ }
+ onClick={() =>
+ isBookmarked
+ ? deleteBookmark({ id: dashboard.id, type: "dashboard" })
+ : createBookmark({ id: dashboard.id, type: "dashboard" })
+ }
+ >
+ {isBookmarked ? t`Remove from bookmarks` : t`Bookmark`}
+ </Menu.Item>
+ );
+}
+
+function ModerationMenuItems({ dashboard }: DashboardMenuItemProps) {
+ return <>{PLUGIN_MODERATION.useDashboardMenuItems(dashboard)}</>;
+}
diff --git a/enterprise/frontend/src/metabase-enterprise/data-studio/library/dashboards/components/DashboardHeader/DashboardMoreMenu/DashboardMoreMenu.unit.spec.tsx b/enterprise/frontend/src/metabase-enterprise/data-studio/library/dashboards/components/DashboardHeader/DashboardMoreMenu/DashboardMoreMenu.unit.spec.tsx
new file mode 100644
index 00000000000..5719899f47c
--- /dev/null
+++ b/enterprise/frontend/src/metabase-enterprise/data-studio/library/dashboards/components/DashboardHeader/DashboardMoreMenu/DashboardMoreMenu.unit.spec.tsx
@@ -0,0 +1,105 @@
+import userEvent from "@testing-library/user-event";
+
+import { setupEnterpriseOnlyPlugin } from "__support__/enterprise";
+import { setupBookmarksEndpoints } from "__support__/server-mocks";
+import { mockSettings } from "__support__/settings";
+import { createMockState } from "__support__/state";
+import { renderWithProviders, screen } from "__support__/ui";
+import type { Dashboard } from "metabase-types/api";
+import {
+ createMockDashboard,
+ createMockTokenFeatures,
+ createMockUser,
+} from "metabase-types/api/mocks";
+
+import { DashboardMoreMenu } from "./DashboardMoreMenu";
+
+type SetupOpts = {
+ dashboard: Dashboard;
+ isAdmin?: boolean;
+ isRemoteSyncReadOnly?: boolean;
+};
+
+function setup({
+ dashboard,
+ isAdmin = false,
+ isRemoteSyncReadOnly = false,
+}: SetupOpts) {
+ const settings = mockSettings({
+ "token-features": createMockTokenFeatures({ content_verification: true }),
+ "remote-sync-enabled": isRemoteSyncReadOnly,
+ "remote-sync-type": isRemoteSyncReadOnly ? "read-only" : undefined,
+ });
+ setupEnterpriseOnlyPlugin("moderation");
+ setupBookmarksEndpoints([]);
+
+ renderWithProviders(<DashboardMoreMenu dashboard={dashboard} />, {
+ storeInitialState: createMockState({
+ settings,
+ currentUser: createMockUser({ is_superuser: isAdmin }),
+ }),
+ });
+}
+
+async function getMenuItemLabels() {
+ await userEvent.click(screen.getByRole("button", { name: "More options" }));
+ const items = await screen.findAllByRole("menuitem");
+ return items.map((item) => item.textContent);
+}
+
+describe("DashboardMoreMenu", () => {
+ it("offers every action on a dashboard the user can edit", async () => {
+ setup({
+ dashboard: createMockDashboard({ can_write: true }),
+ isAdmin: true,
+ });
+
+ expect(await getMenuItemLabels()).toEqual([
+ "Bookmark",
+ "Verify this dashboard",
+ "Move",
+ "Duplicate",
+ "Move to trash",
+ ]);
+ });
+
+ it("offers only bookmarking and duplicating a dashboard the user cannot edit", async () => {
+ setup({ dashboard: createMockDashboard({ can_write: false }) });
+
+ expect(await getMenuItemLabels()).toEqual(["Bookmark", "Duplicate"]);
+ });
+
+ it("offers no Verify to an admin who cannot write the dashboard", async () => {
+ setup({
+ dashboard: createMockDashboard({ can_write: false }),
+ isAdmin: true,
+ });
+
+ expect(await getMenuItemLabels()).toEqual(["Bookmark", "Duplicate"]);
+ });
+
+ it("keeps Verify and Duplicate and drops the edits when remote sync is read-only", async () => {
+ setup({
+ dashboard: createMockDashboard({ can_write: true }),
+ isAdmin: true,
+ isRemoteSyncReadOnly: true,
+ });
+
+ expect(await getMenuItemLabels()).toEqual([
+ "Bookmark",
+ "Verify this dashboard",
+ "Duplicate",
+ ]);
+ });
+
+ it("is hidden on a trashed dashboard, whose banner offers its actions", () => {
+ setup({
+ dashboard: createMockDashboard({ can_write: true, archived: true }),
+ isAdmin: true,
+ });
+
+ expect(
+ screen.queryByRole("button", { name: "More options" }),
+ ).not.toBeInTheDocument();
+ });
+});
diff --git a/enterprise/frontend/src/metabase-enterprise/data-studio/library/dashboards/components/DashboardHeader/DashboardMoreMenu/index.ts b/enterprise/frontend/src/metabase-enterprise/data-studio/library/dashboards/components/DashboardHeader/DashboardMoreMenu/index.ts
new file mode 100644
index 00000000000..e0328666cb4
--- /dev/null
+++ b/enterprise/frontend/src/metabase-enterprise/data-studio/library/dashboards/components/DashboardHeader/DashboardMoreMenu/index.ts
@@ -0,0 +1 @@
+export { DashboardMoreMenu } from "./DashboardMoreMenu";
diff --git a/enterprise/frontend/src/metabase-enterprise/data-studio/library/dashboards/components/DashboardHeader/DashboardTabs.tsx b/enterprise/frontend/src/metabase-enterprise/data-studio/library/dashboards/components/DashboardHeader/DashboardTabs.tsx
index 5e1c70c483f..45b020fb024 100644
--- a/enterprise/frontend/src/metabase-enterprise/data-studio/library/dashboards/components/DashboardHeader/DashboardTabs.tsx
+++ b/enterprise/frontend/src/metabase-enterprise/data-studio/library/dashboards/components/DashboardHeader/DashboardTabs.tsx
@@ -41,6 +41,7 @@ export function DashboardTabs({ dashboardId, tabsInfo }: DashboardTabsProps) {
},
]
: []),
+ { label: t`History`, to: Urls.dataStudioDashboardHistory(dashboardId) },
{
label: t`Subscriptions`,
to: subscriptionsUrl,
diff --git a/enterprise/frontend/src/metabase-enterprise/data-studio/library/dashboards/components/DashboardHeader/utils.ts b/enterprise/frontend/src/metabase-enterprise/data-studio/library/dashboards/components/DashboardHeader/utils.ts
index d04c56d9228..8a2f05467ee 100644
--- a/enterprise/frontend/src/metabase-enterprise/data-studio/library/dashboards/components/DashboardHeader/utils.ts
+++ b/enterprise/frontend/src/metabase-enterprise/data-studio/library/dashboards/components/DashboardHeader/utils.ts
@@ -1,10 +1,16 @@
import type { CollectionEssentials } from "metabase-types/api";
-export function getDashboardFolders(
+export type DashboardLocation =
+ | { type: "library"; folders: CollectionEssentials[] }
+ | { type: "collection"; path: CollectionEssentials[] };
+
+export function getDashboardLocation(
path: CollectionEssentials[],
-): CollectionEssentials[] {
+): DashboardLocation {
const sectionIndex = path.findIndex(
(collection) => collection.type === "library-dashboards",
);
- return sectionIndex === -1 ? [] : path.slice(sectionIndex + 1);
+ return sectionIndex === -1
+ ? { type: "collection", path }
+ : { type: "library", folders: path.slice(sectionIndex + 1) };
}
diff --git a/enterprise/frontend/src/metabase-enterprise/data-studio/library/dashboards/components/DashboardHeader/utils.unit.spec.ts b/enterprise/frontend/src/metabase-enterprise/data-studio/library/dashboards/components/DashboardHeader/utils.unit.spec.ts
index b4784bd05f3..a2bb2f4b96f 100644
--- a/enterprise/frontend/src/metabase-enterprise/data-studio/library/dashboards/components/DashboardHeader/utils.unit.spec.ts
+++ b/enterprise/frontend/src/metabase-enterprise/data-studio/library/dashboards/components/DashboardHeader/utils.unit.spec.ts
@@ -1,27 +1,32 @@
import { createMockCollection } from "metabase-types/api/mocks";
-import { getDashboardFolders } from "./utils";
+import { getDashboardLocation } from "./utils";
const LIBRARY = createMockCollection({ id: 1, type: "library" });
const DASHBOARDS = createMockCollection({ id: 2, type: "library-dashboards" });
const SALES = createMockCollection({ id: 3, type: "library-dashboards" });
const EMEA = createMockCollection({ id: 4, type: "library-dashboards" });
+const EXAMPLES = createMockCollection({ id: 5, type: null });
-describe("getDashboardFolders", () => {
- it("returns the folders below the Dashboards section", () => {
- expect(getDashboardFolders([LIBRARY, DASHBOARDS, SALES, EMEA])).toEqual([
- SALES,
- EMEA,
- ]);
+describe("getDashboardLocation", () => {
+ it("is in the Library with the folders below the Dashboards section", () => {
+ expect(getDashboardLocation([LIBRARY, DASHBOARDS, SALES, EMEA])).toEqual({
+ type: "library",
+ folders: [SALES, EMEA],
+ });
});
- it("returns no folders for a dashboard at the section root", () => {
- expect(getDashboardFolders([LIBRARY, DASHBOARDS])).toEqual([]);
+ it("is in the Library with no folders at the section root", () => {
+ expect(getDashboardLocation([LIBRARY, DASHBOARDS])).toEqual({
+ type: "library",
+ folders: [],
+ });
});
- it("returns no folders outside the Dashboards section", () => {
- expect(
- getDashboardFolders([createMockCollection({ id: 5, type: null })]),
- ).toEqual([]);
+ it("is in a collection with its path outside the Dashboards section", () => {
+ expect(getDashboardLocation([EXAMPLES])).toEqual({
+ type: "collection",
+ path: [EXAMPLES],
+ });
});
});
diff --git a/enterprise/frontend/src/metabase-enterprise/data-studio/library/dashboards/pages/DashboardContentsPage/DashboardContentsPage.unit.spec.tsx b/enterprise/frontend/src/metabase-enterprise/data-studio/library/dashboards/pages/DashboardContentsPage/DashboardContentsPage.unit.spec.tsx
index 4844846db7d..f72b63615b9 100644
--- a/enterprise/frontend/src/metabase-enterprise/data-studio/library/dashboards/pages/DashboardContentsPage/DashboardContentsPage.unit.spec.tsx
+++ b/enterprise/frontend/src/metabase-enterprise/data-studio/library/dashboards/pages/DashboardContentsPage/DashboardContentsPage.unit.spec.tsx
@@ -1,6 +1,7 @@
import userEvent from "@testing-library/user-event";
import {
+ setupBookmarksEndpoints,
setupCollectionByIdEndpoint,
setupDashboardEndpoints,
setupDashboardNotFoundEndpoint,
@@ -83,6 +84,7 @@ function setup({
}: SetupOpts = {}) {
mockGetBoundingClientRect({ width: 1000, height: 800 });
setupListSubscriptionsEndpoint([]);
+ setupBookmarksEndpoints([]);
if (isNotFound) {
setupDashboardNotFoundEndpoint(dashboard);
} else {
diff --git a/enterprise/frontend/src/metabase-enterprise/data-studio/library/dashboards/pages/DashboardDependenciesPage/DashboardDependenciesPage.unit.spec.tsx b/enterprise/frontend/src/metabase-enterprise/data-studio/library/dashboards/pages/DashboardDependenciesPage/DashboardDependenciesPage.unit.spec.tsx
index 6461479067f..48faf3eaa9d 100644
--- a/enterprise/frontend/src/metabase-enterprise/data-studio/library/dashboards/pages/DashboardDependenciesPage/DashboardDependenciesPage.unit.spec.tsx
+++ b/enterprise/frontend/src/metabase-enterprise/data-studio/library/dashboards/pages/DashboardDependenciesPage/DashboardDependenciesPage.unit.spec.tsx
@@ -1,6 +1,7 @@
import userEvent from "@testing-library/user-event";
import {
+ setupBookmarksEndpoints,
setupCollectionByIdEndpoint,
setupDashboardEndpoints,
} from "__support__/server-mocks";
@@ -38,6 +39,7 @@ type SetupOpts = {
function setup({ search }: SetupOpts) {
setupDashboardEndpoints(DASHBOARD);
setupListSubscriptionsEndpoint([]);
+ setupBookmarksEndpoints([]);
setupCollectionByIdEndpoint({
collections: [createMockCollection(ROOT_COLLECTION), DASHBOARDS_COLLECTION],
});
diff --git a/enterprise/frontend/src/metabase-enterprise/data-studio/library/dashboards/pages/DashboardHistoryPage/DashboardHistoryPage.tsx b/enterprise/frontend/src/metabase-enterprise/data-studio/library/dashboards/pages/DashboardHistoryPage/DashboardHistoryPage.tsx
new file mode 100644
index 00000000000..677af362343
--- /dev/null
+++ b/enterprise/frontend/src/metabase-enterprise/data-studio/library/dashboards/pages/DashboardHistoryPage/DashboardHistoryPage.tsx
@@ -0,0 +1,31 @@
+import { ActivityTimelineCard } from "metabase/common/data-studio/components/ActivityTimelineCard";
+import type { Dashboard } from "metabase-types/api";
+
+import { DashboardPageShell } from "../../components/DashboardPageShell";
+import { useCanEditDashboard } from "../../hooks/use-can-edit-dashboard";
+
+export function DashboardHistoryPage() {
+ return (
+ <DashboardPageShell data-testid="dashboard-history-page">
+ {(dashboard) => <DashboardHistory dashboard={dashboard} />}
+ </DashboardPageShell>
+ );
+}
+
+type DashboardHistoryProps = {
+ dashboard: Dashboard;
+};
+
+function DashboardHistory({ dashboard }: DashboardHistoryProps) {
+ const canEdit = useCanEditDashboard(dashboard);
+
+ return (
+ <ActivityTimelineCard
+ entity="dashboard"
+ id={dashboard.id}
+ moderationReviews={dashboard.moderation_reviews}
+ canWrite={canEdit}
+ data-testid="dashboard-history-list"
+ />
+ );
+}
diff --git a/enterprise/frontend/src/metabase-enterprise/data-studio/library/dashboards/pages/DashboardHistoryPage/DashboardHistoryPage.unit.spec.tsx b/enterprise/frontend/src/metabase-enterprise/data-studio/library/dashboards/pages/DashboardHistoryPage/DashboardHistoryPage.unit.spec.tsx
new file mode 100644
index 00000000000..28f961b04ba
--- /dev/null
+++ b/enterprise/frontend/src/metabase-enterprise/data-studio/library/dashboards/pages/DashboardHistoryPage/DashboardHistoryPage.unit.spec.tsx
@@ -0,0 +1,124 @@
+import userEvent from "@testing-library/user-event";
+import fetchMock from "fetch-mock";
+
+import {
+ setupBookmarksEndpoints,
+ setupCollectionByIdEndpoint,
+ setupDashboardEndpoints,
+ setupEntityRevisionsEndpoint,
+ setupRevertRevisionEndpoint,
+} from "__support__/server-mocks";
+import { setupListSubscriptionsEndpoint } from "__support__/server-mocks/pulse";
+import { mockSettings } from "__support__/settings";
+import { createMockState } from "__support__/state";
+import { renderWithProviders, screen, waitFor, within } from "__support__/ui";
+import { Route } from "metabase/router";
+import {
+ createMockCollection,
+ createMockDashboard,
+ createMockRevision,
+} from "metabase-types/api/mocks";
+
+import { DashboardHistoryPage } from "./DashboardHistoryPage";
+
+const SALES = createMockCollection({
+ id: 3,
+ name: "Sales",
+ type: "library-dashboards",
+});
+
+const CREATED = createMockRevision({
+ id: 1,
+ description: "created this",
+ timestamp: "2026-05-14T10:00:00Z",
+});
+const RENAMED = createMockRevision({
+ id: 2,
+ description: "renamed it",
+ timestamp: "2026-05-16T10:00:00Z",
+ is_creation: false,
+});
+
+type SetupOpts = {
+ canWrite?: boolean;
+ isRemoteSyncReadOnly?: boolean;
+};
+
+function setup({
+ canWrite = true,
+ isRemoteSyncReadOnly = false,
+}: SetupOpts = {}) {
+ const dashboard = createMockDashboard({
+ id: 10,
+ name: "Sales overview",
+ collection_id: SALES.id,
+ can_write: canWrite,
+ dashcards: [],
+ });
+ setupListSubscriptionsEndpoint([]);
+ setupBookmarksEndpoints([]);
+ setupDashboardEndpoints(dashboard);
+ setupCollectionByIdEndpoint({ collections: [SALES] });
+ setupEntityRevisionsEndpoint("dashboard", dashboard.id, [RENAMED, CREATED]);
+ setupRevertRevisionEndpoint(CREATED);
+
+ renderWithProviders(
+ <Route
+ path="/data-studio/dashboards/:dashboardId/history"
+ element={<DashboardHistoryPage />}
+ />,
+ {
+ storeInitialState: createMockState({
+ settings: mockSettings({
+ "remote-sync-enabled": isRemoteSyncReadOnly,
+ "remote-sync-type": isRemoteSyncReadOnly ? "read-only" : undefined,
+ }),
+ }),
+ withRouter: true,
+ initialRoute: `/data-studio/dashboards/${dashboard.id}/history`,
+ },
+ );
+}
+
+describe("DashboardHistoryPage", () => {
+ it("lists the dashboard's revisions newest first and reverts to an older one", async () => {
+ setup();
+
+ const list = await screen.findByTestId("dashboard-history-list");
+ const events = within(list).getAllByTestId("revision-history-event");
+ expect(events[0]).toHaveTextContent("renamed it");
+ expect(events[1]).toHaveTextContent("created this");
+
+ await userEvent.click(within(list).getByTestId("question-revert-button"));
+
+ await waitFor(() =>
+ expect(fetchMock.callHistory.called("path:/api/revision/revert")).toBe(
+ true,
+ ),
+ );
+ const call = fetchMock.callHistory.lastCall("path:/api/revision/revert");
+ expect(await call?.request?.json()).toEqual({
+ entity: "dashboard",
+ id: 10,
+ revision_id: CREATED.id,
+ });
+ });
+
+ it.each([
+ { name: "the user cannot write the dashboard", canWrite: false },
+ { name: "remote sync is read-only", isRemoteSyncReadOnly: true },
+ ])(
+ "offers no revert when $name",
+ async ({ canWrite, isRemoteSyncReadOnly }) => {
+ setup({ canWrite, isRemoteSyncReadOnly });
+
+ const list = await screen.findByTestId("dashboard-history-list");
+ expect(
+ within(list).getAllByTestId("revision-history-event"),
+ ).toHaveLength(2);
+ expect(
+ within(list).queryByTestId("question-revert-button"),
+ ).not.toBeInTheDocument();
+ },
+ );
+});
diff --git a/enterprise/frontend/src/metabase-enterprise/data-studio/library/dashboards/pages/DashboardHistoryPage/index.ts b/enterprise/frontend/src/metabase-enterprise/data-studio/library/dashboards/pages/DashboardHistoryPage/index.ts
new file mode 100644
index 00000000000..e6bb1355f14
--- /dev/null
+++ b/enterprise/frontend/src/metabase-enterprise/data-studio/library/dashboards/pages/DashboardHistoryPage/index.ts
@@ -0,0 +1 @@
+export { DashboardHistoryPage } from "./DashboardHistoryPage";
diff --git a/enterprise/frontend/src/metabase-enterprise/data-studio/library/dashboards/pages/DashboardOverviewPage/DashboardOverviewPage.unit.spec.tsx b/enterprise/frontend/src/metabase-enterprise/data-studio/library/dashboards/pages/DashboardOverviewPage/DashboardOverviewPage.unit.spec.tsx
index b3633cc82ad..d017cced9e4 100644
--- a/enterprise/frontend/src/metabase-enterprise/data-studio/library/dashboards/pages/DashboardOverviewPage/DashboardOverviewPage.unit.spec.tsx
+++ b/enterprise/frontend/src/metabase-enterprise/data-studio/library/dashboards/pages/DashboardOverviewPage/DashboardOverviewPage.unit.spec.tsx
@@ -2,6 +2,7 @@ import userEvent from "@testing-library/user-event";
import fetchMock from "fetch-mock";
import {
+ setupBookmarksEndpoints,
setupCollectionByIdEndpoint,
setupDashboardEndpoints,
setupDashboardNotFoundEndpoint,
@@ -74,6 +75,7 @@ function setup({
...dashboardOpts,
});
setupListSubscriptionsEndpoint([]);
+ setupBookmarksEndpoints([]);
if (hasUpdateError) {
// Registered before the default endpoints so this PUT route matches first
setupUpdateDashboardEndpointWithError(dashboard.id);
diff --git a/enterprise/frontend/src/metabase-enterprise/data-studio/library/dashboards/pages/DashboardSubscriptionsPage/DashboardSubscriptionsPage.unit.spec.tsx b/enterprise/frontend/src/metabase-enterprise/data-studio/library/dashboards/pages/DashboardSubscriptionsPage/DashboardSubscriptionsPage.unit.spec.tsx
index f637ee49274..15209f4f183 100644
--- a/enterprise/frontend/src/metabase-enterprise/data-studio/library/dashboards/pages/DashboardSubscriptionsPage/DashboardSubscriptionsPage.unit.spec.tsx
+++ b/enterprise/frontend/src/metabase-enterprise/data-studio/library/dashboards/pages/DashboardSubscriptionsPage/DashboardSubscriptionsPage.unit.spec.tsx
@@ -2,6 +2,7 @@ import userEvent from "@testing-library/user-event";
import fetchMock from "fetch-mock";
import {
+ setupBookmarksEndpoints,
setupCollectionByIdEndpoint,
setupDashboardEndpoints,
} from "__support__/server-mocks";
@@ -183,6 +184,7 @@ function setup({
collections: [createMockCollection(ROOT_COLLECTION)],
});
setupListSubscriptionsEndpoint(subscriptions);
+ setupBookmarksEndpoints([]);
if (hasChannelInfoError) {
setupNotificationChannelsEndpointError();
} else {
diff --git a/enterprise/frontend/src/metabase-enterprise/data-studio/library/dashboards/pages/DashboardUsageStatsPage/DashboardUsageStatsPage.unit.spec.tsx b/enterprise/frontend/src/metabase-enterprise/data-studio/library/dashboards/pages/DashboardUsageStatsPage/DashboardUsageStatsPage.unit.spec.tsx
index 4cbd47dcb43..ce65875670b 100644
--- a/enterprise/frontend/src/metabase-enterprise/data-studio/library/dashboards/pages/DashboardUsageStatsPage/DashboardUsageStatsPage.unit.spec.tsx
+++ b/enterprise/frontend/src/metabase-enterprise/data-studio/library/dashboards/pages/DashboardUsageStatsPage/DashboardUsageStatsPage.unit.spec.tsx
@@ -2,6 +2,7 @@ import fetchMock from "fetch-mock";
import {
setupAuditInfoEndpoint,
+ setupBookmarksEndpoints,
setupCollectionByIdEndpoint,
setupDashboardEndpoints,
} from "__support__/server-mocks";
@@ -121,6 +122,7 @@ function setup({
collections: [createMockCollection(ROOT_COLLECTION)],
});
setupListSubscriptionsEndpoint([]);
+ setupBookmarksEndpoints([]);
setupAuditInfoEndpoint({
auditInfo: hasUsageAnalyticsAccess
? { dashboard_overview: AUDIT_DASHBOARD_ID }
diff --git a/enterprise/frontend/src/metabase-enterprise/data-studio/library/dashboards/routes.tsx b/enterprise/frontend/src/metabase-enterprise/data-studio/library/dashboards/routes.tsx
index 6a0bbb7854d..90c178d8f84 100644
--- a/enterprise/frontend/src/metabase-enterprise/data-studio/library/dashboards/routes.tsx
+++ b/enterprise/frontend/src/metabase-enterprise/data-studio/library/dashboards/routes.tsx
@@ -41,6 +41,13 @@ const dashboardUsageStatsPage = () =>
Component: DashboardUsageStatsPage,
}));
+const dashboardHistoryPage = () =>
+ import(
+ /* webpackChunkName: "data-studio-dashboards" */ "./pages/DashboardHistoryPage"
+ ).then(({ DashboardHistoryPage }) => ({
+ Component: DashboardHistoryPage,
+ }));
+
const dashboardSubscriptionsPage = () =>
import(
/* webpackChunkName: "data-studio-dashboards" */ "./pages/DashboardSubscriptionsPage"
@@ -65,6 +72,7 @@ export function getDataStudioDashboardRoutes() {
{PLUGIN_AUDIT.isEnabled && (
<Route path=":dashboardId/usage" lazy={dashboardUsageStatsPage} />
)}
+ <Route path=":dashboardId/history" lazy={dashboardHistoryPage} />
<Route
path=":dashboardId/subscriptions/:subscriptionId?"
lazy={dashboardSubscriptionsPage}
diff --git a/enterprise/frontend/src/metabase-enterprise/data-studio/library/dashboards/routes.unit.spec.tsx b/enterprise/frontend/src/metabase-enterprise/data-studio/library/dashboards/routes.unit.spec.tsx
index 0e52a693467..41076c54f01 100644
--- a/enterprise/frontend/src/metabase-enterprise/data-studio/library/dashboards/routes.unit.spec.tsx
+++ b/enterprise/frontend/src/metabase-enterprise/data-studio/library/dashboards/routes.unit.spec.tsx
@@ -1,6 +1,7 @@
import { setupEnterpriseOnlyPlugin } from "__support__/enterprise";
import {
setupAuditInfoEndpoint,
+ setupBookmarksEndpoints,
setupCollectionByIdEndpoint,
setupDashboardEndpoints,
} from "__support__/server-mocks";
@@ -43,6 +44,7 @@ function setup({ initialRoute, hasUsageAnalyticsAccess = true }: SetupOpts) {
setupDashboardEndpoints(DASHBOARD);
setupDashboardEndpoints(AUDIT_DASHBOARD);
setupListSubscriptionsEndpoint([]);
+ setupBookmarksEndpoints([]);
setupNotificationChannelsEndpoints({});
setupAuditInfoEndpoint({
auditInfo: hasUsageAnalyticsAccess
@@ -157,7 +159,7 @@ describe("Data Studio dashboard routes with the audit app plugin", () => {
setupEnterpriseOnlyPlugin("audit_app");
});
- it("puts the Usage stats tab between Dependencies and Subscriptions", async () => {
+ it("puts the Usage stats tab between Dependencies and History", async () => {
setup({ initialRoute: CONTENTS_PATH });
const header = await screen.findByTestId("dashboard-pane-header");
@@ -174,6 +176,7 @@ describe("Data Studio dashboard routes with the audit app plugin", () => {
"Contents",
"Dependencies",
"Usage stats",
+ "History",
"Subscriptions",
]);
});
diff --git a/enterprise/frontend/src/metabase-enterprise/data-studio/library/tables/components/TableHeader/TableMoreMenu/TableMoreMenu.tsx b/enterprise/frontend/src/metabase-enterprise/data-studio/library/tables/components/TableHeader/TableMoreMenu/TableMoreMenu.tsx
index 2c24890e740..1f63b0759b1 100644
--- a/enterprise/frontend/src/metabase-enterprise/data-studio/library/tables/components/TableHeader/TableMoreMenu/TableMoreMenu.tsx
+++ b/enterprise/frontend/src/metabase-enterprise/data-studio/library/tables/components/TableHeader/TableMoreMenu/TableMoreMenu.tsx
@@ -1,9 +1,10 @@
import { c, t } from "ttag";
import { ForwardRefLink } from "metabase/common/components/Link";
+import { MoreMenuButton } from "metabase/common/data-studio/components/MoreMenuButton";
import { PLUGIN_REMOTE_SYNC } from "metabase/plugins";
import { useSelector } from "metabase/redux";
-import { ActionIcon, Box, FixedSizeIcon, Icon, Menu } from "metabase/ui";
+import { Box, Icon, Menu } from "metabase/ui";
import * as Urls from "metabase/urls";
import type { TableModalState, TableModalTable } from "../../TableModal";
@@ -28,16 +29,12 @@ export function TableMoreMenu({ table, onOpenModal }: TableMoreMenuProps) {
>
<Menu withinPortal>
<Menu.Target>
- <ActionIcon
- variant="subtle"
+ <MoreMenuButton
aria-label={t`Show table options`}
- size="md"
onClick={(event) => {
event.preventDefault();
}}
- >
- <FixedSizeIcon name="ellipsis" size={16} />
- </ActionIcon>
+ />
</Menu.Target>
<Menu.Dropdown>
{dbId != null && (
diff --git a/frontend/src/metabase/common/components/RevisionHistoryTimeline/utils.ts b/frontend/src/metabase/common/components/RevisionHistoryTimeline/utils.ts
index 0604767a1c6..8b5e75ed422 100644
--- a/frontend/src/metabase/common/components/RevisionHistoryTimeline/utils.ts
+++ b/frontend/src/metabase/common/components/RevisionHistoryTimeline/utils.ts
@@ -1,6 +1,10 @@
import { t } from "ttag";
-import type { Revision, User } from "metabase-types/api";
+import {
+ PLUGIN_MODERATION,
+ type RevisionOrModerationEvent,
+} from "metabase/plugins";
+import type { ModerationReview, Revision, User } from "metabase-types/api";
export function getTimelineEvents({
revisions = [],
@@ -29,3 +33,23 @@ export function getTimelineEvents({
};
});
}
+
+export function getActivityTimelineEvents({
+ revisions,
+ moderationReviews = [],
+ currentUser,
+}: {
+ revisions: Revision[] | undefined;
+ moderationReviews?: ModerationReview[];
+ currentUser: User | null;
+}): RevisionOrModerationEvent[] {
+ return [
+ ...getTimelineEvents({ revisions, currentUser }),
+ ...PLUGIN_MODERATION.getModerationTimelineEvents(
+ moderationReviews,
+ currentUser,
+ ),
+ ].sort(
+ (a, b) => new Date(b.timestamp).getTime() - new Date(a.timestamp).getTime(),
+ );
+}
diff --git a/frontend/src/metabase/common/components/RevisionHistoryTimeline/utils.unit.spec.ts b/frontend/src/metabase/common/components/RevisionHistoryTimeline/utils.unit.spec.ts
new file mode 100644
index 00000000000..2b7f1af36c2
--- /dev/null
+++ b/frontend/src/metabase/common/components/RevisionHistoryTimeline/utils.unit.spec.ts
@@ -0,0 +1,68 @@
+import { setupEnterpriseOnlyPlugin } from "__support__/enterprise";
+import { mockSettings } from "__support__/settings";
+import {
+ createMockModerationReview,
+ createMockRevision,
+ createMockTokenFeatures,
+ createMockUser,
+} from "metabase-types/api/mocks";
+
+import { getActivityTimelineEvents } from "./utils";
+
+const CURRENT_USER = createMockUser({ id: 1 });
+
+const CREATED = createMockRevision({
+ id: 1,
+ description: "created this",
+ timestamp: "2026-05-14T10:00:00Z",
+ user: { id: 1, first_name: "Me", last_name: "Myself", common_name: "Me" },
+});
+
+const RENAMED = createMockRevision({
+ id: 2,
+ description: "renamed it",
+ timestamp: "2026-05-16T10:00:00Z",
+ is_creation: false,
+ user: {
+ id: 2,
+ first_name: "Bobby",
+ last_name: "Tables",
+ common_name: "Bobby Tables",
+ },
+});
+
+const VERIFIED = createMockModerationReview({
+ created_at: "2026-05-15T10:00:00Z",
+});
+
+describe("getActivityTimelineEvents", () => {
+ beforeEach(() => {
+ mockSettings({
+ "token-features": createMockTokenFeatures({ content_verification: true }),
+ });
+ setupEnterpriseOnlyPlugin("moderation");
+ });
+
+ it("merges revisions and moderation reviews newest first", () => {
+ const events = getActivityTimelineEvents({
+ revisions: [CREATED, RENAMED],
+ moderationReviews: [VERIFIED],
+ currentUser: CURRENT_USER,
+ });
+
+ expect(events.map((event) => event.title)).toEqual([
+ "Bobby Tables renamed it",
+ expect.stringContaining("verified this"),
+ "You created this",
+ ]);
+ });
+
+ it("lists revisions alone when there are no reviews", () => {
+ const events = getActivityTimelineEvents({
+ revisions: [CREATED],
+ currentUser: CURRENT_USER,
+ });
+
+ expect(events.map((event) => event.title)).toEqual(["You created this"]);
+ });
+});
diff --git a/frontend/src/metabase/metrics/pages/MetricHistoryPage/MetricHistoryPage.module.css b/frontend/src/metabase/common/data-studio/components/ActivityTimelineCard/ActivityTimelineCard.module.css
similarity index 100%
rename from frontend/src/metabase/metrics/pages/MetricHistoryPage/MetricHistoryPage.module.css
rename to frontend/src/metabase/common/data-studio/components/ActivityTimelineCard/ActivityTimelineCard.module.css
diff --git a/frontend/src/metabase/common/data-studio/components/ActivityTimelineCard/ActivityTimelineCard.tsx b/frontend/src/metabase/common/data-studio/components/ActivityTimelineCard/ActivityTimelineCard.tsx
new file mode 100644
index 00000000000..559e7172994
--- /dev/null
+++ b/frontend/src/metabase/common/data-studio/components/ActivityTimelineCard/ActivityTimelineCard.tsx
@@ -0,0 +1,75 @@
+import { useMemo } from "react";
+import { t } from "ttag";
+
+import { useListRevisionsQuery, useRevertRevisionMutation } from "metabase/api";
+import { LoadingAndErrorWrapper } from "metabase/common/components/LoadingAndErrorWrapper";
+import { RevisionHistoryTimeline } from "metabase/common/components/RevisionHistoryTimeline";
+import { getActivityTimelineEvents } from "metabase/common/components/RevisionHistoryTimeline/utils";
+import { getUser } from "metabase/current-user";
+import { useSelector } from "metabase/redux";
+import { Box, Card, Text } from "metabase/ui";
+import type { CardId, DashboardId, ModerationReview } from "metabase-types/api";
+
+import S from "./ActivityTimelineCard.module.css";
+
+type ActivityTimelineTarget =
+ | { entity: "card"; id: CardId }
+ | { entity: "dashboard"; id: DashboardId };
+
+type ActivityTimelineCardProps = ActivityTimelineTarget & {
+ moderationReviews?: ModerationReview[];
+ canWrite: boolean;
+ "data-testid": string;
+};
+
+export function ActivityTimelineCard(props: ActivityTimelineCardProps) {
+ return (
+ <Card withBorder shadow="none" p="lg" flex={1} className={S.card}>
+ <Box maw={800} pt="lg" px="lg">
+ <ActivityTimeline {...props} />
+ </Box>
+ </Card>
+ );
+}
+
+function ActivityTimeline({
+ entity,
+ id,
+ moderationReviews,
+ canWrite,
+ "data-testid": dataTestId,
+}: ActivityTimelineCardProps) {
+ const currentUser = useSelector(getUser);
+ const {
+ data: revisions,
+ isLoading,
+ error,
+ } = useListRevisionsQuery({ entity, id });
+ const [revertRevision] = useRevertRevisionMutation();
+
+ const events = useMemo(
+ () =>
+ getActivityTimelineEvents({ revisions, moderationReviews, currentUser }),
+ [moderationReviews, revisions, currentUser],
+ );
+
+ if (isLoading || error != null) {
+ return <LoadingAndErrorWrapper loading={isLoading} error={error} />;
+ }
+
+ if (events.length === 0) {
+ return <Text c="text-secondary">{t`No revision history available.`}</Text>;
+ }
+
+ return (
+ <RevisionHistoryTimeline
+ entity={entity}
+ events={events}
+ revert={(revision) =>
+ revertRevision({ entity, id, revision_id: revision.id }).unwrap()
+ }
+ canWrite={canWrite}
+ data-testid={dataTestId}
+ />
+ );
+}
diff --git a/frontend/src/metabase/common/data-studio/components/ActivityTimelineCard/ActivityTimelineCard.unit.spec.tsx b/frontend/src/metabase/common/data-studio/components/ActivityTimelineCard/ActivityTimelineCard.unit.spec.tsx
new file mode 100644
index 00000000000..5ac9f317f04
--- /dev/null
+++ b/frontend/src/metabase/common/data-studio/components/ActivityTimelineCard/ActivityTimelineCard.unit.spec.tsx
@@ -0,0 +1,135 @@
+import userEvent from "@testing-library/user-event";
+import fetchMock from "fetch-mock";
+
+import { setupEnterpriseOnlyPlugin } from "__support__/enterprise";
+import {
+ setupEntityRevisionsEndpoint,
+ setupRevertRevisionEndpoint,
+} from "__support__/server-mocks";
+import { mockSettings } from "__support__/settings";
+import { createMockState } from "__support__/state";
+import { renderWithProviders, screen, waitFor } from "__support__/ui";
+import type { ModerationReview, Revision } from "metabase-types/api";
+import {
+ createMockModerationReview,
+ createMockRevision,
+ createMockTokenFeatures,
+ createMockUser,
+} from "metabase-types/api/mocks";
+
+import { ActivityTimelineCard } from "./ActivityTimelineCard";
+
+const DASHBOARD_ID = 10;
+
+const CREATED = createMockRevision({
+ id: 1,
+ description: "created this",
+ timestamp: "2026-05-14T10:00:00Z",
+ user: { id: 1, first_name: "Me", last_name: "Myself", common_name: "Me" },
+});
+
+const RENAMED = createMockRevision({
+ id: 2,
+ description: "renamed it",
+ timestamp: "2026-05-16T10:00:00Z",
+ is_creation: false,
+ user: {
+ id: 2,
+ first_name: "Bobby",
+ last_name: "Tables",
+ common_name: "Bobby Tables",
+ },
+});
+
+const VERIFIED = createMockModerationReview({
+ created_at: "2026-05-15T10:00:00Z",
+ user: createMockUser({ id: 2, common_name: "Bobby Tables" }),
+});
+
+type SetupOpts = {
+ revisions?: Revision[];
+ moderationReviews?: ModerationReview[];
+ canWrite?: boolean;
+};
+
+function setup({
+ revisions = [RENAMED, CREATED],
+ moderationReviews = [],
+ canWrite = true,
+}: SetupOpts = {}) {
+ const settings = mockSettings({
+ "token-features": createMockTokenFeatures({ content_verification: true }),
+ });
+ setupEnterpriseOnlyPlugin("moderation");
+ setupEntityRevisionsEndpoint("dashboard", DASHBOARD_ID, revisions);
+ setupRevertRevisionEndpoint(CREATED);
+
+ renderWithProviders(
+ <ActivityTimelineCard
+ entity="dashboard"
+ id={DASHBOARD_ID}
+ moderationReviews={moderationReviews}
+ canWrite={canWrite}
+ data-testid="history-list"
+ />,
+ {
+ storeInitialState: createMockState({
+ settings,
+ currentUser: createMockUser({ id: 1 }),
+ }),
+ },
+ );
+}
+
+async function findEvents() {
+ await screen.findByTestId("history-list");
+ return screen.getAllByTestId("revision-history-event");
+}
+
+describe("ActivityTimelineCard", () => {
+ it("lists revisions and moderation events newest first", async () => {
+ setup({ moderationReviews: [VERIFIED] });
+
+ const events = await findEvents();
+ expect(events).toHaveLength(3);
+ expect(events[0]).toHaveTextContent("Bobby Tables renamed it");
+ expect(events[1]).toHaveTextContent("verified this");
+ expect(events[2]).toHaveTextContent("You created this");
+ });
+
+ it("reverts to an older revision of the entity", async () => {
+ setup();
+
+ await findEvents();
+ await userEvent.click(screen.getByTestId("question-revert-button"));
+
+ await waitFor(() =>
+ expect(fetchMock.callHistory.called("path:/api/revision/revert")).toBe(
+ true,
+ ),
+ );
+ const call = fetchMock.callHistory.lastCall("path:/api/revision/revert");
+ expect(await call?.request?.json()).toEqual({
+ entity: "dashboard",
+ id: DASHBOARD_ID,
+ revision_id: CREATED.id,
+ });
+ });
+
+ it("offers no revert to a user who cannot write", async () => {
+ setup({ canWrite: false });
+
+ expect(await findEvents()).toHaveLength(2);
+ expect(
+ screen.queryByTestId("question-revert-button"),
+ ).not.toBeInTheDocument();
+ });
+
+ it("says when there is no history", async () => {
+ setup({ revisions: [] });
+
+ expect(
+ await screen.findByText("No revision history available."),
+ ).toBeInTheDocument();
+ });
+});
diff --git a/frontend/src/metabase/common/data-studio/components/ActivityTimelineCard/index.ts b/frontend/src/metabase/common/data-studio/components/ActivityTimelineCard/index.ts
new file mode 100644
index 00000000000..3e768be6386
--- /dev/null
+++ b/frontend/src/metabase/common/data-studio/components/ActivityTimelineCard/index.ts
@@ -0,0 +1 @@
+export * from "./ActivityTimelineCard";
diff --git a/frontend/src/metabase/common/data-studio/components/MoreMenuButton/MoreMenuButton.tsx b/frontend/src/metabase/common/data-studio/components/MoreMenuButton/MoreMenuButton.tsx
new file mode 100644
index 00000000000..bc4ce37d6e1
--- /dev/null
+++ b/frontend/src/metabase/common/data-studio/components/MoreMenuButton/MoreMenuButton.tsx
@@ -0,0 +1,21 @@
+import { forwardRef } from "react";
+
+import { ActionIcon, type ActionIconProps, Icon } from "metabase/ui";
+
+type MoreMenuButtonProps = Omit<
+ ActionIconProps,
+ "variant" | "size" | "children"
+> & {
+ "aria-label": string;
+};
+
+export const MoreMenuButton = forwardRef<
+ HTMLButtonElement,
+ MoreMenuButtonProps
+>(function MoreMenuButton(props, ref) {
+ return (
+ <ActionIcon ref={ref} variant="subtle" size="md" {...props}>
+ <Icon name="ellipsis" />
+ </ActionIcon>
+ );
+});
diff --git a/frontend/src/metabase/common/data-studio/components/MoreMenuButton/index.ts b/frontend/src/metabase/common/data-studio/components/MoreMenuButton/index.ts
new file mode 100644
index 00000000000..cf1630e13cd
--- /dev/null
+++ b/frontend/src/metabase/common/data-studio/components/MoreMenuButton/index.ts
@@ -0,0 +1 @@
+export * from "./MoreMenuButton";
diff --git a/frontend/src/metabase/common/data-studio/components/PaneHeader/PaneHeader.tsx b/frontend/src/metabase/common/data-studio/components/PaneHeader/PaneHeader.tsx
index 6a2ec0664ac..96f30f82ede 100644
--- a/frontend/src/metabase/common/data-studio/components/PaneHeader/PaneHeader.tsx
+++ b/frontend/src/metabase/common/data-studio/components/PaneHeader/PaneHeader.tsx
@@ -59,7 +59,12 @@ export const PaneHeader = ({
<Group align="center" gap="sm" wrap="nowrap">
{icon && <FixedSizeIcon name={icon} c="core-brand" size={20} />}
{title}
- {menu}
+ {menu && (
+ // The menu button is taller than the title, keep it from growing the header
+ <Flex h="var(--mantine-h3-line-height)" align="center">
+ {menu}
+ </Flex>
+ )}
</Group>
)}
{tabs}
diff --git a/frontend/src/metabase/common/data-studio/hooks/use-collection-path/useCollectionPath.ts b/frontend/src/metabase/common/data-studio/hooks/use-collection-path/useCollectionPath.ts
index 0f472412bd8..55be7188ced 100644
--- a/frontend/src/metabase/common/data-studio/hooks/use-collection-path/useCollectionPath.ts
+++ b/frontend/src/metabase/common/data-studio/hooks/use-collection-path/useCollectionPath.ts
@@ -14,14 +14,16 @@ export const useCollectionPath = ({
collectionId,
namespace,
}: UseCollectionPathOptions) => {
- const { currentData: collection, isLoading: isLoadingPath } =
- useGetCollectionQuery({ id: collectionId ?? "root", namespace });
+ const { currentData: collection, isFetching } = useGetCollectionQuery({
+ id: collectionId ?? "root",
+ namespace,
+ });
const ancestors =
collection?.effective_ancestors?.filter((c) => !isRootCollection(c)) ?? [];
return {
- isLoadingPath,
+ isLoadingPath: collection == null && isFetching,
path: collection ? [...ancestors, collection] : null,
};
};
diff --git a/frontend/src/metabase/common/data-studio/hooks/use-collection-path/useCollectionPath.unit.spec.tsx b/frontend/src/metabase/common/data-studio/hooks/use-collection-path/useCollectionPath.unit.spec.tsx
new file mode 100644
index 00000000000..a9c69504daf
--- /dev/null
+++ b/frontend/src/metabase/common/data-studio/hooks/use-collection-path/useCollectionPath.unit.spec.tsx
@@ -0,0 +1,52 @@
+import { setupCollectionByIdEndpoint } from "__support__/server-mocks";
+import { renderHookWithProviders, waitFor } from "__support__/ui";
+import type { CollectionId } from "metabase-types/api";
+import { createMockCollection } from "metabase-types/api/mocks";
+
+import { useCollectionPath } from "./useCollectionPath";
+
+const LIBRARY = createMockCollection({
+ id: 1,
+ name: "Library",
+ type: "library",
+});
+const SALES = createMockCollection({
+ id: 3,
+ name: "Sales",
+ effective_ancestors: [LIBRARY],
+});
+const EXAMPLES = createMockCollection({ id: 5, name: "Examples" });
+
+function setup(collectionId: CollectionId) {
+ setupCollectionByIdEndpoint({ collections: [LIBRARY, SALES, EXAMPLES] });
+
+ return renderHookWithProviders(
+ ({ collectionId }: { collectionId: CollectionId }) =>
+ useCollectionPath({ collectionId }),
+ { initialProps: { collectionId } },
+ );
+}
+
+describe("useCollectionPath", () => {
+ it("loads the collection and its ancestors", async () => {
+ const { result } = setup(SALES.id);
+
+ expect(result.current).toEqual({ isLoadingPath: true, path: null });
+ await waitFor(() => expect(result.current.isLoadingPath).toBe(false));
+ expect(result.current.path?.map((c) => c.name)).toEqual([
+ "Library",
+ "Sales",
+ ]);
+ });
+
+ it("is loading again, with no stale path, while a new collection loads", async () => {
+ const { result, rerender } = setup(SALES.id);
+ await waitFor(() => expect(result.current.isLoadingPath).toBe(false));
+
+ rerender({ collectionId: EXAMPLES.id });
+
+ expect(result.current).toEqual({ isLoadingPath: true, path: null });
+ await waitFor(() => expect(result.current.isLoadingPath).toBe(false));
+ expect(result.current.path?.map((c) => c.name)).toEqual(["Examples"]);
+ });
+});
diff --git a/frontend/src/metabase/dashboard/components/DashboardInfoSidebar/DashboardInfoSidebar.tsx b/frontend/src/metabase/dashboard/components/DashboardInfoSidebar/DashboardInfoSidebar.tsx
index 6a5fdb1373e..5676ed51cc2 100644
--- a/frontend/src/metabase/dashboard/components/DashboardInfoSidebar/DashboardInfoSidebar.tsx
+++ b/frontend/src/metabase/dashboard/components/DashboardInfoSidebar/DashboardInfoSidebar.tsx
@@ -8,7 +8,7 @@ import { skipToken, useListRevisionsQuery } from "metabase/api";
import { isInstanceAnalyticsCollection } from "metabase/common/collections/utils";
import ErrorBoundary from "metabase/common/components/ErrorBoundary";
import { RevisionHistoryTimeline } from "metabase/common/components/RevisionHistoryTimeline";
-import { getTimelineEvents } from "metabase/common/components/RevisionHistoryTimeline/utils";
+import { getActivityTimelineEvents } from "metabase/common/components/RevisionHistoryTimeline/utils";
import {
SIDESHEET_HORIZONTAL_PADDING,
Sidesheet,
@@ -238,18 +238,11 @@ const HistoryTab = ({
}) => {
const dispatch = useDispatch();
- const events = useMemo(() => {
- const moderationEvents = PLUGIN_MODERATION.getModerationTimelineEvents(
- moderationReviews,
- currentUser,
- );
- const revisionEvents = getTimelineEvents({ revisions, currentUser });
-
- return [...revisionEvents, ...moderationEvents].sort(
- (a, b) =>
- new Date(b.timestamp).getTime() - new Date(a.timestamp).getTime(),
- );
- }, [moderationReviews, revisions, currentUser]);
+ const events = useMemo(
+ () =>
+ getActivityTimelineEvents({ revisions, moderationReviews, currentUser }),
+ [moderationReviews, revisions, currentUser],
+ );
return (
<SidesheetCard>
diff --git a/frontend/src/metabase/dashboard/components/DashboardMoveModal.tsx b/frontend/src/metabase/dashboard/components/DashboardMoveModal.tsx
index 7292e9043d0..71f2168fbdc 100644
--- a/frontend/src/metabase/dashboard/components/DashboardMoveModal.tsx
+++ b/frontend/src/metabase/dashboard/components/DashboardMoveModal.tsx
@@ -17,7 +17,7 @@ import type { CollectionId, Dashboard } from "metabase-types/api";
import S from "./DashboardMoveModal.module.css";
-function DashboardMoveModal({
+export function DashboardMoveModal({
dashboard,
onClose,
}: {
diff --git a/frontend/src/metabase/dashboard/containers/ArchiveDashboardModal.tsx b/frontend/src/metabase/dashboard/containers/ArchiveDashboardModal.tsx
index db69d8aad9d..4649309e9c9 100644
--- a/frontend/src/metabase/dashboard/containers/ArchiveDashboardModal.tsx
+++ b/frontend/src/metabase/dashboard/containers/ArchiveDashboardModal.tsx
@@ -17,19 +17,20 @@ type OwnProps = {
type ArchiveDashboardModalProps = OwnProps & {
dashboard: Dashboard;
+ onArchive: () => Promise<unknown>;
};
-const ArchiveDashboardModal = ({
+export const ArchiveDashboardModal = ({
onClose,
dashboard,
+ onArchive,
}: ArchiveDashboardModalProps) => {
const [loading, setLoading] = useState(false);
- const dispatch = useDispatch();
const archive = async () => {
setLoading(true);
try {
- await dispatch(setArchivedDashboard(true));
+ await onArchive();
} finally {
setLoading(false);
}
@@ -57,6 +58,7 @@ const ArchiveDashboardModal = ({
};
export const ArchiveDashboardModalConnectedInner = (props: OwnProps) => {
+ const dispatch = useDispatch();
const params = useParams();
const id = Urls.extractCollectionId(params?.slug);
const { currentData: dashboard, error } = useGetDashboardQuery(
@@ -70,7 +72,11 @@ export const ArchiveDashboardModalConnectedInner = (props: OwnProps) => {
noWrapper
>
{dashboard && (
- <ArchiveDashboardModal onClose={props.onClose} dashboard={dashboard} />
+ <ArchiveDashboardModal
+ dashboard={dashboard}
+ onArchive={() => dispatch(setArchivedDashboard(true))}
+ onClose={props.onClose}
+ />
)}
</LoadingAndErrorWrapper>
);
diff --git a/frontend/src/metabase/data-studio/actions/components/ActionHeader/ActionMoreMenu/ActionMoreMenu.tsx b/frontend/src/metabase/data-studio/actions/components/ActionHeader/ActionMoreMenu/ActionMoreMenu.tsx
index 7ce4cb09614..eaa90d167ea 100644
--- a/frontend/src/metabase/data-studio/actions/components/ActionHeader/ActionMoreMenu/ActionMoreMenu.tsx
+++ b/frontend/src/metabase/data-studio/actions/components/ActionHeader/ActionMoreMenu/ActionMoreMenu.tsx
@@ -2,10 +2,11 @@ import { useState } from "react";
import { t } from "ttag";
import { useUpdateActionMutation } from "metabase/api";
+import { MoreMenuButton } from "metabase/common/data-studio/components/MoreMenuButton";
import { useMetadataToasts } from "metabase/common/hooks";
import { useConfirmation } from "metabase/common/hooks/use-confirmation";
import { useNavigate } from "metabase/router";
-import { ActionIcon, Icon, Menu } from "metabase/ui";
+import { Icon, Menu } from "metabase/ui";
import * as Urls from "metabase/urls";
import type { WritebackAction } from "metabase-types/api";
@@ -47,9 +48,7 @@ export function ActionMoreMenu({ action }: ActionMoreMenuProps) {
<>
<Menu>
<Menu.Target>
- <ActionIcon variant="subtle" size="sm" aria-label={t`Action options`}>
- <Icon name="ellipsis" />
- </ActionIcon>
+ <MoreMenuButton aria-label={t`Action options`} />
</Menu.Target>
<Menu.Dropdown>
<Menu.Item
diff --git a/frontend/src/metabase/data-studio/common/components/MoreMenu/MoreMenu.tsx b/frontend/src/metabase/data-studio/common/components/MoreMenu/MoreMenu.tsx
index ead49663dee..7526cd261e3 100644
--- a/frontend/src/metabase/data-studio/common/components/MoreMenu/MoreMenu.tsx
+++ b/frontend/src/metabase/data-studio/common/components/MoreMenu/MoreMenu.tsx
@@ -3,7 +3,8 @@ import { t } from "ttag";
import { ConfirmModal } from "metabase/common/components/ConfirmModal";
import { Link } from "metabase/common/components/Link";
-import { ActionIcon, Icon, Menu } from "metabase/ui";
+import { MoreMenuButton } from "metabase/common/data-studio/components/MoreMenuButton";
+import { Icon, Menu } from "metabase/ui";
type MoreMenuProps = {
previewUrl?: string;
@@ -40,9 +41,7 @@ export function MoreMenu({
<>
<Menu>
<Menu.Target>
- <ActionIcon variant="subtle" aria-label={ariaLabel}>
- <Icon name="ellipsis" />
- </ActionIcon>
+ <MoreMenuButton aria-label={ariaLabel} />
</Menu.Target>
<Menu.Dropdown>
{previewUrl && (
diff --git a/frontend/src/metabase/data-studio/measures/pages/MeasureRevisionHistoryPage/MeasureRevisionHistory/MeasureRevisionHistory.unit.spec.tsx b/frontend/src/metabase/data-studio/measures/pages/MeasureRevisionHistoryPage/MeasureRevisionHistory/MeasureRevisionHistory.unit.spec.tsx
index 516ed0b75eb..1999baa5f2d 100644
--- a/frontend/src/metabase/data-studio/measures/pages/MeasureRevisionHistoryPage/MeasureRevisionHistory/MeasureRevisionHistory.unit.spec.tsx
+++ b/frontend/src/metabase/data-studio/measures/pages/MeasureRevisionHistoryPage/MeasureRevisionHistory/MeasureRevisionHistory.unit.spec.tsx
@@ -1,6 +1,6 @@
import fetchMock from "fetch-mock";
-import { setupMeasureRevisionsEndpoint } from "__support__/server-mocks";
+import { setupEntityRevisionsEndpoint } from "__support__/server-mocks";
import { createMockState } from "__support__/state";
import {
renderWithProviders,
@@ -41,7 +41,7 @@ function setup({
body: "Server error",
});
} else {
- setupMeasureRevisionsEndpoint(measure.id, revisions);
+ setupEntityRevisionsEndpoint("measure", measure.id, revisions);
}
const storeInitialState = createMockState({
diff --git a/frontend/src/metabase/data-studio/segments/pages/SegmentRevisionHistoryPage/SegmentRevisionHistory/SegmentRevisionHistory.unit.spec.tsx b/frontend/src/metabase/data-studio/segments/pages/SegmentRevisionHistoryPage/SegmentRevisionHistory/SegmentRevisionHistory.unit.spec.tsx
index 011277dbba5..79a15016803 100644
--- a/frontend/src/metabase/data-studio/segments/pages/SegmentRevisionHistoryPage/SegmentRevisionHistory/SegmentRevisionHistory.unit.spec.tsx
+++ b/frontend/src/metabase/data-studio/segments/pages/SegmentRevisionHistoryPage/SegmentRevisionHistory/SegmentRevisionHistory.unit.spec.tsx
@@ -1,5 +1,5 @@
import {
- setupSegmentRevisionsEndpoint,
+ setupEntityRevisionsEndpoint,
setupSegmentRevisionsEndpointError,
} from "__support__/server-mocks";
import { createMockState } from "__support__/state";
@@ -39,7 +39,7 @@ function setup({
if (hasError) {
setupSegmentRevisionsEndpointError(segment.id);
} else {
- setupSegmentRevisionsEndpoint(segment.id, revisions);
+ setupEntityRevisionsEndpoint("segment", segment.id, revisions);
}
const storeInitialState = createMockState({
diff --git a/frontend/src/metabase/data-studio/snippets/components/SnippetHeader/SnippetMoreMenu/SnippetMoreMenu.tsx b/frontend/src/metabase/data-studio/snippets/components/SnippetHeader/SnippetMoreMenu/SnippetMoreMenu.tsx
index 44fb113d73d..b8ed6d49e36 100644
--- a/frontend/src/metabase/data-studio/snippets/components/SnippetHeader/SnippetMoreMenu/SnippetMoreMenu.tsx
+++ b/frontend/src/metabase/data-studio/snippets/components/SnippetHeader/SnippetMoreMenu/SnippetMoreMenu.tsx
@@ -1,8 +1,9 @@
import { useState } from "react";
import { c, t } from "ttag";
+import { MoreMenuButton } from "metabase/common/data-studio/components/MoreMenuButton";
import { PLUGIN_SNIPPET_FOLDERS } from "metabase/plugins";
-import { ActionIcon, Icon, Menu } from "metabase/ui";
+import { Icon, Menu } from "metabase/ui";
import type { NativeQuerySnippet } from "metabase-types/api";
import { SnippetModal, type SnippetModalType } from "./SnippetModal";
@@ -77,13 +78,7 @@ function SnippetMenu({ onOpenModal, snippet }: SnippetMenuProps) {
return (
<Menu>
<Menu.Target>
- <ActionIcon
- variant="subtle"
- size="sm"
- aria-label={t`Snippet menu options`}
- >
- <Icon name="ellipsis" />
- </ActionIcon>
+ <MoreMenuButton aria-label={t`Snippet menu options`} />
</Menu.Target>
<Menu.Dropdown>{menuItems}</Menu.Dropdown>
</Menu>
diff --git a/frontend/src/metabase/documents/components/DocumentRevisionHistorySidebar.unit.spec.tsx b/frontend/src/metabase/documents/components/DocumentRevisionHistorySidebar.unit.spec.tsx
index 81da465b93c..f3090171917 100644
--- a/frontend/src/metabase/documents/components/DocumentRevisionHistorySidebar.unit.spec.tsx
+++ b/frontend/src/metabase/documents/components/DocumentRevisionHistorySidebar.unit.spec.tsx
@@ -1,7 +1,7 @@
import userEvent from "@testing-library/user-event";
import {
- setupDocumentRevisionsEndpoint,
+ setupEntityRevisionsEndpoint,
setupUsersEndpoints,
} from "__support__/server-mocks";
import { createMockState } from "__support__/state";
@@ -64,7 +64,7 @@ function setup({
const onClose = jest.fn();
const currentUser = mockUser;
- setupDocumentRevisionsEndpoint(document.id, revisions);
+ setupEntityRevisionsEndpoint("document", document.id, revisions);
setupUsersEndpoints([currentUser]);
const state = createMockState({
diff --git a/frontend/src/metabase/metrics/components/MetricActivityTimeline/MetricActivityTimeline.tsx b/frontend/src/metabase/metrics/components/MetricActivityTimeline/MetricActivityTimeline.tsx
deleted file mode 100644
index 4c502c9bc1d..00000000000
--- a/frontend/src/metabase/metrics/components/MetricActivityTimeline/MetricActivityTimeline.tsx
+++ /dev/null
@@ -1,59 +0,0 @@
-import { useMemo } from "react";
-
-import { useListRevisionsQuery, useRevertRevisionMutation } from "metabase/api";
-import { LoadingAndErrorWrapper } from "metabase/common/components/LoadingAndErrorWrapper";
-import { RevisionHistoryTimeline } from "metabase/common/components/RevisionHistoryTimeline";
-import { getTimelineEvents } from "metabase/common/components/RevisionHistoryTimeline/utils";
-import { getUser } from "metabase/current-user";
-import { PLUGIN_MODERATION } from "metabase/plugins";
-import { useSelector } from "metabase/redux";
-import type { Card } from "metabase-types/api";
-
-interface MetricActivityTimelineProps {
- card: Card;
-}
-
-export function MetricActivityTimeline({ card }: MetricActivityTimelineProps) {
- const {
- data: revisions,
- isLoading,
- error,
- } = useListRevisionsQuery({
- id: card.id,
- entity: "card",
- });
- const [revertRevision] = useRevertRevisionMutation();
- const currentUser = useSelector(getUser);
-
- const events = useMemo(() => {
- const moderationEvents = PLUGIN_MODERATION.getModerationTimelineEvents(
- card.moderation_reviews,
- currentUser,
- );
- const revisionEvents = getTimelineEvents({ revisions, currentUser });
- return [...revisionEvents, ...moderationEvents].sort(
- (a, b) =>
- new Date(b.timestamp).getTime() - new Date(a.timestamp).getTime(),
- );
- }, [card.moderation_reviews, revisions, currentUser]);
-
- if (isLoading || error) {
- return <LoadingAndErrorWrapper loading={isLoading} error={error} />;
- }
-
- return (
- <RevisionHistoryTimeline
- events={events}
- data-testid="saved-question-history-list"
- revert={(revision) =>
- revertRevision({
- entity: "card",
- id: card.id,
- revision_id: revision.id,
- }).unwrap()
- }
- canWrite={card.can_write}
- entity="card"
- />
- );
-}
diff --git a/frontend/src/metabase/metrics/components/MetricActivityTimeline/index.ts b/frontend/src/metabase/metrics/components/MetricActivityTimeline/index.ts
deleted file mode 100644
index 2b22c4c7e67..00000000000
--- a/frontend/src/metabase/metrics/components/MetricActivityTimeline/index.ts
+++ /dev/null
@@ -1 +0,0 @@
-export { MetricActivityTimeline } from "./MetricActivityTimeline";
diff --git a/frontend/src/metabase/metrics/components/MetricHeader/MetricHeader.tsx b/frontend/src/metabase/metrics/components/MetricHeader/MetricHeader.tsx
index 9c3aec7378b..6f320ef084a 100644
--- a/frontend/src/metabase/metrics/components/MetricHeader/MetricHeader.tsx
+++ b/frontend/src/metabase/metrics/components/MetricHeader/MetricHeader.tsx
@@ -6,7 +6,7 @@ import {
} from "metabase/common/data-studio/components/PaneHeader";
import type { MetricUrls } from "metabase/common/metrics/types";
import { PLUGIN_MODERATION } from "metabase/plugins";
-import { Flex, Group } from "metabase/ui";
+import { Flex } from "metabase/ui";
import type { Card } from "metabase-types/api";
import { MetricNameInput } from "./MetricNameInput";
@@ -48,16 +48,14 @@ export function MetricHeader({
}
icon="metric"
tabs={<MetricTabs card={card} urls={urls} />}
- actions={
- <Group wrap="nowrap" align="center">
- {actions}
- <MetricToolbar
- card={card}
- urls={urls}
- showDataStudioLink={showDataStudioLink}
- />
- </Group>
+ menu={
+ <MetricToolbar
+ card={card}
+ urls={urls}
+ showDataStudioLink={showDataStudioLink}
+ />
}
+ actions={actions}
breadcrumbs={breadcrumbs}
/>
);
diff --git a/frontend/src/metabase/metrics/components/MetricHeader/MetricToolbar/MetricToolbar.tsx b/frontend/src/metabase/metrics/components/MetricHeader/MetricToolbar/MetricToolbar.tsx
index 865dbdcc3f3..af18f333a81 100644
--- a/frontend/src/metabase/metrics/components/MetricHeader/MetricToolbar/MetricToolbar.tsx
+++ b/frontend/src/metabase/metrics/components/MetricHeader/MetricToolbar/MetricToolbar.tsx
@@ -8,6 +8,7 @@ import {
useListNotificationsQuery,
} from "metabase/api";
import { AddToDashSelectDashModal } from "metabase/common/components/Pickers/AddToDashSelectDashModal";
+import { MoreMenuButton } from "metabase/common/data-studio/components/MoreMenuButton";
import { canAccessDataStudio as canAccessDataStudioSelector } from "metabase/common/data-studio/selectors";
import type { MetricUrls } from "metabase/common/metrics/types";
import { canManageSubscriptions as canManageSubscriptionsSelector } from "metabase/current-user";
@@ -25,7 +26,7 @@ import { MoveCardModal } from "metabase/questions/components/MoveCardModal";
import { useDispatch, useSelector } from "metabase/redux";
import { openUrl } from "metabase/redux/app";
import { useNavigate } from "metabase/router";
-import { ActionIcon, Icon, Menu } from "metabase/ui";
+import { Icon, Menu } from "metabase/ui";
import * as Urls from "metabase/urls";
import * as Lib from "metabase-lib";
import Question from "metabase-lib/v1/Question";
@@ -115,11 +116,9 @@ function MetricToolbarButtons({
PLUGIN_CACHING.hasQuestionCacheSection(new Question(card));
return (
- <Menu position="bottom-end">
+ <Menu>
<Menu.Target>
- <ActionIcon size="lg" aria-label={t`More options`}>
- <Icon name="ellipsis" />
- </ActionIcon>
+ <MoreMenuButton aria-label={t`More options`} />
</Menu.Target>
<Menu.Dropdown>
<Menu.Item
diff --git a/frontend/src/metabase/metrics/pages/MetricHistoryPage/MetricHistoryPage.tsx b/frontend/src/metabase/metrics/pages/MetricHistoryPage/MetricHistoryPage.tsx
index 3ae652fb350..bdfc6ff36bb 100644
--- a/frontend/src/metabase/metrics/pages/MetricHistoryPage/MetricHistoryPage.tsx
+++ b/frontend/src/metabase/metrics/pages/MetricHistoryPage/MetricHistoryPage.tsx
@@ -1,18 +1,15 @@
+import { ActivityTimelineCard } from "metabase/common/data-studio/components/ActivityTimelineCard";
import { PageContainer } from "metabase/common/data-studio/components/PageContainer";
import type {
MetricPageParams,
MetricPageProps,
} from "metabase/common/metrics/types";
import { useParams } from "metabase/router";
-import { Box, Card } from "metabase/ui";
-import { MetricActivityTimeline } from "../../components/MetricActivityTimeline";
import { MetricPageCard } from "../../components/MetricPageCard";
import { MetricPageShell } from "../../components/MetricPageShell";
import { metricUrls as defaultUrls } from "../../urls";
-import S from "./MetricHistoryPage.module.css";
-
export function MetricHistoryPage({
urls = defaultUrls,
renderBreadcrumbs,
@@ -32,11 +29,13 @@ export function MetricHistoryPage({
showAppSwitcher={showAppSwitcher}
showDataStudioLink={showDataStudioLink}
/>
- <Card withBorder shadow="none" p="lg" flex={1} className={S.card}>
- <Box maw={800} pt="lg" px="lg">
- <MetricActivityTimeline card={card} />
- </Box>
- </Card>
+ <ActivityTimelineCard
+ entity="card"
+ id={card.id}
+ moderationReviews={card.moderation_reviews}
+ canWrite={card.can_write}
+ data-testid="saved-question-history-list"
+ />
</PageContainer>
)}
</MetricPageCard>
diff --git a/frontend/src/metabase/metrics/pages/MetricHistoryPage/MetricHistoryPage.unit.spec.tsx b/frontend/src/metabase/metrics/pages/MetricHistoryPage/MetricHistoryPage.unit.spec.tsx
new file mode 100644
index 00000000000..7a5ddf0a23a
--- /dev/null
+++ b/frontend/src/metabase/metrics/pages/MetricHistoryPage/MetricHistoryPage.unit.spec.tsx
@@ -0,0 +1,107 @@
+import userEvent from "@testing-library/user-event";
+import fetchMock from "fetch-mock";
+
+import {
+ setupCardEndpoints,
+ setupCardQueryEndpoints,
+ setupCardQueryMetadataEndpoint,
+ setupCollectionsEndpoints,
+ setupDatabaseEndpoints,
+ setupEntityRevisionsEndpoint,
+ setupMetricEndpoint,
+ setupRevertRevisionEndpoint,
+} from "__support__/server-mocks";
+import { setupAuditInfoEndpoint } from "__support__/server-mocks/audit";
+import { setupBookmarksEndpoints } from "__support__/server-mocks/bookmark";
+import { setupListNotificationEndpoints } from "__support__/server-mocks/notification";
+import { renderWithProviders, screen, waitFor, within } from "__support__/ui";
+import { Route } from "metabase/router";
+import {
+ createMockCard,
+ createMockCardQueryMetadata,
+ createMockCollection,
+ createMockDataset,
+ createMockMetric,
+ createMockRevision,
+} from "metabase-types/api/mocks";
+import {
+ ORDERS_ID,
+ SAMPLE_DB_ID,
+ createSampleDatabase,
+} from "metabase-types/api/mocks/presets";
+
+import { MetricHistoryPage } from "./MetricHistoryPage";
+
+const SAMPLE_DB = createSampleDatabase();
+const CARD_ID = 42;
+
+const CREATED = createMockRevision({
+ id: 1,
+ description: "created this",
+ timestamp: "2026-05-14T10:00:00Z",
+});
+const RENAMED = createMockRevision({
+ id: 2,
+ description: "renamed it",
+ timestamp: "2026-05-16T10:00:00Z",
+ is_creation: false,
+});
+
+function setup() {
+ const card = createMockCard({
+ id: CARD_ID,
+ type: "metric",
+ name: "Count of Orders",
+ database_id: SAMPLE_DB_ID,
+ table_id: ORDERS_ID,
+ dataset_query: {
+ type: "query",
+ database: SAMPLE_DB_ID,
+ query: { "source-table": ORDERS_ID, aggregation: [["count"]] },
+ },
+ });
+ setupDatabaseEndpoints(SAMPLE_DB);
+ setupCardEndpoints(card);
+ setupCardQueryMetadataEndpoint(
+ card,
+ createMockCardQueryMetadata({ databases: [SAMPLE_DB] }),
+ );
+ setupCardQueryEndpoints(card, createMockDataset());
+ setupMetricEndpoint(createMockMetric({ id: card.id, name: card.name }));
+ setupCollectionsEndpoints({ collections: [createMockCollection()] });
+ setupBookmarksEndpoints([]);
+ setupListNotificationEndpoints({ card_id: card.id }, []);
+ setupAuditInfoEndpoint({ auditInfo: {} });
+ setupEntityRevisionsEndpoint("card", card.id, [RENAMED, CREATED]);
+ setupRevertRevisionEndpoint(CREATED);
+
+ renderWithProviders(
+ <Route path="/metric/:cardId/history" element={<MetricHistoryPage />} />,
+ { withRouter: true, initialRoute: `/metric/${CARD_ID}/history` },
+ );
+}
+
+describe("MetricHistoryPage", () => {
+ it("lists the metric's revisions newest first and reverts to an older one", async () => {
+ setup();
+
+ const list = await screen.findByTestId("saved-question-history-list");
+ const events = within(list).getAllByTestId("revision-history-event");
+ expect(events[0]).toHaveTextContent("renamed it");
+ expect(events[1]).toHaveTextContent("created this");
+
+ await userEvent.click(within(list).getByTestId("question-revert-button"));
+
+ await waitFor(() =>
+ expect(fetchMock.callHistory.called("path:/api/revision/revert")).toBe(
+ true,
+ ),
+ );
+ const call = fetchMock.callHistory.lastCall("path:/api/revision/revert");
+ expect(await call?.request?.json()).toEqual({
+ entity: "card",
+ id: CARD_ID,
+ revision_id: CREATED.id,
+ });
+ });
+});
diff --git a/frontend/src/metabase/query_builder/components/QuestionActivityTimeline.tsx b/frontend/src/metabase/query_builder/components/QuestionActivityTimeline.tsx
index dc75895b77f..e49c52101f2 100644
--- a/frontend/src/metabase/query_builder/components/QuestionActivityTimeline.tsx
+++ b/frontend/src/metabase/query_builder/components/QuestionActivityTimeline.tsx
@@ -3,16 +3,13 @@ import { useMemo } from "react";
import { useListRevisionsQuery } from "metabase/api";
import { LoadingAndErrorWrapper } from "metabase/common/components/LoadingAndErrorWrapper";
import { RevisionHistoryTimeline } from "metabase/common/components/RevisionHistoryTimeline";
-import { getTimelineEvents } from "metabase/common/components/RevisionHistoryTimeline/utils";
+import { getActivityTimelineEvents } from "metabase/common/components/RevisionHistoryTimeline/utils";
import { getUser } from "metabase/current-user";
-import { PLUGIN_MODERATION } from "metabase/plugins";
import { useDispatch, useSelector } from "metabase/redux";
import type Question from "metabase-lib/v1/Question";
import { revertToRevision } from "../actions";
-const { getModerationTimelineEvents } = PLUGIN_MODERATION;
-
interface QuestionActivityTimelineProps {
question: Question;
}
@@ -34,18 +31,11 @@ export function QuestionActivityTimeline({
const moderationReviews = question.getModerationReviews();
- const events = useMemo(() => {
- const moderationEvents = getModerationTimelineEvents(
- moderationReviews,
- currentUser,
- );
- const revisionEvents = getTimelineEvents({ revisions, currentUser });
-
- return [...revisionEvents, ...moderationEvents].sort(
- (a, b) =>
- new Date(b.timestamp).getTime() - new Date(a.timestamp).getTime(),
- );
- }, [moderationReviews, revisions, currentUser]);
+ const events = useMemo(
+ () =>
+ getActivityTimelineEvents({ revisions, moderationReviews, currentUser }),
+ [moderationReviews, revisions, currentUser],
+ );
if (isLoading || error) {
return <LoadingAndErrorWrapper loading={isLoading} error={error} />;
diff --git a/frontend/src/metabase/transforms/components/JobMoreMenu/JobMoreMenu.tsx b/frontend/src/metabase/transforms/components/JobMoreMenu/JobMoreMenu.tsx
index 6f77f7a9382..c7b49396776 100644
--- a/frontend/src/metabase/transforms/components/JobMoreMenu/JobMoreMenu.tsx
+++ b/frontend/src/metabase/transforms/components/JobMoreMenu/JobMoreMenu.tsx
@@ -2,9 +2,10 @@ import type { MouseEvent } from "react";
import { t } from "ttag";
import { useUpdateTransformJobMutation } from "metabase/api";
+import { MoreMenuButton } from "metabase/common/data-studio/components/MoreMenuButton";
import { useMetadataToasts } from "metabase/common/hooks";
import { useNavigate } from "metabase/router";
-import { ActionIcon, Icon, Menu } from "metabase/ui";
+import { Icon, Menu } from "metabase/ui";
import * as Urls from "metabase/urls";
import type { TransformJob } from "metabase-types/api";
@@ -66,9 +67,7 @@ function JobMenu({
return (
<Menu>
<Menu.Target>
- <ActionIcon variant="subtle" onClick={handleIconClick}>
- <Icon name="ellipsis" />
- </ActionIcon>
+ <MoreMenuButton aria-label={t`Job options`} onClick={handleIconClick} />
</Menu.Target>
<Menu.Dropdown onClick={(event) => event.stopPropagation()}>
<Menu.Item
diff --git a/frontend/src/metabase/transforms/components/TransformHeader/TransformMoreMenu/TransformMoreMenu.tsx b/frontend/src/metabase/transforms/components/TransformHeader/TransformMoreMenu/TransformMoreMenu.tsx
index 7bdd12922b1..19bf35163f3 100644
--- a/frontend/src/metabase/transforms/components/TransformHeader/TransformMoreMenu/TransformMoreMenu.tsx
+++ b/frontend/src/metabase/transforms/components/TransformHeader/TransformMoreMenu/TransformMoreMenu.tsx
@@ -1,9 +1,10 @@
import { type MouseEvent, useState } from "react";
import { t } from "ttag";
+import { MoreMenuButton } from "metabase/common/data-studio/components/MoreMenuButton";
import { useMetadataToasts } from "metabase/common/hooks";
import { useNavigate } from "metabase/router";
-import { ActionIcon, Icon, Menu } from "metabase/ui";
+import { Icon, Menu } from "metabase/ui";
import * as Urls from "metabase/urls";
import type { Transform } from "metabase-types/api";
@@ -69,9 +70,10 @@ function TransformMenu({
return (
<Menu>
<Menu.Target>
- <ActionIcon variant="subtle" size="sm" onClick={handleIconClick}>
- <Icon name="ellipsis" />
- </ActionIcon>
+ <MoreMenuButton
+ aria-label={t`Transform options`}
+ onClick={handleIconClick}
+ />
</Menu.Target>
<Menu.Dropdown>
<Menu.Item
diff --git a/frontend/src/metabase/transforms/components/TransformRevisionHistorySidebar/TransformRevisionHistorySidebar.unit.spec.tsx b/frontend/src/metabase/transforms/components/TransformRevisionHistorySidebar/TransformRevisionHistorySidebar.unit.spec.tsx
index 59cee89f8e3..4c7fff251d0 100644
--- a/frontend/src/metabase/transforms/components/TransformRevisionHistorySidebar/TransformRevisionHistorySidebar.unit.spec.tsx
+++ b/frontend/src/metabase/transforms/components/TransformRevisionHistorySidebar/TransformRevisionHistorySidebar.unit.spec.tsx
@@ -1,7 +1,7 @@
import userEvent from "@testing-library/user-event";
import {
- setupTransformRevisionsEndpoint,
+ setupEntityRevisionsEndpoint,
setupUsersEndpoints,
} from "__support__/server-mocks";
import { createMockState } from "__support__/state";
@@ -62,7 +62,7 @@ function setup({
const onClose = jest.fn();
const currentUser = mockUser;
- setupTransformRevisionsEndpoint(transform.id, revisions);
+ setupEntityRevisionsEndpoint("transform", transform.id, revisions);
setupUsersEndpoints([currentUser]);
const state = createMockState({
diff --git a/frontend/src/metabase/urls/data-studio.ts b/frontend/src/metabase/urls/data-studio.ts
index 76062f02814..7f5d02190b7 100644
--- a/frontend/src/metabase/urls/data-studio.ts
+++ b/frontend/src/metabase/urls/data-studio.ts
@@ -139,6 +139,10 @@ export function dataStudioDashboardUsage(dashboardId: DashboardId) {
return `${dataStudioDashboard(dashboardId)}/usage`;
}
+export function dataStudioDashboardHistory(dashboardId: DashboardId) {
+ return `${dataStudioDashboard(dashboardId)}/history`;
+}
+
export function dataStudioDashboardSubscriptions(
dashboardId: DashboardId,
subscriptionId?: DashboardSubscription["id"],
diff --git a/frontend/src/metabase/urls/data-studio.unit.spec.ts b/frontend/src/metabase/urls/data-studio.unit.spec.ts
index f823e5bed1f..fd907c28b27 100644
--- a/frontend/src/metabase/urls/data-studio.unit.spec.ts
+++ b/frontend/src/metabase/urls/data-studio.unit.spec.ts
@@ -3,6 +3,7 @@ import {
dataStudioDashboard,
dataStudioDashboardContents,
dataStudioDashboardDependencies,
+ dataStudioDashboardHistory,
dataStudioDashboardSubscriptions,
dataStudioDashboardUsage,
dataStudioDashboards,
@@ -137,6 +138,9 @@ describe("urls > data-studio", () => {
expect(dataStudioDashboardUsage(7)).toBe(
"/data-studio/dashboards/7/usage",
);
+ expect(dataStudioDashboardHistory(7)).toBe(
+ "/data-studio/dashboards/7/history",
+ );
expect(dataStudioDashboardSubscriptions(7)).toBe(
"/data-studio/dashboards/7/subscriptions",
);
diff --git a/frontend/test/__support__/server-mocks/revision.ts b/frontend/test/__support__/server-mocks/revision.ts
index e9115db4f37..9c9e6247550 100644
--- a/frontend/test/__support__/server-mocks/revision.ts
+++ b/frontend/test/__support__/server-mocks/revision.ts
@@ -1,41 +1,19 @@
import fetchMock from "fetch-mock";
-import type { Revision } from "metabase-types/api";
+import type { Revision, RevisionEntityType } from "metabase-types/api";
export function setupRevisionsEndpoints(revisions: Revision[]) {
fetchMock.get("path:/api/revision", revisions);
}
-export function setupSegmentRevisionsEndpoint(
- segmentId: number,
+export function setupEntityRevisionsEndpoint(
+ entity: RevisionEntityType,
+ id: number | string,
revisions: Revision[],
) {
- fetchMock.get(`path:/api/revision?entity=segment&id=${segmentId}`, revisions);
+ fetchMock.get(`path:/api/revision?entity=${entity}&id=${id}`, revisions);
}
-export function setupMeasureRevisionsEndpoint(
- measureId: number,
- revisions: Revision[],
-) {
- fetchMock.get(`path:/api/revision?entity=measure&id=${measureId}`, revisions);
-}
-
-export function setupDocumentRevisionsEndpoint(
- documentId: number,
- revisions: Revision[],
-) {
- fetchMock.get(
- `path:/api/revision?entity=document&id=${documentId}`,
- revisions,
- );
-}
-
-export function setupTransformRevisionsEndpoint(
- transformId: number,
- revisions: Revision[],
-) {
- fetchMock.get(
- `path:/api/revision?entity=transform&id=${transformId}`,
- revisions,
- );
+export function setupRevertRevisionEndpoint(revision: Revision) {
+ fetchMock.post("path:/api/revision/revert", revision);
}