From: Pascal Mugnier Date: Wed, 11 Apr 2018 12:32:57 +0000 (+0200) Subject: GOV-288 Portfolio containing only provisioned projects is not 'empty' X-Git-Tag: 7.5~1351 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=b9d7623d0ce7d804f0c5a6dcfc476ae96c9b8518;p=sonarqube.git GOV-288 Portfolio containing only provisioned projects is not 'empty' --- diff --git a/server/sonar-web/src/main/js/apps/issues/components/App.tsx b/server/sonar-web/src/main/js/apps/issues/components/App.tsx index 37e354aca8d..a433057b301 100644 --- a/server/sonar-web/src/main/js/apps/issues/components/App.tsx +++ b/server/sonar-web/src/main/js/apps/issues/components/App.tsx @@ -67,6 +67,7 @@ import { import { translate, translateWithParameters } from '../../../helpers/l10n'; import { RawQuery } from '../../../helpers/query'; import { scrollToElement } from '../../../helpers/scrolling'; +import EmptySearch from '../../../components/common/EmptySearch'; import Checkbox from '../../../components/controls/Checkbox'; import '../styles.css'; @@ -926,6 +927,17 @@ export default class App extends React.PureComponent { return null; } + let noIssuesMessage = null; + if (paging.total === 0) { + if (this.isFiltered()) { + noIssuesMessage = ; + } else if (this.state.myIssues) { + noIssuesMessage = ; + } else { + noIssuesMessage = ; + } + } + return (
{paging.total > 0 && ( @@ -949,8 +961,7 @@ export default class App extends React.PureComponent { )} - {paging.total === 0 && - (this.state.myIssues && !this.isFiltered() ? : )} + {noIssuesMessage}
); } diff --git a/server/sonar-web/src/main/js/apps/overview/components/OverviewApp.tsx b/server/sonar-web/src/main/js/apps/overview/components/OverviewApp.tsx index 4a0fce06905..f1860ce427e 100644 --- a/server/sonar-web/src/main/js/apps/overview/components/OverviewApp.tsx +++ b/server/sonar-web/src/main/js/apps/overview/components/OverviewApp.tsx @@ -45,6 +45,7 @@ import { isSameBranchLike, getBranchLikeQuery } from '../../../helpers/branches' import { fetchMetrics } from '../../../store/rootActions'; import { getMetrics } from '../../../store/rootReducer'; import { BranchLike, Component, Metric } from '../../../app/types'; +import { translate } from '../../../helpers/l10n'; import '../styles.css'; interface OwnProps { @@ -158,6 +159,10 @@ export class OverviewApp extends React.PureComponent { ? { index: 1 } : undefined; + isEmpty = () => + this.state.measures === undefined || + this.state.measures.find(measure => measure.metric.key === 'ncloc') === undefined; + renderLoading() { return (
@@ -166,14 +171,22 @@ export class OverviewApp extends React.PureComponent { ); } - render() { - const { branchLike, component } = this.props; - const { loading, measures, periods, history, historyStartDate } = this.state; - - if (loading) { - return this.renderLoading(); - } + renderEmpty() { + return ( +
+

+ {!this.state.measures || + !this.state.measures.find(measure => measure.metric.key === 'projects') + ? translate('portfolio.app.empty') + : translate('portfolio.app.no_lines_of_code')} +

+
+ ); + } + renderMain() { + const { branchLike, component } = this.props; + const { periods, measures, history, historyStartDate } = this.state; const leakPeriod = component.qualifier === 'APP' ? this.getApplicationLeakPeriod() : getLeakPeriod(periods); const domainProps = { @@ -185,23 +198,40 @@ export class OverviewApp extends React.PureComponent { historyStartDate }; + if (this.isEmpty()) { + return this.renderEmpty(); + } + + return ( +
+ {component.qualifier === 'APP' ? ( + + ) : ( + + )} + +
+ + + + +
+
+ ); + } + + render() { + const { branchLike, component } = this.props; + const { loading, measures, history } = this.state; + + if (loading) { + return this.renderLoading(); + } + return (
-
- {component.qualifier === 'APP' ? ( - - ) : ( - - )} - -
- - - - -
-
+ {this.renderMain()}
{ - renderLoC = (ncloc: MeasureEnhanced) => ( + renderLoC = (ncloc?: MeasureEnhanced) => (
- - - - - {formatMeasure(ncloc.value, 'SHORT_INT')} - + })} + id="overview-ncloc"> + {ncloc && ( + + + + )} + {ncloc ? ( + + {formatMeasure(ncloc.value, 'SHORT_INT')} + + ) : ( + 0 + )}
{getMetricName('ncloc')}
); @@ -70,24 +76,27 @@ export default class MetaSize extends React.PureComponent { renderProjects = () => { const projects = this.props.measures.find(measure => measure.metric.key === 'projects'); - - return projects ? ( -
- - {formatMeasure(projects.value, 'SHORT_INT')} - + return ( +
+ {projects ? ( + + {formatMeasure(projects.value, 'SHORT_INT')} + + ) : ( + 0 + )}
{translate('metric.projects.name')}
- ) : null; + ); }; render() { const ncloc = this.props.measures.find(measure => measure.metric.key === 'ncloc'); - if (ncloc == null) { + if (ncloc == null && this.props.component.qualifier !== 'APP') { return null; } diff --git a/server/sonar-web/src/main/js/apps/overview/styles.css b/server/sonar-web/src/main/js/apps/overview/styles.css index 5b556ae3a88..ac492720ff5 100644 --- a/server/sonar-web/src/main/js/apps/overview/styles.css +++ b/server/sonar-web/src/main/js/apps/overview/styles.css @@ -363,7 +363,8 @@ box-sizing: border-box; } -.overview-meta-size-ncloc a { +.overview-meta-size-ncloc a, +.overview-meta-size-ncloc span { line-height: var(--controlHeight); font-size: 18px; font-weight: 300; diff --git a/server/sonar-web/src/main/js/apps/portfolio/components/App.tsx b/server/sonar-web/src/main/js/apps/portfolio/components/App.tsx index ab35a37e8ae..188130d59e1 100644 --- a/server/sonar-web/src/main/js/apps/portfolio/components/App.tsx +++ b/server/sonar-web/src/main/js/apps/portfolio/components/App.tsx @@ -123,8 +123,11 @@ export class App extends React.PureComponent { renderEmpty() { return (
-

{translate('portfolio.empty')}

-

{translate('portfolio.empty.hint')}

+

+ {!this.state.measures || !this.state.measures['projects'] + ? translate('portfolio.empty') + : translate('portfolio.no_lines_of_code')} +

); } @@ -188,8 +191,7 @@ export class App extends React.PureComponent {

{translate('overview.about_this_portfolio')}

- {!this.isEmpty() && - !this.isNotComputed() && } +
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 bb28c4be116..13c37926c03 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 @@ -33,9 +33,11 @@ export default function RatingFreshness({ lastChange, rating }: Props) { return (
{rating && ( - <> - {translate('portfolio.has_always_been')} - + }} + /> )}
); diff --git a/server/sonar-web/src/main/js/apps/portfolio/components/Summary.tsx b/server/sonar-web/src/main/js/apps/portfolio/components/Summary.tsx index b32e4cda434..7d438b6167f 100644 --- a/server/sonar-web/src/main/js/apps/portfolio/components/Summary.tsx +++ b/server/sonar-web/src/main/js/apps/portfolio/components/Summary.tsx @@ -40,17 +40,25 @@ export default function Summary({ component, measures }: Props) {
  • - - - + {projects ? ( + + + + ) : ( + '0' + )}
    {translate('projects')}
  • - - - + {ncloc ? ( + + + + ) : ( + '0' + )}
    {translate('metric.ncloc.name')}
  • diff --git a/server/sonar-web/src/main/js/apps/portfolio/components/__tests__/__snapshots__/App-test.tsx.snap b/server/sonar-web/src/main/js/apps/portfolio/components/__tests__/__snapshots__/App-test.tsx.snap index 4a89b29c509..bee7a5e17b9 100644 --- a/server/sonar-web/src/main/js/apps/portfolio/components/__tests__/__snapshots__/App-test.tsx.snap +++ b/server/sonar-web/src/main/js/apps/portfolio/components/__tests__/__snapshots__/App-test.tsx.snap @@ -127,9 +127,6 @@ exports[`renders when portfolio is empty 1`] = `

    portfolio.empty

    -

    - portfolio.empty.hint -

overview.about_this_portfolio +
- - portfolio.has_always_been - - - + , + } + } + />
`; 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 d93850a56e6..4de16e024be 100644 --- a/sonar-core/src/main/resources/org/sonar/l10n/core.properties +++ b/sonar-core/src/main/resources/org/sonar/l10n/core.properties @@ -2678,12 +2678,14 @@ branches.see_the_pr=See the PR # PORTFOLIOS # #------------------------------------------------------------------------------ -portfolio.has_always_been=has always been +portfolio.has_always_been_x=has always been {rating} portfolio.was_x_y=was {rating} {date} portfolio.x_in_y={projects} in {rating} portfolio.empty=This portfolio is empty. -portfolio.empty.hint=This portfolio has no projects, or none of associated projects has lines of code. +portfolio.no_lines_of_code=All projects in this portfolio are empty portfolio.not_computed=This portfolio is not yet computed. +portfolio.app.empty=This application is empty. +portfolio.app.no_lines_of_code=All projects in this application are empty #------------------------------------------------------------------------------