Skip to content

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

Hide shallow copy checkbox instead of disabling it (#64559)

Kamil Mielnik26edf3c9dde7
diff --git a/e2e/test/scenarios/dashboard/dashboard-management.cy.spec.js b/e2e/test/scenarios/dashboard/dashboard-management.cy.spec.js
index 6d158508ac9..a6a5d492d73 100644
--- a/e2e/test/scenarios/dashboard/dashboard-management.cy.spec.js
+++ b/e2e/test/scenarios/dashboard/dashboard-management.cy.spec.js
@@ -152,6 +152,15 @@ describe("managing dashboard from the dashboard's edit menu", () => {
cy.findByLabelText("Only duplicate the dashboard").should(
"not.be.checked",
);
+ cy.icon("info").realHover();
+ });
+
+ H.tooltip().should(
+ "contain.text",
+ "If you check this, the cards in the duplicated dashboard will reference the original questions.",
+ );
+
+ H.modal().within(() => {
cy.button("Duplicate").click();
assertOnRequest("copyDashboard");
});
@@ -386,18 +395,8 @@ describe("managing dashboard from the dashboard's edit menu", () => {
cy.findByRole("heading", {
name: `Duplicate "${dashboardName}" and its questions`,
});
- cy.findByLabelText("Only duplicate the dashboard")
- .as("shallowCopyCheckbox")
- .should("not.be.checked")
- .should("be.disabled");
-
- cy.icon("info").realHover();
+ cy.findByLabelText("Only duplicate the dashboard").should("not.exist");
});
-
- H.tooltip().should(
- "contain.text",
- "Only available when none of the questions are saved to the dashboard.",
- );
});
});
diff --git a/frontend/src/metabase/dashboard/components/DashboardCopyModal/DashboardCopyModalShallowCheckboxLabel/DashboardCopyModalShallowCheckboxLabel.module.css b/frontend/src/metabase/dashboard/components/DashboardCopyModal/DashboardCopyModalShallowCheckboxLabel/DashboardCopyModalShallowCheckboxLabel.module.css
deleted file mode 100644
index 14031baa07c..00000000000
--- a/frontend/src/metabase/dashboard/components/DashboardCopyModal/DashboardCopyModalShallowCheckboxLabel/DashboardCopyModalShallowCheckboxLabel.module.css
+++ /dev/null
@@ -1,9 +0,0 @@
-.checkboxLabelRoot {
- display: flex;
- align-items: center;
- padding-left: 0.25rem;
-
- > * {
- padding-left: 0.25rem;
- }
-}
diff --git a/frontend/src/metabase/dashboard/components/DashboardCopyModal/DashboardCopyModalShallowCheckboxLabel/DashboardCopyModalShallowCheckboxLabel.tsx b/frontend/src/metabase/dashboard/components/DashboardCopyModal/DashboardCopyModalShallowCheckboxLabel/DashboardCopyModalShallowCheckboxLabel.tsx
deleted file mode 100644
index ae07698ae0b..00000000000
--- a/frontend/src/metabase/dashboard/components/DashboardCopyModal/DashboardCopyModalShallowCheckboxLabel/DashboardCopyModalShallowCheckboxLabel.tsx
+++ /dev/null
@@ -1,25 +0,0 @@
-import { t } from "ttag";
-
-import Tooltip from "metabase/common/components/Tooltip";
-import { Icon } from "metabase/ui";
-
-import S from "./DashboardCopyModalShallowCheckboxLabel.module.css";
-
-export const DashboardCopyModalShallowCheckboxLabel = ({
- hasDashboardQuestions,
-}: {
- hasDashboardQuestions: boolean;
-}) => (
- <div className={S.checkboxLabelRoot}>
- {t`Only duplicate the dashboard`}
- <Tooltip
- tooltip={
- hasDashboardQuestions
- ? t`Only available when none of the questions are saved to the dashboard.`
- : t`If you check this, the cards in the duplicated dashboard will reference the original questions.`
- }
- >
- <Icon name="info" size={18} />
- </Tooltip>
- </div>
-);
diff --git a/frontend/src/metabase/dashboard/containers/CopyDashboardForm.tsx b/frontend/src/metabase/dashboard/containers/CopyDashboardForm.tsx
index db523aa34a6..ea52117f6c2 100644
--- a/frontend/src/metabase/dashboard/containers/CopyDashboardForm.tsx
+++ b/frontend/src/metabase/dashboard/containers/CopyDashboardForm.tsx
@@ -20,9 +20,9 @@ import {
FormTextarea,
} from "metabase/forms";
import * as Errors from "metabase/lib/errors";
+import { Group, Icon, Tooltip } from "metabase/ui";
import type { CollectionId, Dashboard, DashboardId } from "metabase-types/api";
-import { DashboardCopyModalShallowCheckboxLabel } from "../components/DashboardCopyModal/DashboardCopyModalShallowCheckboxLabel/DashboardCopyModalShallowCheckboxLabel";
import {
DASHBOARD_DESCRIPTION_MAX_LENGTH,
DASHBOARD_NAME_MAX_LENGTH,
@@ -103,9 +103,7 @@ function CopyDashboardForm({
);
}, [originalDashboard]);
- const isShallowCopyDisabled = Boolean(
- isLoading || error || hasDashboardQuestions,
- );
+ const hideShallowCopy = Boolean(isLoading || error || hasDashboardQuestions);
return (
<FormProvider
@@ -136,15 +134,24 @@ function CopyDashboardForm({
title={t`Which collection should this go in?`}
filterPersonalCollections={filterPersonalCollections}
/>
- <FormCheckbox
- name="is_shallow_copy"
- label={
- <DashboardCopyModalShallowCheckboxLabel
- hasDashboardQuestions={hasDashboardQuestions}
- />
- }
- disabled={isShallowCopyDisabled}
- />
+
+ {!hideShallowCopy && (
+ <FormCheckbox
+ name="is_shallow_copy"
+ label={
+ <Group align="center" gap="xs">
+ {t`Only duplicate the dashboard`}
+
+ <Tooltip
+ label={t`If you check this, the cards in the duplicated dashboard will reference the original questions.`}
+ >
+ <Icon name="info" size={18} />
+ </Tooltip>
+ </Group>
+ }
+ />
+ )}
+
<FormFooter>
<FormErrorMessage inline />
{!!onClose && (