From 9bed278a7b11a213a551847b9672cbbab198f59b Mon Sep 17 00:00:00 2001 From: Stas Vilchik Date: Tue, 27 Mar 2018 10:33:05 +0200 Subject: [PATCH] SONAR-10221 Change message when project main branch is not analyzed (#3164) --- .../src/main/js/app/styles/init/type.css | 4 ++ .../main/js/apps/overview/components/App.tsx | 4 +- .../overview/components/EmptyOverview.tsx | 42 ++++++++---- .../components/__tests__/App-test.tsx | 18 +++-- .../__tests__/EmptyOverview-test.tsx | 8 ++- .../__snapshots__/EmptyOverview-test.tsx.snap | 65 +++++++++++++++++++ .../resources/org/sonar/l10n/core.properties | 1 + 7 files changed, 125 insertions(+), 17 deletions(-) diff --git a/server/sonar-web/src/main/js/app/styles/init/type.css b/server/sonar-web/src/main/js/app/styles/init/type.css index 943ee5497a8..f0c235042ca 100644 --- a/server/sonar-web/src/main/js/app/styles/init/type.css +++ b/server/sonar-web/src/main/js/app/styles/init/type.css @@ -211,6 +211,10 @@ small, vertical-align: text-bottom !important; } +.text-baseline { + vertical-align: baseline !important; +} + .text-ellipsis { overflow: hidden; text-overflow: ellipsis; diff --git a/server/sonar-web/src/main/js/apps/overview/components/App.tsx b/server/sonar-web/src/main/js/apps/overview/components/App.tsx index 0d7caeb5d3e..d54ea53f10b 100644 --- a/server/sonar-web/src/main/js/apps/overview/components/App.tsx +++ b/server/sonar-web/src/main/js/apps/overview/components/App.tsx @@ -27,6 +27,7 @@ import { getShortLivingBranchUrl, getCodeUrl } from '../../../helpers/urls'; interface Props { branchLike?: BranchLike; + branchLikes: BranchLike[]; component: Component; isInProgress?: boolean; isPending?: boolean; @@ -60,7 +61,7 @@ export default class App extends React.PureComponent { isFile = () => ['FIL', 'UTS'].includes(this.props.component.qualifier); render() { - const { branchLike, component } = this.props; + const { branchLike, branchLikes, component } = this.props; if (this.isPortfolio() || this.isFile() || isShortLivingBranch(branchLike)) { return null; @@ -70,6 +71,7 @@ export default class App extends React.PureComponent { return ( 1} showWarning={!this.props.isPending && !this.props.isInProgress} /> ); diff --git a/server/sonar-web/src/main/js/apps/overview/components/EmptyOverview.tsx b/server/sonar-web/src/main/js/apps/overview/components/EmptyOverview.tsx index 0dd1b07cb15..9beed6e65b5 100644 --- a/server/sonar-web/src/main/js/apps/overview/components/EmptyOverview.tsx +++ b/server/sonar-web/src/main/js/apps/overview/components/EmptyOverview.tsx @@ -19,14 +19,16 @@ */ import * as React from 'react'; import { Link } from 'react-router'; +import { FormattedMessage } from 'react-intl'; import { translate } from '../../../helpers/l10n'; interface Props { component: string; + hasBranches?: boolean; showWarning?: boolean; } -export default function EmptyOverview({ component, showWarning }: Props) { +export default function EmptyOverview({ component, hasBranches, showWarning }: Props) { const rawMessage = translate('provisioning.no_analysis.delete'); const head = rawMessage.substr(0, rawMessage.indexOf('{0}')); const tail = rawMessage.substr(rawMessage.indexOf('{0}') + 3); @@ -35,17 +37,35 @@ export default function EmptyOverview({ component, showWarning }: Props) {
{showWarning && (
-
{translate('provisioning.no_analysis')}
- -
- {head} - - {translate('provisioning.no_analysis.delete_project')} - - {tail} +
+ {hasBranches ? ( + + {translate('branches.main_branch')} +
+ ) + }} + /> + ) : ( + translate('provisioning.no_analysis') + )}
+ + {!hasBranches && ( +
+ {head} + + {translate('provisioning.no_analysis.delete_project')} + + {tail} +
+ )}
)} diff --git a/server/sonar-web/src/main/js/apps/overview/components/__tests__/App-test.tsx b/server/sonar-web/src/main/js/apps/overview/components/__tests__/App-test.tsx index f3eb8d43cba..ac84c986293 100644 --- a/server/sonar-web/src/main/js/apps/overview/components/__tests__/App-test.tsx +++ b/server/sonar-web/src/main/js/apps/overview/components/__tests__/App-test.tsx @@ -54,9 +54,17 @@ it('redirects on Code page for files', () => { qualifier: 'FIL' }; const replace = jest.fn(); - mount(, { - context: { router: { replace } } - }); + mount( + , + { + context: { router: { replace } } + } + ); expect(replace).toBeCalledWith({ pathname: '/code', query: { branch: 'b', id: 'project', selected: 'foo' } @@ -64,5 +72,7 @@ it('redirects on Code page for files', () => { }); function getWrapper(props = {}) { - return shallow(); + return shallow( + + ); } diff --git a/server/sonar-web/src/main/js/apps/overview/components/__tests__/EmptyOverview-test.tsx b/server/sonar-web/src/main/js/apps/overview/components/__tests__/EmptyOverview-test.tsx index eeee97a8970..c2468df3638 100644 --- a/server/sonar-web/src/main/js/apps/overview/components/__tests__/EmptyOverview-test.tsx +++ b/server/sonar-web/src/main/js/apps/overview/components/__tests__/EmptyOverview-test.tsx @@ -22,9 +22,15 @@ import { shallow } from 'enzyme'; import EmptyOverview from '../EmptyOverview'; it('renders', () => { - expect(shallow()).toMatchSnapshot(); + expect(shallow()).toMatchSnapshot(); }); it('does not render warning', () => { expect(shallow()).toMatchSnapshot(); }); + +it('should render another message when there are branches', () => { + expect( + shallow() + ).toMatchSnapshot(); +}); diff --git a/server/sonar-web/src/main/js/apps/overview/components/__tests__/__snapshots__/EmptyOverview-test.tsx.snap b/server/sonar-web/src/main/js/apps/overview/components/__tests__/__snapshots__/EmptyOverview-test.tsx.snap index 824034aef44..4d8cdf63248 100644 --- a/server/sonar-web/src/main/js/apps/overview/components/__tests__/__snapshots__/EmptyOverview-test.tsx.snap +++ b/server/sonar-web/src/main/js/apps/overview/components/__tests__/__snapshots__/EmptyOverview-test.tsx.snap @@ -19,6 +19,71 @@ exports[`renders 1`] = `
+
+
+ provisioning.no_analysis +
+
+ + provisioning.no_analysis.delete_project + + ovisioning.no_analysis.delete +
+
+
+

+ key +

+ + abcd + +
+
+`; + +exports[`should render another message when there are branches 1`] = ` +
+
+
+ + branches.main_branch +
, + } + } + /> +
+

key 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 397cb2e3bd7..4aae3967b8f 100644 --- a/sonar-core/src/main/resources/org/sonar/l10n/core.properties +++ b/sonar-core/src/main/resources/org/sonar/l10n/core.properties @@ -1443,6 +1443,7 @@ provisioning.no_analysis.delete=Either you should retry analysis or simply {0}. provisioning.no_analysis.delete_project=delete the project provisioning.only_provisioned=Only Provisioned provisioning.only_provisioned.tooltip=Provisioned projects are projects that have been created, but have not been analyzed yet. +provisioning.no_analysis_on_main_branch={branch} has not been analyzed yet. #------------------------------------------------------------------------------ -- 2.39.5