diff options
author | Stas Vilchik <stas.vilchik@sonarsource.com> | 2018-03-27 10:33:05 +0200 |
---|---|---|
committer | SonarTech <sonartech@sonarsource.com> | 2018-03-28 20:20:58 +0200 |
commit | 9bed278a7b11a213a551847b9672cbbab198f59b (patch) | |
tree | 772993ad6e883a4ce65a90bf306c850ccce30030 /server/sonar-web | |
parent | 8b8f07ed8becdef5cf45fc27567ea24cd43e124a (diff) | |
download | sonarqube-9bed278a7b11a213a551847b9672cbbab198f59b.tar.gz sonarqube-9bed278a7b11a213a551847b9672cbbab198f59b.zip |
SONAR-10221 Change message when project main branch is not analyzed (#3164)
Diffstat (limited to 'server/sonar-web')
6 files changed, 124 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<Props> { 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<Props> { return ( <EmptyOverview component={component.key} + hasBranches={branchLikes.length > 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) { <div className="page page-limited"> {showWarning && ( <div className="big-spacer-bottom"> - <div className="alert alert-warning">{translate('provisioning.no_analysis')}</div> - - <div className="big-spacer-top"> - {head} - <Link - className="text-danger" - to={{ pathname: '/project/deletion', query: { id: component } }}> - {translate('provisioning.no_analysis.delete_project')} - </Link> - {tail} + <div className="alert alert-warning"> + {hasBranches ? ( + <FormattedMessage + defaultMessage={translate('provisioning.no_analysis_on_main_branch')} + id="provisioning.no_analysis_on_main_branch" + values={{ + branch: ( + <div className="outline-badge text-baseline little-spacer-right"> + {translate('branches.main_branch')} + </div> + ) + }} + /> + ) : ( + translate('provisioning.no_analysis') + )} </div> + + {!hasBranches && ( + <div className="big-spacer-top"> + {head} + <Link + className="text-danger" + to={{ pathname: '/project/deletion', query: { id: component } }}> + {translate('provisioning.no_analysis.delete_project')} + </Link> + {tail} + </div> + )} </div> )} 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(<App branchLike={branch} component={newComponent} onComponentChange={jest.fn()} />, { - context: { router: { replace } } - }); + mount( + <App + branchLike={branch} + branchLikes={[branch]} + component={newComponent} + onComponentChange={jest.fn()} + />, + { + 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(<App component={component} onComponentChange={jest.fn()} {...props} />); + return shallow( + <App branchLikes={[]} component={component} onComponentChange={jest.fn()} {...props} /> + ); } 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(<EmptyOverview component="abcd" />)).toMatchSnapshot(); + expect(shallow(<EmptyOverview component="abcd" showWarning={true} />)).toMatchSnapshot(); }); it('does not render warning', () => { expect(shallow(<EmptyOverview component="abcd" showWarning={false} />)).toMatchSnapshot(); }); + +it('should render another message when there are branches', () => { + expect( + shallow(<EmptyOverview component="abcd" hasBranches={true} showWarning={true} />) + ).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`] = ` <div className="page page-limited" > + <div + className="big-spacer-bottom" + > + <div + className="alert alert-warning" + > + provisioning.no_analysis + </div> + <div + className="big-spacer-top" + > + <Link + className="text-danger" + onlyActiveOnIndex={false} + style={Object {}} + to={ + Object { + "pathname": "/project/deletion", + "query": Object { + "id": "abcd", + }, + } + } + > + provisioning.no_analysis.delete_project + </Link> + ovisioning.no_analysis.delete + </div> + </div> + <div> + <h4> + key + </h4> + <code> + abcd + </code> + </div> +</div> +`; + +exports[`should render another message when there are branches 1`] = ` +<div + className="page page-limited" +> + <div + className="big-spacer-bottom" + > + <div + className="alert alert-warning" + > + <FormattedMessage + defaultMessage="provisioning.no_analysis_on_main_branch" + id="provisioning.no_analysis_on_main_branch" + values={ + Object { + "branch": <div + className="outline-badge text-baseline little-spacer-right" + > + branches.main_branch + </div>, + } + } + /> + </div> + </div> <div> <h4> key |