From 10eb646ae987bc0f8e7233d448c20d61cac17dd7 Mon Sep 17 00:00:00 2001 From: Frank Niessink Date: Tue, 21 Jan 2025 15:59:23 +0100 Subject: [PATCH] Fix issue tracker error message being too narrow and remove duplication between ErrorMessage and WarningMessage components. No GitHub issue because this issue was not released yet. --- components/frontend/src/issue/IssuesRows.js | 24 +++++++++++-------- components/frontend/src/source/Source.js | 24 +++++++++++++++---- .../frontend/src/widgets/ErrorMessage.js | 23 ------------------ .../frontend/src/widgets/WarningMessage.js | 5 ++-- 4 files changed, 37 insertions(+), 39 deletions(-) delete mode 100644 components/frontend/src/widgets/ErrorMessage.js diff --git a/components/frontend/src/issue/IssuesRows.js b/components/frontend/src/issue/IssuesRows.js index 98250191a8..cf787a2414 100644 --- a/components/frontend/src/issue/IssuesRows.js +++ b/components/frontend/src/issue/IssuesRows.js @@ -9,9 +9,9 @@ import { MultipleChoiceField } from "../fields/MultipleChoiceField" import { metricPropType, reportPropType } from "../sharedPropTypes" import { getMetricIssueIds } from "../utils" import { ActionButton } from "../widgets/buttons/ActionButton" -import { ErrorMessage } from "../widgets/ErrorMessage" import { AddItemIcon } from "../widgets/icons" import { showMessage } from "../widgets/toast" +import { WarningMessage } from "../widgets/WarningMessage" function CreateIssueButton({ issueTrackerConfigured, issueTrackerInstruction, metric_uuid, target, reload }) { const permissions = useContext(Permissions) @@ -106,7 +106,7 @@ export function IssuesRows({ metric, metric_uuid, reload, report, target }) { } return ( <> - + - + {getMetricIssueIds(metric).length > 0 && !issueTrackerConfigured && ( - + {issueTrackerInstruction} )} {(metric.issue_status ?? []) .filter((issue_status) => issue_status.connection_error) .map((issue_status) => ( - + > + {issue_status.connection_error} + ))} {(metric.issue_status ?? []) .filter((issue_status) => issue_status.parse_error) .map((issue_status) => ( - + > + {issue_status.parse_error} + ))} diff --git a/components/frontend/src/source/Source.js b/components/frontend/src/source/Source.js index 3f9e8c65a8..b1580d2d84 100644 --- a/components/frontend/src/source/Source.js +++ b/components/frontend/src/source/Source.js @@ -20,9 +20,9 @@ import { getMetricName, getSourceName, referenceDocumentationURL } from "../util import { ButtonRow } from "../widgets/ButtonRow" import { DeleteButton } from "../widgets/buttons/DeleteButton" import { ReorderButtonGroup } from "../widgets/buttons/ReorderButtonGroup" -import { ErrorMessage } from "../widgets/ErrorMessage" import { HyperLink } from "../widgets/HyperLink" import { Tabs } from "../widgets/Tabs" +import { WarningMessage } from "../widgets/WarningMessage" import { SourceParameters } from "./SourceParameters" import { SourceType } from "./SourceType" @@ -104,9 +104,25 @@ function Parameters({ source_uuid={source_uuid} /> - {connection_error && } - {parse_error && } - {config_error && } + {connection_error && ( + + + {connection_error} + + + )} + {parse_error && ( + + + {parse_error} + + + )} + {config_error && ( + + {config_error} + + )} ) } diff --git a/components/frontend/src/widgets/ErrorMessage.js b/components/frontend/src/widgets/ErrorMessage.js deleted file mode 100644 index 02e03bc64a..0000000000 --- a/components/frontend/src/widgets/ErrorMessage.js +++ /dev/null @@ -1,23 +0,0 @@ -import Grid from "@mui/material/Grid2" -import { bool, object, oneOfType, string } from "prop-types" - -import { WarningMessage } from "./WarningMessage" - -export function ErrorMessage({ formatAsText, message, title }) { - return ( - - - {formatAsText ? ( - message - ) : ( -
{message}
- )} -
-
- ) -} -ErrorMessage.propTypes = { - formatAsText: bool, - message: oneOfType([object, string]), - title: string, -} diff --git a/components/frontend/src/widgets/WarningMessage.js b/components/frontend/src/widgets/WarningMessage.js index 18de1cfe31..4520675be2 100644 --- a/components/frontend/src/widgets/WarningMessage.js +++ b/components/frontend/src/widgets/WarningMessage.js @@ -3,17 +3,18 @@ import { bool, string } from "prop-types" import { childrenPropType } from "../sharedPropTypes" -export function WarningMessage({ children, title, showIf }) { +export function WarningMessage({ children, pre, showIf, title }) { // Show a warning message if showIf is true or undefined return (showIf ?? true) ? ( {title} - {children} + {pre ?
{children}
: children}
) : null } WarningMessage.propTypes = { children: childrenPropType, + pre: bool, showIf: bool, title: string, }