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';
};
static contextTypes = {
- branchesEnabled: PropTypes.bool.isRequired
+ branchesEnabled: PropTypes.bool.isRequired,
+ onSonarCloud: PropTypes.bool
};
componentDidMount() {
</div>
);
+ renderNoBranchSupportPopup = () => (
+ <div className="display-inline-block spacer-left">
+ <a className="link-no-underline" href="#" onClick={this.handleNoBranchSupportClick}>
+ <HelpIcon fill="#cdcdcd" />
+ </a>
+ <BubblePopupHelper
+ isOpen={this.state.noBranchSupportPopupOpen}
+ position="bottomleft"
+ popup={<NoBranchSupportPopup />}
+ togglePopup={this.toggleNoBranchSupportPopup}
+ />
+ </div>
+ );
+
render() {
const { branches, currentBranch } = this.props;
- if (!this.context.branchesEnabled) {
+ if (this.context.onSonarCloud && !this.context.branchesEnabled) {
return null;
}
+ if (!this.context.branchesEnabled) {
+ return (
+ <div className="navbar-context-branches">
+ <BranchIcon branch={currentBranch} className="little-spacer-right" color="#cdcdcd" />
+ <span className="note">{currentBranch.name}</span>
+ {this.renderNoBranchSupportPopup()}
+ </div>
+ );
+ }
+
if (branches.length < 2) {
return (
<div className="navbar-context-branches">
--- /dev/null
+/*
+ * 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 (
+ <BubblePopup position={props.popupPosition} customClass="bubble-popup-bottom">
+ <div className="abs-width-400">
+ <h6 className="spacer-bottom">{translate('branches.no_support.header')}</h6>
+ <p className="big-spacer-bottom markdown">{translate('branches.no_support.header.text')}</p>
+ <p>
+ <a href="https://redirect.sonarsource.com/doc/branches.html" target="_blank">
+ {translate('branches.learn_more')}
+ </a>
+ <a
+ className="button spacer-left"
+ href="https://www.sonarsource.com/company/contact/"
+ target="_blank">
+ {translate('branches.buy_developer_pack')}
+ </a>
+ </p>
+ </div>
+ </BubblePopup>
+ );
+}
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(
/>,
{ 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(
+ <ComponentNavBranch branches={[branch]} component={component} currentBranch={branch} />,
+ { context: { branchesEnabled: false, onSonarCloud: true } }
+ );
expect(wrapper.type()).toBeNull();
});
--- /dev/null
+/*
+ * 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(<NoBranchSupportPopup />)).toMatchSnapshot();
+});
</div>
`;
+exports[`renders no branch support popup 1`] = `
+<div
+ className="navbar-context-branches"
+>
+ <BranchIcon
+ branch={
+ Object {
+ "isMain": true,
+ "name": "master",
+ }
+ }
+ className="little-spacer-right"
+ color="#cdcdcd"
+ />
+ <span
+ className="note"
+ >
+ master
+ </span>
+ <div
+ className="display-inline-block spacer-left"
+ >
+ <a
+ className="link-no-underline"
+ href="#"
+ onClick={[Function]}
+ >
+ <HelpIcon
+ fill="#cdcdcd"
+ />
+ </a>
+ <BubblePopupHelper
+ isOpen={false}
+ popup={<NoBranchSupportPopup />}
+ position="bottomleft"
+ togglePopup={[Function]}
+ />
+ </div>
+</div>
+`;
+
exports[`renders short-living branch 1`] = `
<div
className="navbar-context-branches dropdown"
--- /dev/null
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`renders 1`] = `
+<BubblePopup
+ customClass="bubble-popup-bottom"
+>
+ <div
+ className="abs-width-400"
+ >
+ <h6
+ className="spacer-bottom"
+ >
+ branches.no_support.header
+ </h6>
+ <p
+ className="big-spacer-bottom markdown"
+ >
+ branches.no_support.header.text
+ </p>
+ <p>
+ <a
+ href="https://redirect.sonarsource.com/doc/branches.html"
+ target="_blank"
+ >
+ branches.learn_more
+ </a>
+ <a
+ className="button spacer-left"
+ href="https://www.sonarsource.com/company/contact/"
+ target="_blank"
+ >
+ branches.buy_developer_pack
+ </a>
+ </p>
+ </div>
+</BubblePopup>
+`;
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
#------------------------------------------------------------------------------