]> source.dussan.org Git - sonarqube.git/commitdiff
GOV-316 Add "has always been X" for ratings that never changed
authorPascal Mugnier <pascal.mugnier@sonarsource.com>
Wed, 11 Apr 2018 07:44:24 +0000 (09:44 +0200)
committerSonarTech <sonartech@sonarsource.com>
Tue, 17 Apr 2018 18:20:47 +0000 (20:20 +0200)
12 files changed:
server/sonar-web/src/main/js/apps/portfolio/components/MaintainabilityBox.tsx
server/sonar-web/src/main/js/apps/portfolio/components/RatingFreshness.tsx
server/sonar-web/src/main/js/apps/portfolio/components/ReleasabilityBox.tsx
server/sonar-web/src/main/js/apps/portfolio/components/ReliabilityBox.tsx
server/sonar-web/src/main/js/apps/portfolio/components/SecurityBox.tsx
server/sonar-web/src/main/js/apps/portfolio/components/__tests__/RatingFreshness-test.tsx
server/sonar-web/src/main/js/apps/portfolio/components/__tests__/__snapshots__/MaintainabilityBox-test.tsx.snap
server/sonar-web/src/main/js/apps/portfolio/components/__tests__/__snapshots__/RatingFreshness-test.tsx.snap
server/sonar-web/src/main/js/apps/portfolio/components/__tests__/__snapshots__/ReleasabilityBox-test.tsx.snap
server/sonar-web/src/main/js/apps/portfolio/components/__tests__/__snapshots__/ReliabilityBox-test.tsx.snap
server/sonar-web/src/main/js/apps/portfolio/components/__tests__/__snapshots__/SecurityBox-test.tsx.snap
sonar-core/src/main/resources/org/sonar/l10n/core.properties

index 1f8619e9885ac6ba00028d8fcb5bff92abfa75de..4e3564d63b165e680cd3f72be4658676472f105d 100644 (file)
@@ -46,7 +46,7 @@ export default function MaintainabilityBox({ component, measures }: Props) {
 
       {rating && <MainRating component={component} metric={'sqale_rating'} value={rating} />}
 
-      <RatingFreshness lastChange={lastMaintainabilityChange} />
+      <RatingFreshness lastChange={lastMaintainabilityChange} rating={rating} />
 
       {effort && <Effort component={component} effort={effort} metricKey={'sqale_rating'} />}
     </div>
index 0760429fd1299e77b7467fa41223c0aa2611992c..bb28c4be116489886ec8aa079576288bb6066f2f 100644 (file)
@@ -25,11 +25,20 @@ import { translate } from '../../../helpers/l10n';
 
 interface Props {
   lastChange?: string;
+  rating?: string;
 }
 
-export default function RatingFreshness({ lastChange }: Props) {
+export default function RatingFreshness({ lastChange, rating }: Props) {
   if (!lastChange) {
-    return <div className="portfolio-freshness">&nbsp;</div>;
+    return (
+      <div className="portfolio-freshness">
+        {rating && (
+          <>
+            {translate('portfolio.has_always_been')} <Rating small={true} value={rating} />
+          </>
+        )}
+      </div>
+    );
   }
 
   const data = JSON.parse(lastChange);
@@ -40,7 +49,7 @@ export default function RatingFreshness({ lastChange }: Props) {
         defaultMessage={translate('portfolio.was_x_y')}
         id="portfolio.was_x_y"
         values={{
-          rating: <Rating value={data.value} small={true} />,
+          rating: <Rating small={true} value={data.value} />,
           date: <DateFromNow date={data.date} />
         }}
       />
index ff7a2dd2f157bd9eba4e1957d08fb954b1c0b8ef..a33d40f9ef17f6dd1475d8467e1156ed02984f7a 100644 (file)
@@ -47,7 +47,7 @@ export default function ReleasabilityBox({ component, measures }: Props) {
         </Link>
       )}
 
-      <RatingFreshness lastChange={lastReleasabilityChange} />
+      <RatingFreshness lastChange={lastReleasabilityChange} rating={rating} />
 
       {effort &&
         Number(effort) > 0 && (
index 1875e38e7b306efeaa7f1842278aa3474bce25c7..797f74290e4a7d486783607e7298b60296525f98 100644 (file)
@@ -46,7 +46,7 @@ export default function ReliabilityBox({ component, measures }: Props) {
 
       {rating && <MainRating component={component} metric="reliability_rating" value={rating} />}
 
-      <RatingFreshness lastChange={lastReliabilityChange} />
+      <RatingFreshness lastChange={lastReliabilityChange} rating={rating} />
 
       {effort && <Effort component={component} effort={effort} metricKey="reliability_rating" />}
     </div>
index a80f269ecaa0cf0f5144fe1b4cfa51fccef53d8d..0cd905f5bb0b7ae30e2b2839101772de91332db5 100644 (file)
@@ -46,7 +46,7 @@ export default function SecurityBox({ component, measures }: Props) {
 
       {rating && <MainRating component={component} metric="security_rating" value={rating} />}
 
-      <RatingFreshness lastChange={lastSecurityChange} />
+      <RatingFreshness lastChange={lastSecurityChange} rating={rating} />
 
       {effort && <Effort component={component} effort={effort} metricKey="security_rating" />}
     </div>
index 627c65c3c1c70081aca3c6712e7b802894a3fc2e..a89bb6d1178edb8ffe23cff148cd63927dcefbb4 100644 (file)
@@ -26,6 +26,10 @@ it('renders', () => {
   expect(shallow(<RatingFreshness lastChange={lastChange} />)).toMatchSnapshot();
 });
 
+it('renders has always been', () => {
+  expect(shallow(<RatingFreshness rating="A" />)).toMatchSnapshot();
+});
+
 it('renders empty', () => {
   expect(shallow(<RatingFreshness />)).toMatchSnapshot();
 });
index 874b02296e22633b00dec763836e0476bdf1c756..eaf8d2609a40a230bf4d0063808bd53ba6151c95 100644 (file)
@@ -24,6 +24,7 @@ exports[`renders 1`] = `
   />
   <RatingFreshness
     lastChange="{\\"date\\":\\"2017-01-02T00:00:00.000Z\\",\\"value\\":2}"
+    rating="3"
   />
   <Effort
     component="foo"
index 7e0c44f1ca47451a8fc7ee09111147df1a39fad2..4cb8a857051fe5b9e192f707e7bd3ef1381b21c2 100644 (file)
@@ -23,9 +23,22 @@ exports[`renders 1`] = `
 `;
 
 exports[`renders empty 1`] = `
+<div
+  className="portfolio-freshness"
+/>
+`;
+
+exports[`renders has always been 1`] = `
 <div
   className="portfolio-freshness"
 >
-   
+  <React.Fragment>
+    portfolio.has_always_been
+     
+    <Rating
+      small={true}
+      value="A"
+    />
+  </React.Fragment>
 </div>
 `;
index 2401a4dc09b71481af3808fddd93ca7b2c9e05f6..9374965500cbbe516006ba582dd0030e78a3449e 100644 (file)
@@ -29,6 +29,7 @@ exports[`renders 1`] = `
   </Link>
   <RatingFreshness
     lastChange="{\\"date\\":\\"2017-01-02T00:00:00.000Z\\",\\"value\\":2}"
+    rating="3"
   />
   <div
     className="portfolio-effort"
index e5b35707fa0ae2416032addd9f7754aefcab22d6..426f6290acd9644180a0dfeaaa9b9ddbf1b059f1 100644 (file)
@@ -24,6 +24,7 @@ exports[`renders 1`] = `
   />
   <RatingFreshness
     lastChange="{\\"date\\":\\"2017-01-02T00:00:00.000Z\\",\\"value\\":2}"
+    rating="3"
   />
   <Effort
     component="foo"
index b2966238d594deb3711d21c712a2a195719edfe7..3795a1b585f0c32fea1eb6e3785965ab2a47fdf3 100644 (file)
@@ -24,6 +24,7 @@ exports[`renders 1`] = `
   />
   <RatingFreshness
     lastChange="{\\"date\\":\\"2017-01-02T00:00:00.000Z\\",\\"value\\":2}"
+    rating="3"
   />
   <Effort
     component="foo"
index 70ac03a89788c257021e6b9439706d31f2ea628c..d93850a56e63ebcbae50325036b467b1e9f4656b 100644 (file)
@@ -2678,6 +2678,7 @@ branches.see_the_pr=See the PR
 # PORTFOLIOS
 #
 #------------------------------------------------------------------------------
+portfolio.has_always_been=has always been
 portfolio.was_x_y=was {rating} {date}
 portfolio.x_in_y={projects} in {rating}
 portfolio.empty=This portfolio is empty.