diff --git a/e2e/test/scenarios/visualizations-tabular/table-column-settings.cy.spec.js b/e2e/test/scenarios/visualizations-tabular/table-column-settings.cy.spec.js index 0177561c7efdd357e14211eb63ea48f406470912..65f9966f5bbd0656e7142741c803f6480122231f 100644 --- a/e2e/test/scenarios/visualizations-tabular/table-column-settings.cy.spec.js +++ b/e2e/test/scenarios/visualizations-tabular/table-column-settings.cy.spec.js @@ -496,8 +496,6 @@ describe("scenarios > visualizations > table column settings", () => { _hideColumn(testData); _showColumn(testData); - _removeColumn(testData); - _addColumn(testData); }); it("should be able to show and hide custom expressions for a table with selected fields", () => { @@ -515,8 +513,6 @@ describe("scenarios > visualizations > table column settings", () => { _hideColumn(testData); _showColumn(testData); - _removeColumn(testData); - _addColumn(testData); }); it("should be able to show and hide columns from aggregations", () => { diff --git a/frontend/src/metabase/querying/components/FieldPanel/FieldPanel.unit.spec.tsx b/frontend/src/metabase/querying/components/FieldPanel/FieldPanel.unit.spec.tsx index b47cc14092b1fa13c9758d6e591d354bcfc11c6b..cdf62381e212452eab77ed849acf1a44523189a9 100644 --- a/frontend/src/metabase/querying/components/FieldPanel/FieldPanel.unit.spec.tsx +++ b/frontend/src/metabase/querying/components/FieldPanel/FieldPanel.unit.spec.tsx @@ -2,7 +2,7 @@ import userEvent from "@testing-library/user-event"; import { useState } from "react"; import { renderWithProviders, screen } from "__support__/ui"; -import type * as Lib from "metabase-lib"; +import * as Lib from "metabase-lib"; import { createQuery } from "metabase-lib/test-helpers"; import { FieldPanel } from "./FieldPanel"; @@ -116,6 +116,22 @@ describe("QueryColumnPicker", () => { expect(firstColumn).toBeEnabled(); }); + it("should not allow to remove custom columns", () => { + const query = Lib.expression( + createQuery(), + -1, + "Custom", + Lib.expressionClause("+", [1, 2]), + ); + setup({ query }); + const [orderGroup] = screen.getAllByRole("checkbox"); + const customColumn = screen.getByRole("checkbox", { name: "Custom" }); + expect(orderGroup).toBeChecked(); + expect(orderGroup).toBeDisabled(); + expect(customColumn).toBeChecked(); + expect(customColumn).toBeDisabled(); + }); + it("should allow to search for columns", () => { setup(); userEvent.type(screen.getByPlaceholderText("Search for a column…"), "a"); diff --git a/frontend/src/metabase/querying/components/FieldPanel/utils.ts b/frontend/src/metabase/querying/components/FieldPanel/utils.ts index 03c7bed4153a1069a1997a89451e69016e50215b..f312bd0608aaf46ccc23cae2c50a5c14e821b955 100644 --- a/frontend/src/metabase/querying/components/FieldPanel/utils.ts +++ b/frontend/src/metabase/querying/components/FieldPanel/utils.ts @@ -24,7 +24,10 @@ function getColumnItems( column, displayName: columnInfo.displayName, isSelected: columnInfo.selected ?? false, - isDisabled: columnInfo.isAggregation || columnInfo.isBreakout, + isDisabled: + columnInfo.isAggregation || + columnInfo.isBreakout || + columnInfo.isCalculated, }; }); }