Skip to content

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

fix: savingModel prop only "collection" matters (#66906)

Edward Pagetb2ec3abf6290
diff --git a/frontend/src/metabase/collections/containers/FormCollectionAndDashboardPicker/FormCollectionAndDashboardPicker.tsx b/frontend/src/metabase/collections/containers/FormCollectionAndDashboardPicker/FormCollectionAndDashboardPicker.tsx
index ae6233d931f..e1b19c28e66 100644
--- a/frontend/src/metabase/collections/containers/FormCollectionAndDashboardPicker/FormCollectionAndDashboardPicker.tsx
+++ b/frontend/src/metabase/collections/containers/FormCollectionAndDashboardPicker/FormCollectionAndDashboardPicker.tsx
@@ -81,10 +81,10 @@ interface FormCollectionPickerProps extends HTMLAttributes<HTMLDivElement> {
zIndex?: number;
collectionPickerModalProps?: Partial<CollectionPickerModalProps>;
/**
- * The type of item being saved. When set to a non-collection model,
- * namespace root collections (like tenant root) will be disabled.
+ * When set to "collection", allows saving to namespace root collections
+ * (like tenant root). When null/undefined, namespace roots are disabled.
*/
- savingModel?: "collection" | "dashboard" | "question" | "model";
+ savingModel?: "collection" | null;
}
export function FormCollectionAndDashboardPicker({
diff --git a/frontend/src/metabase/collections/containers/FormCollectionPicker/FormCollectionPicker.tsx b/frontend/src/metabase/collections/containers/FormCollectionPicker/FormCollectionPicker.tsx
index f6486ca5c1f..b664691364d 100644
--- a/frontend/src/metabase/collections/containers/FormCollectionPicker/FormCollectionPicker.tsx
+++ b/frontend/src/metabase/collections/containers/FormCollectionPicker/FormCollectionPicker.tsx
@@ -44,10 +44,10 @@ interface FormCollectionPickerProps extends HTMLAttributes<HTMLDivElement> {
collectionPickerModalProps?: Partial<CollectionPickerModalProps>;
setNamespace?: (namespace: string | undefined) => void;
/**
- * The type of item being saved. When set to a non-collection model,
- * namespace root collections (like tenant root) will be disabled.
+ * When set to "collection", allows saving to namespace root collections
+ * (like tenant root). When null/undefined, namespace roots are disabled.
*/
- savingModel?: "collection" | "dashboard" | "question" | "model";
+ savingModel?: "collection" | null;
}
function ItemName({
diff --git a/frontend/src/metabase/common/components/MoveModal.tsx b/frontend/src/metabase/common/components/MoveModal.tsx
index d298b59fcbf..a61541b3f49 100644
--- a/frontend/src/metabase/common/components/MoveModal.tsx
+++ b/frontend/src/metabase/common/components/MoveModal.tsx
@@ -37,10 +37,10 @@ interface BaseMoveModalProps {
entityType?: EntityType;
recentAndSearchFilter?: (item: CollectionPickerItem) => boolean;
/**
- * The type of item being moved. When set to a non-collection model,
- * namespace root collections (like tenant root) will be disabled.
+ * When set to "collection", allows saving to namespace root collections
+ * (like tenant root). When null/undefined, namespace roots are disabled.
*/
- savingModel?: "collection" | "dashboard" | "question" | "model";
+ savingModel?: "collection" | null;
/**
* The namespace of the collection being moved. Used to restrict which
* collections are shown in the picker:
diff --git a/frontend/src/metabase/common/components/Pickers/CollectionPicker/components/CollectionPickerModal.tsx b/frontend/src/metabase/common/components/Pickers/CollectionPicker/components/CollectionPickerModal.tsx
index 6b401f00c17..08ce9230be4 100644
--- a/frontend/src/metabase/common/components/Pickers/CollectionPicker/components/CollectionPickerModal.tsx
+++ b/frontend/src/metabase/common/components/Pickers/CollectionPicker/components/CollectionPickerModal.tsx
@@ -157,7 +157,6 @@ export const CollectionPickerModal = ({
// Check if namespace root is disallowed for this savingModel
if (
- options.savingModel &&
options.savingModel !== "collection" &&
isNamespaceRoot(item as CollectionPickerItem)
) {
diff --git a/frontend/src/metabase/common/components/Pickers/CollectionPicker/types.ts b/frontend/src/metabase/common/components/Pickers/CollectionPicker/types.ts
index d1a7b483e91..ad083ac5fa2 100644
--- a/frontend/src/metabase/common/components/Pickers/CollectionPicker/types.ts
+++ b/frontend/src/metabase/common/components/Pickers/CollectionPicker/types.ts
@@ -87,10 +87,10 @@ export type CollectionPickerOptions = EntityPickerModalOptions & {
showRootCollection?: boolean;
showLibrary?: boolean;
/**
- * The type of item being saved. When set to a non-collection model,
- * namespace root collections (like tenant root) will be disabled.
+ * When set to "collection", allows saving to namespace root collections
+ * (like tenant root). When null/undefined, namespace roots are disabled.
*/
- savingModel?: "collection" | "dashboard" | "question" | "model";
+ savingModel?: "collection" | null;
/**
* Restricts the picker to only show collections in a specific namespace.
* - When set to "shared-tenant-collection", only the tenant root is shown.
diff --git a/frontend/src/metabase/common/components/Pickers/utils.ts b/frontend/src/metabase/common/components/Pickers/utils.ts
index 42d10594fd3..a3fb04d5ffe 100644
--- a/frontend/src/metabase/common/components/Pickers/utils.ts
+++ b/frontend/src/metabase/common/components/Pickers/utils.ts
@@ -206,10 +206,6 @@ export const shouldDisableItemForSavingModel = (
item: CollectionPickerItem,
savingModel?: CollectionPickerOptions["savingModel"],
): boolean => {
- if (!savingModel) {
- return false;
- }
-
if (savingModel === "collection") {
return false;
}
diff --git a/frontend/src/metabase/common/components/Pickers/utils.unit.spec.ts b/frontend/src/metabase/common/components/Pickers/utils.unit.spec.ts
index 9c757171703..9f373b69ed7 100644
--- a/frontend/src/metabase/common/components/Pickers/utils.unit.spec.ts
+++ b/frontend/src/metabase/common/components/Pickers/utils.unit.spec.ts
@@ -404,16 +404,9 @@ describe("shouldDisableItemForSavingModel", () => {
location: "/tenant/",
};
- it("should return true for tenant root when saving a dashboard", () => {
- expect(shouldDisableItemForSavingModel(tenantRoot, "dashboard")).toBe(true);
- });
-
- it("should return true for tenant root when saving a question", () => {
- expect(shouldDisableItemForSavingModel(tenantRoot, "question")).toBe(true);
- });
-
- it("should return true for tenant root when saving a model", () => {
- expect(shouldDisableItemForSavingModel(tenantRoot, "model")).toBe(true);
+ it("should return true for tenant root when savingModel is not 'collection'", () => {
+ expect(shouldDisableItemForSavingModel(tenantRoot, undefined)).toBe(true);
+ expect(shouldDisableItemForSavingModel(tenantRoot, null)).toBe(true);
});
it("should return false for tenant root when saving a collection", () => {
@@ -422,11 +415,11 @@ describe("shouldDisableItemForSavingModel", () => {
);
});
- it("should return false for regular collections when saving any item type", () => {
- expect(
- shouldDisableItemForSavingModel(regularCollection, "dashboard"),
- ).toBe(false);
- expect(shouldDisableItemForSavingModel(regularCollection, "question")).toBe(
+ it("should return false for regular collections regardless of savingModel", () => {
+ expect(shouldDisableItemForSavingModel(regularCollection, undefined)).toBe(
+ false,
+ );
+ expect(shouldDisableItemForSavingModel(regularCollection, null)).toBe(
false,
);
expect(
@@ -434,18 +427,11 @@ describe("shouldDisableItemForSavingModel", () => {
).toBe(false);
});
- it("should return false for tenant sub-collections when saving any item type", () => {
- expect(
- shouldDisableItemForSavingModel(tenantSubCollection, "dashboard"),
- ).toBe(false);
+ it("should return false for tenant sub-collections regardless of savingModel", () => {
expect(
- shouldDisableItemForSavingModel(tenantSubCollection, "question"),
+ shouldDisableItemForSavingModel(tenantSubCollection, undefined),
).toBe(false);
- });
-
- it("should return false when savingModel is not specified", () => {
- expect(shouldDisableItemForSavingModel(tenantRoot, undefined)).toBe(false);
- expect(shouldDisableItemForSavingModel(regularCollection, undefined)).toBe(
+ expect(shouldDisableItemForSavingModel(tenantSubCollection, null)).toBe(
false,
);
});
@@ -466,8 +452,8 @@ describe("getDisabledReasonForSavingModel", () => {
location: "/",
};
- it("should return reason for disabled tenant root", () => {
- const reason = getDisabledReasonForSavingModel(tenantRoot, "dashboard");
+ it("should return reason for disabled tenant root when savingModel is not 'collection'", () => {
+ const reason = getDisabledReasonForSavingModel(tenantRoot, undefined);
expect(reason).toBeDefined();
expect(reason).toContain("tenant root collection");
@@ -475,14 +461,11 @@ describe("getDisabledReasonForSavingModel", () => {
it("should return undefined for enabled items", () => {
expect(
- getDisabledReasonForSavingModel(regularCollection, "dashboard"),
+ getDisabledReasonForSavingModel(regularCollection, undefined),
).toBeUndefined();
expect(
getDisabledReasonForSavingModel(tenantRoot, "collection"),
).toBeUndefined();
- expect(
- getDisabledReasonForSavingModel(tenantRoot, undefined),
- ).toBeUndefined();
});
});
diff --git a/frontend/src/metabase/common/components/SaveQuestionForm/SaveQuestionForm.tsx b/frontend/src/metabase/common/components/SaveQuestionForm/SaveQuestionForm.tsx
index eecd18e4b5c..3f42c74b0e7 100644
--- a/frontend/src/metabase/common/components/SaveQuestionForm/SaveQuestionForm.tsx
+++ b/frontend/src/metabase/common/components/SaveQuestionForm/SaveQuestionForm.tsx
@@ -58,9 +58,6 @@ export const SaveQuestionForm = ({
? ["collection", "dashboard"]
: ["collection"];
- // Determine the savingModel based on question type
- const savingModel = question.type() === "model" ? "model" : "question";
-
const showPickerInput =
values.saveType === "create" && !targetCollection && !saveToDashboard;
@@ -128,7 +125,6 @@ export const SaveQuestionForm = ({
dashboardIdFieldName="dashboard_id"
title={t`Where do you want to save this?`}
entityType={getEntityTypeFromCardType(question.type())}
- savingModel={savingModel}
collectionPickerModalProps={{
models,
recentFilter: (items) =>
diff --git a/frontend/src/metabase/dashboard/components/DashboardMoveModal.tsx b/frontend/src/metabase/dashboard/components/DashboardMoveModal.tsx
index ad13aba073d..2aedaf32ac3 100644
--- a/frontend/src/metabase/dashboard/components/DashboardMoveModal.tsx
+++ b/frontend/src/metabase/dashboard/components/DashboardMoveModal.tsx
@@ -56,7 +56,6 @@ function DashboardMoveModal({
onClose();
}}
recentAndSearchFilter={recentsAndSearchFilter}
- savingModel="dashboard"
/>
);
}
diff --git a/frontend/src/metabase/dashboard/containers/CopyDashboardForm.tsx b/frontend/src/metabase/dashboard/containers/CopyDashboardForm.tsx
index 45e7f04ff5a..5a3fe5afbf9 100644
--- a/frontend/src/metabase/dashboard/containers/CopyDashboardForm.tsx
+++ b/frontend/src/metabase/dashboard/containers/CopyDashboardForm.tsx
@@ -134,7 +134,6 @@ function CopyDashboardForm({
title={t`Which collection should this go in?`}
filterPersonalCollections={filterPersonalCollections}
entityType="dashboard"
- savingModel="dashboard"
/>
{!hideShallowCopy && (
diff --git a/frontend/src/metabase/dashboard/containers/CreateDashboardForm.tsx b/frontend/src/metabase/dashboard/containers/CreateDashboardForm.tsx
index d98e7c6b705..5a8cfb6fef8 100644
--- a/frontend/src/metabase/dashboard/containers/CreateDashboardForm.tsx
+++ b/frontend/src/metabase/dashboard/containers/CreateDashboardForm.tsx
@@ -126,7 +126,6 @@ export function CreateDashboardForm({
title={t`Which collection should this go in?`}
filterPersonalCollections={filterPersonalCollections}
entityType="dashboard"
- savingModel="dashboard"
/>
<FormFooter>
<FormErrorMessage inline />
diff --git a/frontend/src/metabase/questions/components/MoveCardModal/MoveCardModal.tsx b/frontend/src/metabase/questions/components/MoveCardModal/MoveCardModal.tsx
index ca5fe4b79fc..2085291ccbb 100644
--- a/frontend/src/metabase/questions/components/MoveCardModal/MoveCardModal.tsx
+++ b/frontend/src/metabase/questions/components/MoveCardModal/MoveCardModal.tsx
@@ -260,9 +260,6 @@ export const MoveCardModal = ({ card, onClose }: MoveCardModalProps) => {
}
};
- // Determine the savingModel based on card type
- const savingModel = card.type === "model" ? "model" : "question";
-
return (
<MoveModal
title={t`Where do you want to save this?`}
@@ -272,7 +269,6 @@ export const MoveCardModal = ({ card, onClose }: MoveCardModalProps) => {
canMoveToDashboard={card.type === "question"}
entityType={getEntityTypeFromCardType(card.type)}
recentAndSearchFilter={recentAndSearchFilter}
- savingModel={savingModel}
/>
);
};