Skip to content

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

Show breadcrumbs on published table page (Library > Data > table) (#66837)

Anderson18e227736c8a
diff --git a/e2e/support/helpers/e2e-data-studio-helpers.ts b/e2e/support/helpers/e2e-data-studio-helpers.ts
index 46f7a5f4495..913430f8660 100644
--- a/e2e/support/helpers/e2e-data-studio-helpers.ts
+++ b/e2e/support/helpers/e2e-data-studio-helpers.ts
@@ -11,6 +11,7 @@ const metricQueryEditor = () => cy.findByTestId("metric-query-editor");
export const DataStudio = {
nav: () => cy.findByTestId("data-studio-nav"),
+ breadcrumbs: () => cy.findByTestId("data-studio-breadcrumbs"),
Transforms: {
header: () => cy.findByTestId("transforms-header"),
list: () => cy.findByTestId("transforms-list"),
diff --git a/e2e/test/scenarios/data-studio/data-studio-tables.cy.spec.ts b/e2e/test/scenarios/data-studio/data-studio-tables.cy.spec.ts
index 3f6ef16ac65..04c8a0672b0 100644
--- a/e2e/test/scenarios/data-studio/data-studio-tables.cy.spec.ts
+++ b/e2e/test/scenarios/data-studio/data-studio-tables.cy.spec.ts
@@ -50,11 +50,21 @@ describe("scenarios > data studio > library > tables", () => {
});
describe("overview", () => {
- it("should be able to view the table data", () => {
+ beforeEach(() => {
H.createLibrary();
H.publishTables({ table_ids: [ORDERS_ID] });
-
H.DataStudio.Tables.visitOverviewPage(ORDERS_ID);
+ });
+
+ it("should show page breadcrumbs", () => {
+ H.DataStudio.breadcrumbs().within(() => {
+ cy.findByRole("link", { name: "Library" }).should("be.visible");
+ cy.findByRole("link", { name: "Data" }).should("be.visible");
+ cy.findByText("Orders").should("be.visible");
+ });
+ });
+
+ it("should be able to view the table data", () => {
H.queryVisualizationRoot().within(() => {
cy.findByText("Subtotal").should("be.visible");
cy.findByText("110.93").should("be.visible");
@@ -62,10 +72,6 @@ describe("scenarios > data studio > library > tables", () => {
});
it("should be able to change the description", () => {
- H.createLibrary();
- H.publishTables({ table_ids: [ORDERS_ID] });
-
- H.DataStudio.Tables.visitOverviewPage(ORDERS_ID);
H.DataStudio.Tables.Overview.descriptionText()
.should("contain.text", "orders for a product")
.click();
diff --git a/enterprise/frontend/src/metabase-enterprise/data-studio/common/components/DataStudioBreadcrumbs/DataStudioBreadcrumbs.tsx b/enterprise/frontend/src/metabase-enterprise/data-studio/common/components/DataStudioBreadcrumbs/DataStudioBreadcrumbs.tsx
index dc35f6eb271..068cd562bef 100644
--- a/enterprise/frontend/src/metabase-enterprise/data-studio/common/components/DataStudioBreadcrumbs/DataStudioBreadcrumbs.tsx
+++ b/enterprise/frontend/src/metabase-enterprise/data-studio/common/components/DataStudioBreadcrumbs/DataStudioBreadcrumbs.tsx
@@ -13,6 +13,7 @@ export const DataStudioBreadcrumbs = ({
fz="sm"
c="text-secondary"
style={{ visibility: loading ? "hidden" : undefined }}
+ data-testid="data-studio-breadcrumbs"
{...rest}
/>
);
diff --git a/enterprise/frontend/src/metabase-enterprise/data-studio/tables/components/TableHeader/TableHeader.tsx b/enterprise/frontend/src/metabase-enterprise/data-studio/tables/components/TableHeader/TableHeader.tsx
index c5a068ecf90..84d0779c8d5 100644
--- a/enterprise/frontend/src/metabase-enterprise/data-studio/tables/components/TableHeader/TableHeader.tsx
+++ b/enterprise/frontend/src/metabase-enterprise/data-studio/tables/components/TableHeader/TableHeader.tsx
@@ -1,3 +1,7 @@
+import Link from "metabase/common/components/Link/Link";
+import * as Urls from "metabase/lib/urls";
+import { DataStudioBreadcrumbs } from "metabase-enterprise/data-studio/common/components/DataStudioBreadcrumbs";
+import { useCollectionPath } from "metabase-enterprise/data-studio/common/hooks/use-collection-path/useCollectionPath";
import type { Table } from "metabase-types/api";
import { PaneHeader } from "../../../common/components/PaneHeader";
@@ -11,6 +15,9 @@ type TableHeaderProps = {
};
export function TableHeader({ table }: TableHeaderProps) {
+ const { path, isLoadingPath } = useCollectionPath({
+ collectionId: table.collection_id,
+ });
return (
<PaneHeader
data-testid="table-pane-header"
@@ -18,6 +25,21 @@ export function TableHeader({ table }: TableHeaderProps) {
icon="table"
menu={<TableMoreMenu table={table} />}
tabs={<TableTabs table={table} />}
+ breadcrumbs={
+ <DataStudioBreadcrumbs loading={isLoadingPath}>
+ {path?.map((collection, i) => (
+ <Link
+ key={collection.id}
+ to={Urls.dataStudioLibrary({
+ expandedIds: path.slice(1, i + 1).map((c) => c.id),
+ })}
+ >
+ {collection.name}
+ </Link>
+ ))}
+ <span>{table.display_name}</span>
+ </DataStudioBreadcrumbs>
+ }
/>
);
}