]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-12719 Handle labels in actions
authorJeremy Davis <jeremy.davis@sonarsource.com>
Thu, 9 Jan 2020 13:08:12 +0000 (14:08 +0100)
committerSonarTech <sonartech@sonarsource.com>
Mon, 13 Jan 2020 19:46:38 +0000 (20:46 +0100)
server/sonar-web/src/main/js/apps/securityHotspots/components/HotspotActionsFormRenderer.tsx
server/sonar-web/src/main/js/apps/securityHotspots/components/__tests__/__snapshots__/HotspotActionsFormRenderer-test.tsx.snap
sonar-core/src/main/resources/org/sonar/l10n/core.properties

index 829df46d1a0e985bc122292a31d3c0c8fae342a4..e6a382828db9c0b4066f4f11e43fa81bed38dee1 100644 (file)
@@ -21,6 +21,7 @@ import * as classnames from 'classnames';
 import * as React from 'react';
 import { SubmitButton } from 'sonar-ui-common/components/controls/buttons';
 import Radio from 'sonar-ui-common/components/controls/Radio';
+import Tooltip from 'sonar-ui-common/components/controls/Tooltip';
 import { translate } from 'sonar-ui-common/helpers/l10n';
 import MarkdownTips from '../../../components/common/MarkdownTips';
 import {
@@ -50,7 +51,11 @@ export default function HotspotActionsFormRenderer(props: HotspotActionsFormRend
 
   return (
     <form className="abs-width-400 padded" onSubmit={props.onSubmit}>
-      <h2>{translate('hotspots.form.title')}</h2>
+      <h2>
+        {disableStatusChange
+          ? translate('hotspots.form.title.disabled')
+          : translate('hotspots.form.title')}
+      </h2>
       <div className="display-flex-column big-spacer-bottom">
         {renderOption({
           disabled: disableStatusChange,
@@ -140,7 +145,8 @@ function renderOption(params: {
   selectedOption: HotspotStatusOption;
 }) {
   const { disabled, onClick, option, selectedOption } = params;
-  return (
+
+  const optionRender = (
     <div className="big-spacer-top">
       <Radio
         checked={selectedOption === option}
@@ -156,4 +162,12 @@ function renderOption(params: {
       </div>
     </div>
   );
+
+  return disabled ? (
+    <Tooltip overlay={translate('hotspots.form.cannot_change_status')} placement="left">
+      {optionRender}
+    </Tooltip>
+  ) : (
+    optionRender
+  );
 }
index 25f5ec0e7a52a15065294251d3fee0edcd5283c7..3aec0f399807274832b7bf3d56586cb68ad47fd2 100644 (file)
@@ -219,74 +219,89 @@ exports[`should render correctly: restricted access 1`] = `
   onSubmit={[MockFunction]}
 >
   <h2>
-    hotspots.form.title
+    hotspots.form.title.disabled
   </h2>
   <div
     className="display-flex-column big-spacer-bottom"
   >
-    <div
-      className="big-spacer-top"
+    <Tooltip
+      overlay="hotspots.form.cannot_change_status"
+      placement="left"
     >
-      <Radio
-        checked={true}
-        className="disabled"
-        onCheck={[Function]}
-        value="FIXED"
-      >
-        <h3
-          className="text-muted"
-        >
-          hotspots.status_option.FIXED
-        </h3>
-      </Radio>
       <div
-        className="radio-button-description text-muted"
+        className="big-spacer-top"
       >
-        hotspots.status_option.FIXED.description
+        <Radio
+          checked={true}
+          className="disabled"
+          onCheck={[Function]}
+          value="FIXED"
+        >
+          <h3
+            className="text-muted"
+          >
+            hotspots.status_option.FIXED
+          </h3>
+        </Radio>
+        <div
+          className="radio-button-description text-muted"
+        >
+          hotspots.status_option.FIXED.description
+        </div>
       </div>
-    </div>
-    <div
-      className="big-spacer-top"
+    </Tooltip>
+    <Tooltip
+      overlay="hotspots.form.cannot_change_status"
+      placement="left"
     >
-      <Radio
-        checked={false}
-        className="disabled"
-        onCheck={[Function]}
-        value="SAFE"
-      >
-        <h3
-          className="text-muted"
-        >
-          hotspots.status_option.SAFE
-        </h3>
-      </Radio>
       <div
-        className="radio-button-description text-muted"
+        className="big-spacer-top"
       >
-        hotspots.status_option.SAFE.description
+        <Radio
+          checked={false}
+          className="disabled"
+          onCheck={[Function]}
+          value="SAFE"
+        >
+          <h3
+            className="text-muted"
+          >
+            hotspots.status_option.SAFE
+          </h3>
+        </Radio>
+        <div
+          className="radio-button-description text-muted"
+        >
+          hotspots.status_option.SAFE.description
+        </div>
       </div>
-    </div>
-    <div
-      className="big-spacer-top"
+    </Tooltip>
+    <Tooltip
+      overlay="hotspots.form.cannot_change_status"
+      placement="left"
     >
-      <Radio
-        checked={false}
-        className="disabled"
-        onCheck={[Function]}
-        value="ADDITIONAL_REVIEW"
-      >
-        <h3
-          className="text-muted"
-        >
-          hotspots.status_option.ADDITIONAL_REVIEW
-        </h3>
-      </Radio>
       <div
-        className="radio-button-description text-muted"
+        className="big-spacer-top"
       >
-        hotspots.status_option.ADDITIONAL_REVIEW.description
+        <Radio
+          checked={false}
+          className="disabled"
+          onCheck={[Function]}
+          value="ADDITIONAL_REVIEW"
+        >
+          <h3
+            className="text-muted"
+          >
+            hotspots.status_option.ADDITIONAL_REVIEW
+          </h3>
+        </Radio>
+        <div
+          className="radio-button-description text-muted"
+        >
+          hotspots.status_option.ADDITIONAL_REVIEW.description
+        </div>
       </div>
-    </div>
+    </Tooltip>
   </div>
   <div
     className="display-flex-column big-spacer-bottom"
index 0e17f23518b2fe8cd78e6c195329146feda1ae9f..465c975cfea244e608b490f6d0706f28a994c5f7 100644 (file)
@@ -690,11 +690,13 @@ hotspot.filters.show_all=Show all hotspots
 hotspots.review_hotspot=Review Hotspot
 
 hotspots.form.title=Mark Security Hotspot as:
+hotspots.form.title.disabled=Security Hotspot is marked as:
 
+hotspots.form.cannot_change_status=Changing a hotspot's status requires permission.
 hotspots.form.assign_to=Assign to:
 hotspots.form.select_user=Select a user...
 hotspots.form.comment=Comment:
-hotspots.form.comment.placeholder=This status requires justification
+hotspots.form.comment.placeholder=For tracking purposes, we highly recommend explaining why the code is safe.
 hotspots.form.submit.TO_REVIEW=Submit Review
 hotspots.form.submit.REVIEWED=Apply changes