From: Pascal Mugnier Date: Wed, 11 Apr 2018 07:06:38 +0000 (+0200) Subject: GOV-265 Application leak header should reflect oldest leak start X-Git-Tag: 7.5~1354 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=de390c4a3cf6a30f11a22bb99726900a42137477;p=sonarqube.git GOV-265 Application leak header should reflect oldest leak start --- diff --git a/server/sonar-web/src/main/js/apps/overview/components/ApplicationLeakPeriodLegend.tsx b/server/sonar-web/src/main/js/apps/overview/components/ApplicationLeakPeriodLegend.tsx index 4ff9c39f670..eb230682fcb 100644 --- a/server/sonar-web/src/main/js/apps/overview/components/ApplicationLeakPeriodLegend.tsx +++ b/server/sonar-web/src/main/js/apps/overview/components/ApplicationLeakPeriodLegend.tsx @@ -18,10 +18,13 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import * as React from 'react'; +import * as classNames from 'classnames'; +import { sortBy } from 'lodash'; import Tooltip from '../../../components/controls/Tooltip'; import DateTooltipFormatter from '../../../components/intl/DateTooltipFormatter'; import { getApplicationLeak } from '../../../api/application'; -import { translate } from '../../../helpers/l10n'; +import { translate, translateWithParameters } from '../../../helpers/l10n'; +import DateFromNow from '../../../components/intl/DateFromNow'; interface Props { component: string; @@ -37,6 +40,7 @@ export default class ApplicationLeakPeriodLegend extends React.Component { if (this.mounted) { - this.setState({ leaks }); + this.setState({ + leaks: sortBy(leaks, value => { + return new Date(value.date); + }) + }); } }, () => { if (this.mounted) { - this.setState({ leaks: [] }); + this.setState({ leaks: undefined }); } } ); @@ -80,10 +88,22 @@ export default class ApplicationLeakPeriodLegend extends React.Component 0 ? this.state.leaks[0] : undefined; return ( - -
- {translate('issues.leak_period')} + +
+ {translate('issues.max_leak_period')}:{' '} + {leak && ( + <> + + {fromNow => {translateWithParameters('overview.started_x', fromNow)}} + +
+ + {translate('from')}:{leak.projectName} + + + )}
); diff --git a/server/sonar-web/src/main/js/apps/overview/components/__tests__/ApplicationLeakPeriodLegend-test.tsx b/server/sonar-web/src/main/js/apps/overview/components/__tests__/ApplicationLeakPeriodLegend-test.tsx index f9c36d4c81c..27a71ac1851 100644 --- a/server/sonar-web/src/main/js/apps/overview/components/__tests__/ApplicationLeakPeriodLegend-test.tsx +++ b/server/sonar-web/src/main/js/apps/overview/components/__tests__/ApplicationLeakPeriodLegend-test.tsx @@ -35,7 +35,6 @@ it('renders', async () => { const wrapper = shallow(); expect(wrapper).toMatchSnapshot(); - wrapper.find('Tooltip').prop('onShow')(); await waitAndUpdate(wrapper); expect(wrapper).toMatchSnapshot(); }); diff --git a/server/sonar-web/src/main/js/apps/overview/components/__tests__/__snapshots__/ApplicationLeakPeriodLegend-test.tsx.snap b/server/sonar-web/src/main/js/apps/overview/components/__tests__/__snapshots__/ApplicationLeakPeriodLegend-test.tsx.snap index f873abb317d..6a5804570eb 100644 --- a/server/sonar-web/src/main/js/apps/overview/components/__tests__/__snapshots__/ApplicationLeakPeriodLegend-test.tsx.snap +++ b/server/sonar-web/src/main/js/apps/overview/components/__tests__/__snapshots__/ApplicationLeakPeriodLegend-test.tsx.snap @@ -2,7 +2,6 @@ exports[`renders 1`] = `
- issues.leak_period + issues.max_leak_period + : +
`; exports[`renders 2`] = `
- issues.leak_period + issues.max_leak_period + : + + + +
+ + from + : + 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 c27b6630b33..70ac03a8978 100644 --- a/sonar-core/src/main/resources/org/sonar/l10n/core.properties +++ b/sonar-core/src/main/resources/org/sonar/l10n/core.properties @@ -618,6 +618,7 @@ issues.to_navigate=to navigate issues.to_navigate_issue_locations=to navigate issue locations issues.to_switch_flows=to switch flows issues.leak_period=Leak Period +issues.max_leak_period=Max Leak Period issues.my_issues=My Issues issues.no_my_issues=There are no issues assigned to you. issues.no_issues=No Issues. Hooray!