/*::
type Props = {
branch?: { name: string },
+ branches: Array<*>,
component: {
analysisDate?: string,
breadcrumbs: Array<{ key: string }>,
}
render() {
- const { branch, component } = this.props;
+ const { branch, branches, component } = this.props;
if (this.isPortfolio() || this.isFile() || isShortLivingBranch(branch)) {
return null;
}
if (!component.analysisDate) {
- return <EmptyOverview component={component} />;
+ return (
+ <EmptyOverview
+ component={component}
+ hasBranches={branches !== undefined && branches.length > 1}
+ />
+ );
}
return (
// @flow
import React from 'react';
import { Link } from 'react-router';
+import { FormattedMessage } from 'react-intl';
import { translate } from '../../../helpers/l10n';
/*::
type Props = {
- component: { key: string }
+ component: { key: string },
+ hasBranches: bool
};
*/
-export default function EmptyOverview({ component } /*: Props */) {
+export default function EmptyOverview({ component, hasBranches } /*: Props */) {
const rawMessage = translate('provisioning.no_analysis.delete');
const head = rawMessage.substr(0, rawMessage.indexOf('{0}'));
const tail = rawMessage.substr(rawMessage.indexOf('{0}') + 3);
return (
<div className="page page-limited">
- <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.key } }}>
- {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.key } }}>
+ {translate('provisioning.no_analysis.delete_project')}
+ </Link>
+ {tail}
+ </div>
+ )}
+
<div className="big-spacer-top">
<h4>{translate('key')}</h4>
<code>{component.key}</code>
import { shallow } from 'enzyme';
import EmptyOverview from '../EmptyOverview';
+const component = {
+ id: 'id',
+ key: 'abcd',
+ analysisDate: '2016-01-01'
+};
+
it('should render component key', () => {
- const component = {
- id: 'id',
- key: 'abcd',
- analysisDate: '2016-01-01'
- };
const output = shallow(<EmptyOverview component={component} />);
expect(output.find('code').text()).toBe('abcd');
});
+
+it('should render another message when there are branches', () => {
+ const wrapper = shallow(<EmptyOverview component={component} hasBranches={true} />);
+ expect(wrapper).toMatchSnapshot();
+});
--- /dev/null
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`should render another message when there are branches 1`] = `
+<div
+ className="page page-limited"
+>
+ <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
+ className="big-spacer-top"
+ >
+ <h4>
+ key
+ </h4>
+ <code>
+ abcd
+ </code>
+ </div>
+</div>
+`;