]> source.dussan.org Git - sonarqube.git/commitdiff
avoid passing null values to SeverityHelper
authorStas Vilchik <stas.vilchik@sonarsource.com>
Wed, 2 Jan 2019 14:54:58 +0000 (15:54 +0100)
committerSonarTech <sonartech@sonarsource.com>
Mon, 7 Jan 2019 19:21:00 +0000 (20:21 +0100)
server/sonar-web/src/main/js/apps/quality-profiles/changelog/ChangesList.tsx
server/sonar-web/src/main/js/apps/quality-profiles/changelog/SeverityChange.tsx
server/sonar-web/src/main/js/components/shared/SeverityHelper.tsx

index 629c8bf6c1f6348db902dc397d92700bcfb94d8c..acbb45c981d6b8a555e9e2cd62ebc73b61a348ff 100644 (file)
@@ -26,12 +26,17 @@ interface Props {
 }
 
 export default function ChangesList({ changes }: Props) {
+  const renderSeverity = (key: string) => {
+    const severity = changes[key];
+    return severity ? <SeverityChange severity={severity} /> : null;
+  };
+
   return (
     <ul>
       {Object.keys(changes).map(key => (
         <li key={key}>
           {key === 'severity' ? (
-            <SeverityChange severity={changes[key]} />
+            renderSeverity(key)
           ) : (
             <ParameterChange name={key} value={changes[key]} />
           )}
index 8a843689a60982640b7e46e89fc4712a288b4a3d..815224e48a37b43b34de30b129047b9fd01affa1 100644 (file)
@@ -22,7 +22,7 @@ import SeverityHelper from '../../../components/shared/SeverityHelper';
 import { translate } from '../../../helpers/l10n';
 
 interface Props {
-  severity: string | null;
+  severity: string;
 }
 
 export default function SeverityChange({ severity }: Props) {
index cec03cf70148acff2fef0f590dbff817b0b8221a..7d9e0c42cb832d6a390877eccc23ac1f47521d91 100644 (file)
@@ -23,8 +23,7 @@ import { translate } from '../../helpers/l10n';
 
 interface Props {
   className?: string;
-  // TODO avoid passing nil values
-  severity: string | undefined | null;
+  severity: string;
 }
 
 export default function SeverityHelper({ className, severity }: Props) {