vertical-align: text-bottom !important;
}
+.text-baseline {
+ vertical-align: baseline !important;
+}
+
.text-ellipsis {
overflow: hidden;
text-overflow: ellipsis;
interface Props {
branchLike?: BranchLike;
+ branchLikes: BranchLike[];
component: Component;
isInProgress?: boolean;
isPending?: boolean;
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;
return (
<EmptyOverview
component={component.key}
+ hasBranches={branchLikes.length > 1}
showWarning={!this.props.isPending && !this.props.isInProgress}
/>
);
*/
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);
<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>
)}
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' }
});
function getWrapper(props = {}) {
- return shallow(<App component={component} onComponentChange={jest.fn()} {...props} />);
+ return shallow(
+ <App branchLikes={[]} component={component} onComponentChange={jest.fn()} {...props} />
+ );
}
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();
+});
<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
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.
#------------------------------------------------------------------------------