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
Fixup of Erroring Questions page (#64119)
Nick Fitzpatrick00d21cf20d1b
diff --git a/e2e/test/scenarios/admin/troubleshooting.cy.spec.js b/e2e/test/scenarios/admin/troubleshooting.cy.spec.jsindex 4e5475f3eca..3f8c642c5b9 100644--- a/e2e/test/scenarios/admin/troubleshooting.cy.spec.js+++ b/e2e/test/scenarios/admin/troubleshooting.cy.spec.js@@ -378,14 +378,7 @@ describe("scenarios > admin > tools > logs", () => {}});-// Quarantine the whole spec because it is most likely causing the H2 timeouts and the chained failures!-// NOTE: it will be quarantined on PRs, but will still run on `master`!--// UDATE:-// We need to skip this completely! CI on `master` is almost constantly red.-// TODO:-// Once the underlying problem with H2 is solved, replace `describe.skip` with `describePremium`.-describe("admin > tools > erroring questions ", { tags: "@skip" }, () => {+describe("admin > tools > erroring questions ", () => {const TOOLS_ERRORS_URL = "/admin/tools/errors";// The filter is required but doesn't have a default value setconst brokenQuestionDetails = {@@ -406,8 +399,8 @@ describe("admin > tools > erroring questions ", { tags: "@skip" }, () => {};function fixQuestion(name) {- cy.visit("/collection/root");- cy.findByText(name).click();+ cy.findByTestId("visualization-root").findByText(name).click();+cy.findByText("Open Editor").click();cy.icon("variable").click();@@ -428,7 +421,7 @@ describe("admin > tools > erroring questions ", { tags: "@skip" }, () => {});}- describe("when feature enabled", { tags: "@skip" }, () => {+ describe("when feature enabled", () => {beforeEach(() => {H.restore();cy.signInAsAdmin();@@ -438,27 +431,18 @@ describe("admin > tools > erroring questions ", { tags: "@skip" }, () => {});describe("without broken questions", () => {- it(- 'should render the "Tools" tab and navigate to the "Erroring Questions" by clicking on it',- { tags: "@skip" },- () => {- // The sidebar has been taken out, because it looks awkward when there's only one elem on it: put it back in when there's more than one- cy.visit("/admin");-- cy.get("nav").contains("Tools").click();-- cy.location("pathname").should("eq", TOOLS_ERRORS_URL);- cy.findByRole("link", { name: "Erroring Questions" })- .should("have.attr", "href")- .and("eq", TOOLS_ERRORS_URL);- },- );+ it('should render the "Tools" tab and navigate to the "Erroring Questions" by clicking on it', () => {+ // The sidebar has been taken out, because it looks awkward when there's only one elem on it: put it back in when there's more than one+ cy.visit("/admin");- it("should disable search input fields (metabase#18050)", () => {- cy.visit(TOOLS_ERRORS_URL);+ cy.get("nav").contains("Tools").click();- // eslint-disable-next-line no-unscoped-text-selectors -- deprecated usage- cy.findByText("No results");+ cy.findByRole("link", { name: /Erroring questions/ }).click();+ cy.location("pathname").should("eq", TOOLS_ERRORS_URL);++ cy.log("test no results state");++ cy.findByTestId("visualization-root").findByText("No results");cy.button("Rerun Selected").should("be.disabled");cy.findByPlaceholderText("Error contents").should("be.disabled");cy.findByPlaceholderText("DB name").should("be.disabled");@@ -485,8 +469,9 @@ describe("admin > tools > erroring questions ", { tags: "@skip" }, () => {cy.wait("@dataset");// The question is still there because we didn't fix it- // eslint-disable-next-line no-unscoped-text-selectors -- deprecated usage- cy.findByText(brokenQuestionDetails.name);+ cy.findByTestId("visualization-root").findByText(+ brokenQuestionDetails.name,+ );cy.button("Rerun Selected").should("be.disabled");cy.findByPlaceholderText("Error contents").should("not.be.disabled");@@ -497,11 +482,10 @@ describe("admin > tools > erroring questions ", { tags: "@skip" }, () => {cy.wait("@dataset");- // eslint-disable-next-line no-unscoped-text-selectors -- deprecated usage- cy.findByText("No results");- });+ cy.findByTestId("visualization-root").findByText("No results");++ cy.findByPlaceholderText("Collection name").clear();- it("should remove fixed question on a rerun", () => {fixQuestion(brokenQuestionDetails.name);cy.visit(TOOLS_ERRORS_URL);@@ -512,8 +496,7 @@ describe("admin > tools > erroring questions ", { tags: "@skip" }, () => {cy.wait("@dataset");- // eslint-disable-next-line no-unscoped-text-selectors -- deprecated usage- cy.findByText("No results");+ cy.findByTestId("visualization-root").findByText("No results");});});});diff --git a/enterprise/frontend/src/metabase-enterprise/audit_app/components/AuditTableVisualization/AuditTableVisualization.jsx b/enterprise/frontend/src/metabase-enterprise/audit_app/components/AuditTableVisualization/AuditTableVisualization.jsxindex a6418a141a2..28d781111c1 100644--- a/enterprise/frontend/src/metabase-enterprise/audit_app/components/AuditTableVisualization/AuditTableVisualization.jsx+++ b/enterprise/frontend/src/metabase-enterprise/audit_app/components/AuditTableVisualization/AuditTableVisualization.jsx@@ -17,11 +17,7 @@ import Table from "metabase/visualizations/visualizations/Table/Table";import { getColumnName, getRowValuesByColumns } from "../../lib/mode";-import {- HeaderCell,- RemoveRowButton,- RowCell,-} from "./AuditTableVisualization.styled";+import { HeaderCell, RowCell } from "./AuditTableVisualization.styled";const propTypes = {series: PropTypes.array,@@ -107,10 +103,8 @@ export class AuditTableVisualization extends Component {isSortable,isSelectable,rowChecked,- onRemoveRow,} = this.props;- const canRemoveRows = !!onRemoveRow;const columnIndexes = settings["table.columns"].filter(({ enabled }) => enabled).map(({ name }) => _.findIndex(cols, (col) => col.name === name));@@ -123,6 +117,7 @@ export class AuditTableVisualization extends Component {/>);}+return (<table className={AdminS.ContentTable}><thead>@@ -230,16 +225,6 @@ export class AuditTableVisualization extends Component {</RowCell>);})}-- {canRemoveRows && (- <td>- <RemoveRowButton- onClick={() => this.handleRemoveRowClick(row, cols)}- >- <Icon name="close" color="text-light" />- </RemoveRowButton>- </td>- )}</tr>))}</tbody>diff --git a/enterprise/frontend/src/metabase-enterprise/audit_app/components/AuditTableVisualization/AuditTableVisualization.styled.tsx b/enterprise/frontend/src/metabase-enterprise/audit_app/components/AuditTableVisualization/AuditTableVisualization.styled.tsxindex 42e843f54bb..81b68b57eb6 100644--- a/enterprise/frontend/src/metabase-enterprise/audit_app/components/AuditTableVisualization/AuditTableVisualization.styled.tsx+++ b/enterprise/frontend/src/metabase-enterprise/audit_app/components/AuditTableVisualization/AuditTableVisualization.styled.tsx@@ -1,7 +1,5 @@import styled from "@emotion/styled";-import IconButtonWrapper from "metabase/common/components/IconButtonWrapper";-interface HeaderCellProps {isSortable?: boolean;isSortedByColumn?: boolean;@@ -29,7 +27,3 @@ export const RowCell = styled.td<RowCellProps>`cursor: ${(props) => props.isClickable && "pointer"};text-align: ${(props) => props.isRightAligned && "right"};`;--export const RemoveRowButton = styled(IconButtonWrapper)`- color: var(--mb-color-text-light);-`;diff --git a/enterprise/frontend/src/metabase-enterprise/audit_app/containers/AuditTable.jsx b/enterprise/frontend/src/metabase-enterprise/audit_app/containers/AuditTable.jsxindex 5023024eb6b..80c37572c66 100644--- a/enterprise/frontend/src/metabase-enterprise/audit_app/containers/AuditTable.jsx+++ b/enterprise/frontend/src/metabase-enterprise/audit_app/containers/AuditTable.jsx@@ -80,8 +80,9 @@ function AuditTable({dispatch={dispatch}{...rest}/>- <PaginationControlsContainer>- {shouldShowPagination && (++ {shouldShowPagination && (+ <PaginationControlsContainer><PaginationControlspage={page}pageSize={pageSize}@@ -89,8 +90,9 @@ function AuditTable({onNextPage={loadedCount === pageSize ? handleNextPage : null}onPreviousPage={handlePreviousPage}/>- )}- </PaginationControlsContainer>+ </PaginationControlsContainer>+ )}+{children}</div>);diff --git a/enterprise/frontend/src/metabase-enterprise/audit_app/containers/AuditTableWithSearch.jsx b/enterprise/frontend/src/metabase-enterprise/audit_app/containers/AuditTableWithSearch.jsxdeleted file mode 100644index 48516752d30..00000000000--- a/enterprise/frontend/src/metabase-enterprise/audit_app/containers/AuditTableWithSearch.jsx+++ /dev/null@@ -1,40 +0,0 @@-import { updateIn } from "icepick";-import PropTypes from "prop-types";-import { t } from "ttag";--import { Icon } from "metabase/ui";--import AuditParameters from "../components/AuditParameters";--import AuditTable from "./AuditTable";--const propTypes = {- placeholder: PropTypes.string,- table: PropTypes.object,-};--// AuditTable but with a default search parameter that gets appended to `args`-const AuditTableWithSearch = ({ placeholder = t`Search`, table, ...props }) => (- <AuditParameters- parameters={[- { key: "search", placeholder, icon: <Icon name="search" size={16} /> },- ]}- >- {({ search }) => (- <AuditTable- {...props}- table={- search- ? updateIn(table, ["card", "dataset_query", "args"], (args) =>- (args || []).concat(search),- )- : table- }- />- )}- </AuditParameters>-);--AuditTableWithSearch.propTypes = propTypes;--export default AuditTableWithSearch;diff --git a/enterprise/frontend/src/metabase-enterprise/tools/mode.js b/enterprise/frontend/src/metabase-enterprise/tools/mode.jsindex f4536b49183..40d65b3a25c 100644--- a/enterprise/frontend/src/metabase-enterprise/tools/mode.js+++ b/enterprise/frontend/src/metabase-enterprise/tools/mode.js@@ -1,6 +1,8 @@import { push } from "react-router-redux";import { t } from "ttag";+import { question } from "metabase/lib/urls";+const CARD_ID_ROW_IDX = 0;const ErrorDrill = ({ clicked }) => {@@ -16,7 +18,7 @@ const ErrorDrill = ({ clicked }) => {title: t`View this`,default: true,action() {- return push(`/admin/tools/errors/${cardId}`);+ return push(question({ id: cardId }));},},];@@ -24,5 +26,5 @@ const ErrorDrill = ({ clicked }) => {export const ErrorMode = {name: "error",- drills: [ErrorDrill],+ fallback: (props) => ErrorDrill(props),};diff --git a/frontend/src/metabase/visualizations/components/Visualization/Visualization.tsx b/frontend/src/metabase/visualizations/components/Visualization/Visualization.tsxindex 937241f7b09..1af09a0c695 100644--- a/frontend/src/metabase/visualizations/components/Visualization/Visualization.tsx+++ b/frontend/src/metabase/visualizations/components/Visualization/Visualization.tsx@@ -611,6 +611,10 @@ class Visualization extends PureComponent<onEditSummary,queryBuilderMode,rawSeries = [],+ isSelectable,+ rowChecked,+ onAllSelectClick,+ onRowSelectClick,visualizerRawSeries,renderEmptyMessage,renderLoadingView = LoadingView,@@ -905,6 +909,11 @@ class Visualization extends PureComponent<onHeaderColumnReorder={this.props.onHeaderColumnReorder}titleMenuItems={hasHeader ? undefined : titleMenuItems}tableFooterExtraButtons={tableFooterExtraButtons}+ // These props are only used by the table on the Erroring Questions admin page+ isSelectable={isSelectable}+ rowChecked={rowChecked}+ onAllSelectClick={onAllSelectClick}+ onRowSelectClick={onRowSelectClick}/></VisualizationRenderedWrapper>{hasDevWatermark && <Watermark card={series[0].card} />}diff --git a/frontend/src/metabase/visualizations/types/visualization.ts b/frontend/src/metabase/visualizations/types/visualization.tsindex 5c03d1b9d69..dcd69f0932a 100644--- a/frontend/src/metabase/visualizations/types/visualization.ts+++ b/frontend/src/metabase/visualizations/types/visualization.ts@@ -241,6 +241,14 @@ export type VisualizationPassThroughProps = {* Extra buttons to be shown in the table footer (if the visualization is a table)*/tableFooterExtraButtons?: React.ReactNode;++ /**+ * Props used for Audit Table visualization+ */+ isSelectable?: boolean;+ rowChecked?: [];+ onAllSelectClick?: () => void;+ onRowSelectClick?: () => void;};export type ColumnSettingDefinition<TValue, TProps = unknown> = {