]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-23582 Do not show severity recommendation on rule update
authorstanislavh <stanislav.honcharov@sonarsource.com>
Fri, 15 Nov 2024 11:02:37 +0000 (12:02 +0100)
committersonartech <sonartech@sonarsource.com>
Fri, 15 Nov 2024 20:02:42 +0000 (20:02 +0000)
server/sonar-web/src/main/js/apps/coding-rules/components/CustomRuleFormModal.tsx
server/sonar-web/src/main/js/apps/coding-rules/components/SeveritySelect.tsx

index 12e43b222e87e957f33712cb9acda625aa3bf62c..4841c3ae8f557fd9ebb23af06494c25e5ea8d6ce 100644 (file)
@@ -340,7 +340,7 @@ export default function CustomRuleFormModal(props: Readonly<Props>) {
           isDisabled={submitting}
           onChange={(value) => setStandardSeverity(value)}
           severity={standardSeverity}
-          recommendedSeverity={templateRule.severity ?? customRule?.severity}
+          recommendedSeverity={customRule?.severity ? undefined : templateRule.severity}
         />
       </FormField>
     ),
index 358c5e1ddbcd5274409dad56efc24f0e547a15e6..cc0969a699bbf02484602b3b5e05f7d73cd5daab 100644 (file)
@@ -19,7 +19,7 @@
  */
 
 import { HelperText, Select } from '@sonarsource/echoes-react';
-import { isEmpty } from 'lodash';
+import { isEmpty, isUndefined } from 'lodash';
 import { FormattedMessage, useIntl } from 'react-intl';
 import SoftwareImpactSeverityIcon from '../../../components/icon-mappers/SoftwareImpactSeverityIcon';
 import { SEVERITIES } from '../../../helpers/constants';
@@ -30,7 +30,7 @@ export interface SeveritySelectProps {
   impactSeverity?: boolean;
   isDisabled: boolean;
   onChange: (value: string) => void;
-  recommendedSeverity: string;
+  recommendedSeverity?: string;
   severity: string;
 }
 
@@ -70,7 +70,7 @@ export function SeveritySelect(props: SeveritySelectProps) {
         value={severity}
         valueIcon={<SoftwareImpactSeverityIcon severity={severity} aria-hidden />}
       />
-      {severity !== recommendedSeverity && (
+      {severity !== recommendedSeverity && !isUndefined(recommendedSeverity) && (
         <HelperText className="sw-mt-2">
           <FormattedMessage
             id="coding_rules.custom_severity.not_recommended"