Don't crash if name is null or undefined
authorPeter Amstutz <peter.amstutz@curii.com>
Tue, 4 Feb 2020 18:18:45 +0000 (13:18 -0500)
committerPeter Amstutz <peter.amstutz@curii.com>
Tue, 4 Feb 2020 18:18:45 +0000 (13:18 -0500)
no issue #

Arvados-DCO-1.1-Signed-off-by: Peter Amstutz <peter.amstutz@curii.com>

src/components/warning/warning.tsx

index bd3303616d7e41a9b7f618ec6742df558c8cc159..95e495d72a038db1b48a66d9f06738028803899f 100644 (file)
@@ -16,11 +16,12 @@ interface WarningComponentProps {
 }
 
 export const WarningComponent = ({ text, rules, message }: WarningComponentProps) =>
-    rules.find(aRule => text.match(aRule) !== null)
-        ? message
-            ? <Tooltip title={message}><ErrorIcon /></Tooltip>
-            : <ErrorIcon />
-        : null;
+    !text ? <Tooltip title={"No name"}><ErrorIcon /></Tooltip>
+        : (rules.find(aRule => text.match(aRule) !== null)
+            ? message
+                ? <Tooltip title={message}><ErrorIcon /></Tooltip>
+                : <ErrorIcon />
+            : null);
 
 interface IllegalNamingWarningProps {
     name: string;