diff options
author | Pascal Mugnier <pascal.mugnier@sonarsource.com> | 2018-04-11 09:44:24 +0200 |
---|---|---|
committer | SonarTech <sonartech@sonarsource.com> | 2018-04-17 20:20:47 +0200 |
commit | 5575882cee119d3e1705e203e2105d3046b0a093 (patch) | |
tree | 906d4d42b1174bb091c0751b22794df85f93435b | |
parent | de390c4a3cf6a30f11a22bb99726900a42137477 (diff) | |
download | sonarqube-5575882cee119d3e1705e203e2105d3046b0a093.tar.gz sonarqube-5575882cee119d3e1705e203e2105d3046b0a093.zip |
GOV-316 Add "has always been X" for ratings that never changed
12 files changed, 39 insertions, 8 deletions
diff --git a/server/sonar-web/src/main/js/apps/portfolio/components/MaintainabilityBox.tsx b/server/sonar-web/src/main/js/apps/portfolio/components/MaintainabilityBox.tsx index 1f8619e9885..4e3564d63b1 100644 --- a/server/sonar-web/src/main/js/apps/portfolio/components/MaintainabilityBox.tsx +++ b/server/sonar-web/src/main/js/apps/portfolio/components/MaintainabilityBox.tsx @@ -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> diff --git a/server/sonar-web/src/main/js/apps/portfolio/components/RatingFreshness.tsx b/server/sonar-web/src/main/js/apps/portfolio/components/RatingFreshness.tsx index 0760429fd12..bb28c4be116 100644 --- a/server/sonar-web/src/main/js/apps/portfolio/components/RatingFreshness.tsx +++ b/server/sonar-web/src/main/js/apps/portfolio/components/RatingFreshness.tsx @@ -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"> </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} /> }} /> diff --git a/server/sonar-web/src/main/js/apps/portfolio/components/ReleasabilityBox.tsx b/server/sonar-web/src/main/js/apps/portfolio/components/ReleasabilityBox.tsx index ff7a2dd2f15..a33d40f9ef1 100644 --- a/server/sonar-web/src/main/js/apps/portfolio/components/ReleasabilityBox.tsx +++ b/server/sonar-web/src/main/js/apps/portfolio/components/ReleasabilityBox.tsx @@ -47,7 +47,7 @@ export default function ReleasabilityBox({ component, measures }: Props) { </Link> )} - <RatingFreshness lastChange={lastReleasabilityChange} /> + <RatingFreshness lastChange={lastReleasabilityChange} rating={rating} /> {effort && Number(effort) > 0 && ( diff --git a/server/sonar-web/src/main/js/apps/portfolio/components/ReliabilityBox.tsx b/server/sonar-web/src/main/js/apps/portfolio/components/ReliabilityBox.tsx index 1875e38e7b3..797f74290e4 100644 --- a/server/sonar-web/src/main/js/apps/portfolio/components/ReliabilityBox.tsx +++ b/server/sonar-web/src/main/js/apps/portfolio/components/ReliabilityBox.tsx @@ -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> diff --git a/server/sonar-web/src/main/js/apps/portfolio/components/SecurityBox.tsx b/server/sonar-web/src/main/js/apps/portfolio/components/SecurityBox.tsx index a80f269ecaa..0cd905f5bb0 100644 --- a/server/sonar-web/src/main/js/apps/portfolio/components/SecurityBox.tsx +++ b/server/sonar-web/src/main/js/apps/portfolio/components/SecurityBox.tsx @@ -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> diff --git a/server/sonar-web/src/main/js/apps/portfolio/components/__tests__/RatingFreshness-test.tsx b/server/sonar-web/src/main/js/apps/portfolio/components/__tests__/RatingFreshness-test.tsx index 627c65c3c1c..a89bb6d1178 100644 --- a/server/sonar-web/src/main/js/apps/portfolio/components/__tests__/RatingFreshness-test.tsx +++ b/server/sonar-web/src/main/js/apps/portfolio/components/__tests__/RatingFreshness-test.tsx @@ -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(); }); diff --git a/server/sonar-web/src/main/js/apps/portfolio/components/__tests__/__snapshots__/MaintainabilityBox-test.tsx.snap b/server/sonar-web/src/main/js/apps/portfolio/components/__tests__/__snapshots__/MaintainabilityBox-test.tsx.snap index 874b02296e2..eaf8d2609a4 100644 --- a/server/sonar-web/src/main/js/apps/portfolio/components/__tests__/__snapshots__/MaintainabilityBox-test.tsx.snap +++ b/server/sonar-web/src/main/js/apps/portfolio/components/__tests__/__snapshots__/MaintainabilityBox-test.tsx.snap @@ -24,6 +24,7 @@ exports[`renders 1`] = ` /> <RatingFreshness lastChange="{\\"date\\":\\"2017-01-02T00:00:00.000Z\\",\\"value\\":2}" + rating="3" /> <Effort component="foo" diff --git a/server/sonar-web/src/main/js/apps/portfolio/components/__tests__/__snapshots__/RatingFreshness-test.tsx.snap b/server/sonar-web/src/main/js/apps/portfolio/components/__tests__/__snapshots__/RatingFreshness-test.tsx.snap index 7e0c44f1ca4..4cb8a857051 100644 --- a/server/sonar-web/src/main/js/apps/portfolio/components/__tests__/__snapshots__/RatingFreshness-test.tsx.snap +++ b/server/sonar-web/src/main/js/apps/portfolio/components/__tests__/__snapshots__/RatingFreshness-test.tsx.snap @@ -25,7 +25,20 @@ 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> `; diff --git a/server/sonar-web/src/main/js/apps/portfolio/components/__tests__/__snapshots__/ReleasabilityBox-test.tsx.snap b/server/sonar-web/src/main/js/apps/portfolio/components/__tests__/__snapshots__/ReleasabilityBox-test.tsx.snap index 2401a4dc09b..9374965500c 100644 --- a/server/sonar-web/src/main/js/apps/portfolio/components/__tests__/__snapshots__/ReleasabilityBox-test.tsx.snap +++ b/server/sonar-web/src/main/js/apps/portfolio/components/__tests__/__snapshots__/ReleasabilityBox-test.tsx.snap @@ -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" diff --git a/server/sonar-web/src/main/js/apps/portfolio/components/__tests__/__snapshots__/ReliabilityBox-test.tsx.snap b/server/sonar-web/src/main/js/apps/portfolio/components/__tests__/__snapshots__/ReliabilityBox-test.tsx.snap index e5b35707fa0..426f6290acd 100644 --- a/server/sonar-web/src/main/js/apps/portfolio/components/__tests__/__snapshots__/ReliabilityBox-test.tsx.snap +++ b/server/sonar-web/src/main/js/apps/portfolio/components/__tests__/__snapshots__/ReliabilityBox-test.tsx.snap @@ -24,6 +24,7 @@ exports[`renders 1`] = ` /> <RatingFreshness lastChange="{\\"date\\":\\"2017-01-02T00:00:00.000Z\\",\\"value\\":2}" + rating="3" /> <Effort component="foo" diff --git a/server/sonar-web/src/main/js/apps/portfolio/components/__tests__/__snapshots__/SecurityBox-test.tsx.snap b/server/sonar-web/src/main/js/apps/portfolio/components/__tests__/__snapshots__/SecurityBox-test.tsx.snap index b2966238d59..3795a1b585f 100644 --- a/server/sonar-web/src/main/js/apps/portfolio/components/__tests__/__snapshots__/SecurityBox-test.tsx.snap +++ b/server/sonar-web/src/main/js/apps/portfolio/components/__tests__/__snapshots__/SecurityBox-test.tsx.snap @@ -24,6 +24,7 @@ exports[`renders 1`] = ` /> <RatingFreshness lastChange="{\\"date\\":\\"2017-01-02T00:00:00.000Z\\",\\"value\\":2}" + rating="3" /> <Effort component="foo" diff --git a/sonar-core/src/main/resources/org/sonar/l10n/core.properties b/sonar-core/src/main/resources/org/sonar/l10n/core.properties index 70ac03a8978..d93850a56e6 100644 --- a/sonar-core/src/main/resources/org/sonar/l10n/core.properties +++ b/sonar-core/src/main/resources/org/sonar/l10n/core.properties @@ -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. |