From: Stas Vilchik Date: Wed, 11 Oct 2017 09:51:05 +0000 (+0200) Subject: SONAR-9847 Add tooltip explaining how to get branch support X-Git-Tag: 6.7-RC1~296 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=11517022de14138e106d1420944f79bb4426b5fa;p=sonarqube.git SONAR-9847 Add tooltip explaining how to get branch support --- diff --git a/server/sonar-web/src/main/js/app/components/nav/component/ComponentNavBranch.tsx b/server/sonar-web/src/main/js/app/components/nav/component/ComponentNavBranch.tsx index 7215a3ab825..334fdfb5e1b 100644 --- a/server/sonar-web/src/main/js/app/components/nav/component/ComponentNavBranch.tsx +++ b/server/sonar-web/src/main/js/app/components/nav/component/ComponentNavBranch.tsx @@ -22,6 +22,7 @@ import * as classNames from 'classnames'; import * as PropTypes from 'prop-types'; import ComponentNavBranchesMenu from './ComponentNavBranchesMenu'; import SingleBranchHelperPopup from './SingleBranchHelperPopup'; +import NoBranchSupportPopup from './NoBranchSupportPopup'; import { Branch, Component } from '../../../types'; import BranchIcon from '../../../../components/icons-components/BranchIcon'; import { isShortLivingBranch } from '../../../../helpers/branches'; @@ -52,7 +53,8 @@ export default class ComponentNavBranch extends React.PureComponent ); + renderNoBranchSupportPopup = () => ( +
+ + + + } + togglePopup={this.toggleNoBranchSupportPopup} + /> +
+ ); + render() { const { branches, currentBranch } = this.props; - if (!this.context.branchesEnabled) { + if (this.context.onSonarCloud && !this.context.branchesEnabled) { return null; } + if (!this.context.branchesEnabled) { + return ( +
+ + {currentBranch.name} + {this.renderNoBranchSupportPopup()} +
+ ); + } + if (branches.length < 2) { return (
diff --git a/server/sonar-web/src/main/js/app/components/nav/component/NoBranchSupportPopup.tsx b/server/sonar-web/src/main/js/app/components/nav/component/NoBranchSupportPopup.tsx new file mode 100644 index 00000000000..70cfb0edb28 --- /dev/null +++ b/server/sonar-web/src/main/js/app/components/nav/component/NoBranchSupportPopup.tsx @@ -0,0 +1,48 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +import * as React from 'react'; +import BubblePopup from '../../../../components/common/BubblePopup'; +import { translate } from '../../../../helpers/l10n'; + +interface Props { + popupPosition?: any; +} + +export default function NoBranchSupportPopup(props: Props) { + return ( + +
+
{translate('branches.no_support.header')}
+

{translate('branches.no_support.header.text')}

+

+ + {translate('branches.learn_more')} + + + {translate('branches.buy_developer_pack')} + +

+
+
+ ); +} diff --git a/server/sonar-web/src/main/js/app/components/nav/component/__tests__/ComponentNavBranch-test.tsx b/server/sonar-web/src/main/js/app/components/nav/component/__tests__/ComponentNavBranch-test.tsx index 8da338c23e1..fc12f64d040 100644 --- a/server/sonar-web/src/main/js/app/components/nav/component/__tests__/ComponentNavBranch-test.tsx +++ b/server/sonar-web/src/main/js/app/components/nav/component/__tests__/ComponentNavBranch-test.tsx @@ -96,7 +96,7 @@ it('renders single branch popup', () => { expect(wrapper.find('BubblePopupHelper').prop('isOpen')).toBe(true); }); -it('renders nothing when no branch support', () => { +it('renders no branch support popup', () => { const branch: MainBranch = { isMain: true, name: 'master' }; const component = {} as Component; const wrapper = shallow( @@ -107,5 +107,18 @@ it('renders nothing when no branch support', () => { />, { context: { branchesEnabled: false } } ); + expect(wrapper).toMatchSnapshot(); + expect(wrapper.find('BubblePopupHelper').prop('isOpen')).toBe(false); + click(wrapper.find('a')); + expect(wrapper.find('BubblePopupHelper').prop('isOpen')).toBe(true); +}); + +it('renders nothing on SonarCloud without branch support', () => { + const branch: MainBranch = { isMain: true, name: 'master' }; + const component = {} as Component; + const wrapper = shallow( + , + { context: { branchesEnabled: false, onSonarCloud: true } } + ); expect(wrapper.type()).toBeNull(); }); diff --git a/server/sonar-web/src/main/js/app/components/nav/component/__tests__/NoBranchSupportPopup-test.tsx b/server/sonar-web/src/main/js/app/components/nav/component/__tests__/NoBranchSupportPopup-test.tsx new file mode 100644 index 00000000000..4f5925156fc --- /dev/null +++ b/server/sonar-web/src/main/js/app/components/nav/component/__tests__/NoBranchSupportPopup-test.tsx @@ -0,0 +1,26 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +import * as React from 'react'; +import { shallow } from 'enzyme'; +import NoBranchSupportPopup from '../NoBranchSupportPopup'; + +it('renders', () => { + expect(shallow()).toMatchSnapshot(); +}); diff --git a/server/sonar-web/src/main/js/app/components/nav/component/__tests__/__snapshots__/ComponentNavBranch-test.tsx.snap b/server/sonar-web/src/main/js/app/components/nav/component/__tests__/__snapshots__/ComponentNavBranch-test.tsx.snap index 1a1f5a3db79..38c20e78b97 100644 --- a/server/sonar-web/src/main/js/app/components/nav/component/__tests__/__snapshots__/ComponentNavBranch-test.tsx.snap +++ b/server/sonar-web/src/main/js/app/components/nav/component/__tests__/__snapshots__/ComponentNavBranch-test.tsx.snap @@ -26,6 +26,47 @@ exports[`renders main branch 1`] = `
`; +exports[`renders no branch support popup 1`] = ` +
+ + + master + +
+ + + + } + position="bottomleft" + togglePopup={[Function]} + /> +
+
+`; + exports[`renders short-living branch 1`] = `
+
+
+ branches.no_support.header +
+

+ branches.no_support.header.text +

+

+ + branches.learn_more + + + branches.buy_developer_pack + +

+
+ +`; 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 0c5adce783d..359bc7632b4 100644 --- a/sonar-core/src/main/resources/org/sonar/l10n/core.properties +++ b/sonar-core/src/main/resources/org/sonar/l10n/core.properties @@ -2577,6 +2577,10 @@ branches.detection_of_long_living_branches=Detection of long living branches branches.detection_of_long_living_branches.description=Regular expression used to detect whether a branch is a long living branch (as opposed to short living branch), based on its name. This applies only during first analysis, the type of a branch cannot be changed later. branches.set_leak_period=Set Leak Period branches.last_analysis_date=Last Analysis Date +branches.no_support.header=Get the most out of SonarQube with branches analysis +branches.no_support.header.text=Analyze each branch of your project separately with our Developer Pack. +branches.learn_more=Learn More +branches.buy_developer_pack=Buy Developer Pack #------------------------------------------------------------------------------