]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-10221 Change message when project main branch is not analyzed (#3164)
authorStas Vilchik <stas.vilchik@sonarsource.com>
Tue, 27 Mar 2018 08:33:05 +0000 (10:33 +0200)
committerSonarTech <sonartech@sonarsource.com>
Wed, 28 Mar 2018 18:20:58 +0000 (20:20 +0200)
server/sonar-web/src/main/js/app/styles/init/type.css
server/sonar-web/src/main/js/apps/overview/components/App.tsx
server/sonar-web/src/main/js/apps/overview/components/EmptyOverview.tsx
server/sonar-web/src/main/js/apps/overview/components/__tests__/App-test.tsx
server/sonar-web/src/main/js/apps/overview/components/__tests__/EmptyOverview-test.tsx
server/sonar-web/src/main/js/apps/overview/components/__tests__/__snapshots__/EmptyOverview-test.tsx.snap
sonar-core/src/main/resources/org/sonar/l10n/core.properties

index 943ee5497a819ff063062e949a1cc53bb0b875c3..f0c235042ca333b7e719d2d950dfacd0f1027d79 100644 (file)
@@ -211,6 +211,10 @@ small,
   vertical-align: text-bottom !important;
 }
 
+.text-baseline {
+  vertical-align: baseline !important;
+}
+
 .text-ellipsis {
   overflow: hidden;
   text-overflow: ellipsis;
index 0d7caeb5d3e565fc09ba1da5f95747f694aff9e5..d54ea53f10b8dee490b0afd90b062b432778687a 100644 (file)
@@ -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}
         />
       );
index 0dd1b07cb1539ef1a8100646d12fc2dba0fb6a93..9beed6e65b5cea94e3874e9d3e8ba5fb6bd68007 100644 (file)
  */
 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>
       )}
 
index f3eb8d43cba2966460bb9ae147471da2266872ee..ac84c986293060133297f1ebd7a53e3473b89fd1 100644 (file)
@@ -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} />
+  );
 }
index eeee97a89700f61f2d2e1e37e1413ad51a17063b..c2468df363814e06683587c7beaee567e0aad2df 100644 (file)
@@ -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();
+});
index 824034aef44f04f4b458bbe576fbf59d6248c075..4d8cdf632481b617b83fb619a10c135f4a59abf6 100644 (file)
@@ -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
index 397cb2e3bd75b60ffae69aff6f1b1554a6875afe..4aae3967b8f16c7e15840059a8a16221d29f41bf 100644 (file)
@@ -1443,6 +1443,7 @@ provisioning.no_analysis.delete=Either you should retry analysis or simply {0}.
 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.
 
 
 #------------------------------------------------------------------------------