diff --git a/scm-ui/ui-components/src/MarkdownView.tsx b/scm-ui/ui-components/src/MarkdownView.tsx index 7ad8889bc3..3e20830585 100644 --- a/scm-ui/ui-components/src/MarkdownView.tsx +++ b/scm-ui/ui-components/src/MarkdownView.tsx @@ -21,7 +21,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -import React from "react"; +import React, { FC } from "react"; import { withRouter, RouteComponentProps } from "react-router-dom"; // @ts-ignore import Markdown from "react-markdown/with-html"; @@ -29,6 +29,8 @@ import { binder } from "@scm-manager/ui-extensions"; import ErrorBoundary from "./ErrorBoundary"; import SyntaxHighlighter from "./SyntaxHighlighter"; import MarkdownHeadingRenderer from "./MarkdownHeadingRenderer"; +import { useTranslation } from "react-i18next"; +import Notification from "./Notification"; type Props = RouteComponentProps & { content: string; @@ -38,6 +40,35 @@ type Props = RouteComponentProps & { enableAnchorHeadings?: boolean; }; +const xmlMarkupSample = `\`\`\`xml + + + + + +\`\`\``; + +const MarkdownErrorNotification: FC = () => { + const [t] = useTranslation("commons"); + return ( + +
+

{t("markdownErrorNotification.title")}

+

{t("markdownErrorNotification.description")}

+
+          {xmlMarkupSample}
+        
+

+ {t("markdownErrorNotification.spec")}:{" "} + + GitHub Flavored Markdown Spec + +

+
+
+ ); +}; + class MarkdownView extends React.Component { static defaultProps: Partial = { enableAnchorHeadings: false, @@ -88,7 +119,7 @@ class MarkdownView extends React.Component { } return ( - +
(this.contentRef = el)}> - - errorNotification.prefix - : - - - Cannot read property 'children' of undefined +
+

+ markdownErrorNotification.title +

+

+ markdownErrorNotification.description +

+
+        
+          \`\`\`xml
+<your>
+  <xml>
+    <content/>
+  </xml>
+</your>
+\`\`\`
+        
+      
+

+ markdownErrorNotification.spec + : + + + GitHub Flavored Markdown Spec + +

+
`; diff --git a/scm-ui/ui-webapp/public/locales/de/commons.json b/scm-ui/ui-webapp/public/locales/de/commons.json index 8b9e9942e7..902a11c9e0 100644 --- a/scm-ui/ui-webapp/public/locales/de/commons.json +++ b/scm-ui/ui-webapp/public/locales/de/commons.json @@ -33,6 +33,11 @@ "wrongLoginCredentials": "Ungültige Anmeldedaten", "forbidden": "Sie haben nicht die Berechtigung, diesen Datensatz zu sehen" }, + "markdownErrorNotification": { + "title": "Markdown Inhalt konnte nicht geparsed werden", + "description": "Der Inhalt enthält kein valides Markdown. Wenn XML im Inhalt verwendet wird, muss sicher gestellt werden das sich dieser in einem Code-Block befindet z.B.:", + "spec": "Die Spezifikation kann hier eingesehen werden" + }, "loading": { "alt": "Lade ..." }, diff --git a/scm-ui/ui-webapp/public/locales/en/commons.json b/scm-ui/ui-webapp/public/locales/en/commons.json index 6b7b6c8fb6..f15a0890c6 100644 --- a/scm-ui/ui-webapp/public/locales/en/commons.json +++ b/scm-ui/ui-webapp/public/locales/en/commons.json @@ -34,6 +34,11 @@ "wrongLoginCredentials": "Invalid credentials", "forbidden": "You don't have permission to view this entity" }, + "markdownErrorNotification": { + "title": "Markdown content could not be parsed", + "description": "Content does not contain valid markdown. If you use XML, please ensure that it is wrapped in a code block e.g.:", + "spec": "Please have a look at the specification" + }, "loading": { "alt": "Loading ..." },