The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:
TypeScript analyticsbibusiness-intelligencebusinessintelligenceclojuredashboarddatadata-analysisdata-visualizationdatabasemetabasemysqlpostgrespostgresqlreportingslacksql-editorvisualization
Make "database" the first option in the "Add data" modal (#63412)
Nemanja Glumacaa59dca84e7c
diff --git a/e2e/test/scenarios/onboarding/add-initial-data.cy.spec.ts b/e2e/test/scenarios/onboarding/add-initial-data.cy.spec.tsindex e68cef71693..e5f28d905b2 100644--- a/e2e/test/scenarios/onboarding/add-initial-data.cy.spec.ts+++ b/e2e/test/scenarios/onboarding/add-initial-data.cy.spec.ts@@ -52,32 +52,32 @@ H.describeWithSnowplow(openAddDataModalFromSidebar();cy.log("Tracking shouldn't happen on the default open tab");- getTab("CSV").should("have.attr", "data-active", "true");+ getTab("Database").should("have.attr", "data-active", "true");- cy.log("Track when Database tab opens");- openTab("Database");+ cy.log("Track when CSV tab opens");+ openTab("CSV");H.expectUnstructuredSnowplowEvent({- event: "database_tab_clicked",+ event: "csv_tab_clicked",triggered_from: "add-data-modal",});cy.log("Ignore the repeated click");- openTab("Database");+ openTab("CSV");H.expectUnstructuredSnowplowEvent({- event: "database_tab_clicked",+ event: "csv_tab_clicked",triggered_from: "add-data-modal",},1,);- cy.log("Track when CSV tab opens");- openTab("CSV");+ cy.log("Track when Database tab opens");+ openTab("Database");// We confirm that it didn't track the default open tab because the following assertion passes.// If there were multiple events like this, the count would be higherH.expectUnstructuredSnowplowEvent({- event: "csv_tab_clicked",+ event: "database_tab_clicked",triggered_from: "add-data-modal",},1,@@ -87,7 +87,6 @@ H.describeWithSnowplow(it("should track database selection", () => {cy.visit("/");openAddDataModalFromSidebar();- openTab("Database");addDataModal().findByRole("listbox").findByText("Snowflake")@@ -113,6 +112,7 @@ H.describeWithSnowplow(cy.visit("/");openAddDataModalFromSidebar();+ openTab("CSV");addDataModal().findByText("Select a file").click();H.expectUnstructuredSnowplowEvent({@@ -156,7 +156,6 @@ describe("Add data modal", () => {cy.signInAsAdmin();cy.visit("/");openAddDataModalFromSidebar();- openTab("Database");addDataModal().within(() => {cy.log("Admin should be able to manage databases");@@ -239,6 +238,7 @@ describe("Add data modal", () => {cy.signInAsAdmin();cy.visit("/");openAddDataModalFromSidebar();+ openTab("CSV");addDataModal().findByText("Enable uploads").click();cy.location("pathname").should("eq", "/admin/settings/uploads");@@ -322,6 +322,7 @@ describe("Add data modal", () => {cy.signIn("nocollection");cy.visit("/");openAddDataModalFromSidebar();+ openTab("CSV");addDataModal().within(() => {cy.button("Upload").should("be.disabled");diff --git a/frontend/src/metabase/nav/containers/MainNavbar/MainNavbarContainer/AddDataModal/AddDataModal.tsx b/frontend/src/metabase/nav/containers/MainNavbar/MainNavbarContainer/AddDataModal/AddDataModal.tsxindex 8a139703593..847642d2310 100644--- a/frontend/src/metabase/nav/containers/MainNavbar/MainNavbarContainer/AddDataModal/AddDataModal.tsx+++ b/frontend/src/metabase/nav/containers/MainNavbar/MainNavbarContainer/AddDataModal/AddDataModal.tsx@@ -64,13 +64,13 @@ export const AddDataModal = ({ opened, onClose }: AddDataModalProps) => {const tabs = useMemo(() => {return [+ { name: t`Database`, value: "db", isVisible: true, iconName: "database" },{name: t`CSV`,value: "csv",isVisible: shouldShowUploadsPanel,iconName: "table2",},- { name: t`Database`, value: "db", isVisible: true, iconName: "database" },{name: t`Google Sheets`,value: "gsheets",diff --git a/frontend/src/metabase/nav/containers/MainNavbar/MainNavbarContainer/AddDataModal/tests/common.unit.spec.tsx b/frontend/src/metabase/nav/containers/MainNavbar/MainNavbarContainer/AddDataModal/tests/common.unit.spec.tsxindex 1be5b4c181a..c0f501cf2df 100644--- a/frontend/src/metabase/nav/containers/MainNavbar/MainNavbarContainer/AddDataModal/tests/common.unit.spec.tsx+++ b/frontend/src/metabase/nav/containers/MainNavbar/MainNavbarContainer/AddDataModal/tests/common.unit.spec.tsx@@ -38,34 +38,27 @@ describe("AddDataModal", () => {).not.toBeInTheDocument();});- it("should have csv tab selected by default", async () => {- setup();-- const csvTab = await screen.findByRole("tab", { name: /CSV$/ });- expect(csvTab).toHaveAttribute("data-active", "true");- });-- it("should allow to change tabs", async () => {+ it("should have database tab selected by default but allow to change tabs", async () => {setup();const databaseTab = screen.getByRole("tab", { name: /Database$/ });const csvTab = await screen.findByRole("tab", { name: /CSV$/ });- expect(csvTab).toHaveAttribute("data-active", "true");- await userEvent.click(screen.getByRole("tab", { name: /Database$/ }));- expect(csvTab).not.toHaveAttribute("data-active");expect(databaseTab).toHaveAttribute("data-active", "true");+ await userEvent.click(csvTab);+ expect(databaseTab).not.toHaveAttribute("data-active");+ expect(csvTab).toHaveAttribute("data-active", "true");});it("should maintain the tab selection state", async () => {setup();- const csvTab = await screen.findByRole("tab", { name: /CSV$/ });- expect(csvTab).toHaveAttribute("data-active", "true");+ const databaseTab = await screen.findByRole("tab", { name: /Database$/ });+ expect(databaseTab).toHaveAttribute("data-active", "true");- await userEvent.click(csvTab);+ await userEvent.click(databaseTab);// Tab should remain selected after clicking- expect(csvTab).toHaveAttribute("data-active", "true");+ expect(databaseTab).toHaveAttribute("data-active", "true");});describe("database panel", () => {@@ -146,6 +139,7 @@ describe("AddDataModal", () => {it("should show CSV panel for admin users", async () => {setup({ isAdmin: true, uploadsEnabled: true });+ await userEvent.click(await screen.findByRole("tab", { name: /CSV$/ }));expect(await screen.findByText("Manage uploads")).toBeInTheDocument();expect(@@ -161,6 +155,7 @@ describe("AddDataModal", () => {it("should prompt the admin to enable uploads", async () => {setup({ isAdmin: true, uploadsEnabled: false });+ await userEvent.click(await screen.findByRole("tab", { name: /CSV$/ }));expect(await screen.findByText("Manage uploads")).toBeInTheDocument();expect(screen.getByRole("heading", { name: "Upload CSV files" }),@@ -178,6 +173,7 @@ describe("AddDataModal", () => {it("should prompt the admin to enable uploads with an upsell on a hosted instance", async () => {setup({ isAdmin: true, uploadsEnabled: false, isHosted: true });+ await userEvent.click(await screen.findByRole("tab", { name: /CSV$/ }));expect(await screen.findByText("Manage uploads")).toBeInTheDocument();expect(await screen.findByText("Enable uploads")).toBeInTheDocument();expect(@@ -188,6 +184,7 @@ describe("AddDataModal", () => {it("regular user should be instructed to contact their admin in order to enable uploads", async () => {setup({ isAdmin: false, uploadsEnabled: false, canUpload: true });+ await userEvent.click(await screen.findByRole("tab", { name: /CSV$/ }));expect(screen.queryByText("Manage uploads")).not.toBeInTheDocument();expect(await screen.findByRole("heading", { name: "Upload CSV files" }),@@ -212,6 +209,7 @@ describe("AddDataModal", () => {it("regular user should be instructed to contact their admin in order to gain upload permissions", async () => {setup({ isAdmin: false, uploadsEnabled: true, canUpload: false });+ await userEvent.click(await screen.findByRole("tab", { name: /CSV$/ }));expect(screen.queryByText("Manage uploads")).not.toBeInTheDocument();expect(await screen.findByRole("heading", { name: "Upload CSV files" }),@@ -236,6 +234,7 @@ describe("AddDataModal", () => {it("should show CSV panel for a regular user with sufficient permissions", async () => {setup({ isAdmin: false, uploadsEnabled: true, canUpload: true });+ await userEvent.click(await screen.findByRole("tab", { name: /CSV$/ }));expect(screen.queryByText("Manage uploads")).not.toBeInTheDocument();expect(@@ -419,6 +418,7 @@ describe("AddDataModal", () => {});async function inputUpload(fileorFiles: File | File[]) {+ await userEvent.click(await screen.findByRole("tab", { name: /CSV$/ }));const input: HTMLInputElement = await screen.findByTestId("add-data-modal-upload-csv-input",);@@ -427,6 +427,7 @@ async function inputUpload(fileorFiles: File | File[]) {}async function dropUpload(files: File[]) {+ await userEvent.click(await screen.findByRole("tab", { name: /CSV$/ }));const dropzone = await screen.findByTestId("add-data-modal-csv-dropzone");expect(dropzone).toBeInTheDocument();const dropEvent = {diff --git a/frontend/src/metabase/nav/containers/MainNavbar/MainNavbarContainer/AddDataModal/tests/premium-advanced-permissions.unit.spec.tsx b/frontend/src/metabase/nav/containers/MainNavbar/MainNavbarContainer/AddDataModal/tests/premium-advanced-permissions.unit.spec.tsxindex 05d1c168f57..3b046d63033 100644--- a/frontend/src/metabase/nav/containers/MainNavbar/MainNavbarContainer/AddDataModal/tests/premium-advanced-permissions.unit.spec.tsx+++ b/frontend/src/metabase/nav/containers/MainNavbar/MainNavbarContainer/AddDataModal/tests/premium-advanced-permissions.unit.spec.tsx@@ -8,7 +8,6 @@ describe("Add data modal (EE with token)", () => {describe("Database panel", () => {it("should not offer a setting manager to manage databases", async () => {setupAdvancedPermissions({ isAdmin: false, canManageSettings: true });- await userEvent.click(screen.getByRole("tab", { name: /Database$/ }));expect(screen.getByRole("tab", { name: /Database$/ }),@@ -26,6 +25,7 @@ describe("Add data modal (EE with token)", () => {canUpload: true,});+ await userEvent.click(await screen.findByRole("tab", { name: /CSV$/ }));expect(await screen.findByText("Manage uploads")).toBeInTheDocument();expect(await screen.findByText("Enable uploads")).toBeInTheDocument();});@@ -38,6 +38,7 @@ describe("Add data modal (EE with token)", () => {canUpload: true,});+ await userEvent.click(await screen.findByRole("tab", { name: /CSV$/ }));expect(await screen.findByText("Manage uploads")).toBeInTheDocument();});@@ -57,6 +58,7 @@ describe("Add data modal (EE with token)", () => {canUpload: false,});+ await userEvent.click(await screen.findByRole("tab", { name: /CSV$/ }));expect(await screen.findByText("Manage uploads")).toBeInTheDocument();});});