Skip to content

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

Fix transforms-root breadcrumb link in remote-sync changes list (GHY-3901) (#77113)

Eric Normand843ddfa34875
diff --git a/enterprise/frontend/src/metabase-enterprise/remote_sync/components/ChangesLists/AllChangesView.unit.spec.tsx b/enterprise/frontend/src/metabase-enterprise/remote_sync/components/ChangesLists/AllChangesView.unit.spec.tsx
index 7bf3da6db98..bad149b9fbd 100644
--- a/enterprise/frontend/src/metabase-enterprise/remote_sync/components/ChangesLists/AllChangesView.unit.spec.tsx
+++ b/enterprise/frontend/src/metabase-enterprise/remote_sync/components/ChangesLists/AllChangesView.unit.spec.tsx
@@ -274,6 +274,38 @@ describe("AllChangesView", () => {
expect(screen.getByText("Transform in Collection")).toBeInTheDocument();
});
+ it("should link the Transforms virtual root to the transforms list, not a dead collection URL (GHY-3901)", async () => {
+ const transformsCollection = createMockCollection({
+ id: 100,
+ name: "My Transforms Collection",
+ namespace: "transforms",
+ effective_ancestors: [],
+ });
+ const transformEntity = createMockRemoteSyncEntity({
+ id: 200,
+ name: "Transform in Collection",
+ model: "transform",
+ collection_id: 100,
+ sync_status: "create",
+ });
+
+ setup({
+ entities: [transformEntity],
+ collections: [transformsCollection],
+ isTransformsSyncEnabled: true,
+ });
+
+ // The virtual root uses the sentinel id -1, which must not leak into a
+ // /collection/-1-transforms URL.
+ const transformsRootLink = await screen.findByRole("link", {
+ name: "Transforms",
+ });
+ expect(transformsRootLink).toHaveAttribute(
+ "href",
+ "/data-studio/transforms",
+ );
+ });
+
it("should display nested transforms collections with Transforms virtual root in path", async () => {
const childTransformsCollection = createMockCollection({
id: 101,
diff --git a/enterprise/frontend/src/metabase-enterprise/remote_sync/components/ChangesLists/CollectionPath.tsx b/enterprise/frontend/src/metabase-enterprise/remote_sync/components/ChangesLists/CollectionPath.tsx
index 855a137f206..b848a7c5633 100644
--- a/enterprise/frontend/src/metabase-enterprise/remote_sync/components/ChangesLists/CollectionPath.tsx
+++ b/enterprise/frontend/src/metabase-enterprise/remote_sync/components/ChangesLists/CollectionPath.tsx
@@ -1,14 +1,22 @@
import { Fragment } from "react";
import { Anchor, Group, Text } from "metabase/ui";
-import { collection as collectionUrl } from "metabase/urls";
+import { collection as collectionUrl, transformList } from "metabase/urls";
-import type { CollectionPathSegment } from "../../utils";
+import { type CollectionPathSegment, TRANSFORMS_ROOT_ID } from "../../utils";
interface CollectionPathProps {
segments: CollectionPathSegment[];
}
+const segmentUrl = (segment: CollectionPathSegment): string =>
+ // The Transforms root is a virtual collection (sentinel id -1) with no real
+ // collection page, so link it to the transforms list instead of building a
+ // dead /collection/-1-... URL.
+ segment.id === TRANSFORMS_ROOT_ID
+ ? transformList()
+ : collectionUrl({ id: segment.id, name: segment.name });
+
// TODO: see if we can use the CollectionBreadcrumb component here
export const CollectionPath = ({ segments }: CollectionPathProps) => {
return (
@@ -21,10 +29,7 @@ export const CollectionPath = ({ segments }: CollectionPathProps) => {
</Text>
)}
<Anchor
- href={collectionUrl({
- id: segment.id,
- name: segment.name,
- })}
+ href={segmentUrl(segment)}
target="_blank"
size="sm"
c="text-secondary"