Skip to content

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

allow collection creation when publishing tables (#75261)

Nick Fitzpatrick7a3ea4c788ce
diff --git a/enterprise/frontend/src/metabase-enterprise/data-studio/library/components/PublishTablesModal/PublishTablesModal.tsx b/enterprise/frontend/src/metabase-enterprise/data-studio/library/components/PublishTablesModal/PublishTablesModal.tsx
index c0e24e0596b..ae1820984f4 100644
--- a/enterprise/frontend/src/metabase-enterprise/data-studio/library/components/PublishTablesModal/PublishTablesModal.tsx
+++ b/enterprise/frontend/src/metabase-enterprise/data-studio/library/components/PublishTablesModal/PublishTablesModal.tsx
@@ -181,7 +181,7 @@ function ModalBody({
hasSearch: true,
hasRecents: false,
hasConfirmButtons: true,
- canCreateCollections: false,
+ canCreateCollections: true,
},
}}
/>
diff --git a/enterprise/frontend/src/metabase-enterprise/data-studio/library/components/PublishTablesModal/PublishTablesModal.unit.spec.tsx b/enterprise/frontend/src/metabase-enterprise/data-studio/library/components/PublishTablesModal/PublishTablesModal.unit.spec.tsx
index 0193e334ce8..dfa2f8a3ae3 100644
--- a/enterprise/frontend/src/metabase-enterprise/data-studio/library/components/PublishTablesModal/PublishTablesModal.unit.spec.tsx
+++ b/enterprise/frontend/src/metabase-enterprise/data-studio/library/components/PublishTablesModal/PublishTablesModal.unit.spec.tsx
@@ -7,6 +7,7 @@ import {
setupLibraryEndpoints,
setupPublishTablesEndpoint,
setupPublishTablesEndpointError,
+ setupRootCollectionItemsEndpoint,
setupTableSelectionInfoEndpoint,
} from "__support__/server-mocks";
import { mockSettings } from "__support__/settings";
@@ -74,6 +75,23 @@ function setup({
],
});
setupCollectionByIdEndpoint({ collections: [dataCollection] });
+ setupCollectionItemsEndpoint({
+ collection: { id: dataCollection.id as number },
+ collectionItems: [],
+ });
+ setupRootCollectionItemsEndpoint({
+ rootCollectionItems: [
+ createMockCollectionItem({
+ id: dataCollection.id as number,
+ name: dataCollection.name,
+ model: "collection",
+ type: dataCollection.type,
+ can_write: true,
+ here: ["table", "collection"],
+ below: ["table", "collection"],
+ }),
+ ],
+ });
setupTableSelectionInfoEndpoint(selectionInfo);
if (hasPublishError) {
@@ -180,6 +198,26 @@ describe("PublishTablesModal", () => {
await waitFor(() => expect(onPublish).toHaveBeenCalled());
});
+ it("should allow creating a new collection from the collection picker (UXW-4167)", async () => {
+ setup({
+ selectionInfo: createMockBulkTableSelectionInfo({
+ selected_table: createMockBulkTableInfo({
+ id: 1,
+ display_name: "Orders",
+ }),
+ }),
+ });
+ expect(await screen.findByText("Publish Orders?")).toBeInTheDocument();
+
+ await userEvent.click(
+ await screen.findByTestId("collection-picker-button"),
+ );
+
+ expect(
+ await screen.findByRole("button", { name: "New collection" }),
+ ).toBeInTheDocument();
+ });
+
it("should show a publish error", async () => {
const { onPublish } = setup({
selectionInfo: createMockBulkTableSelectionInfo({