]> 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)
committerGitHub <noreply@github.com>
Tue, 27 Mar 2018 08:33:05 +0000 (10:33 +0200)
server/sonar-web/src/main/js/apps/overview/components/App.js
server/sonar-web/src/main/js/apps/overview/components/EmptyOverview.js
server/sonar-web/src/main/js/apps/overview/components/__tests__/EmptyOverview-test.js
server/sonar-web/src/main/js/apps/overview/components/__tests__/__snapshots__/EmptyOverview-test.js.snap [new file with mode: 0644]
server/sonar-web/src/main/less/init/type.less
sonar-core/src/main/resources/org/sonar/l10n/core.properties

index 8ce26596388cf203f209919570122038b2b86be0..29235f1ed7603cde5d0e5778f461ff9cdf8696d7 100644 (file)
@@ -28,6 +28,7 @@ import { getProjectBranchUrl, getCodeUrl } from '../../../helpers/urls';
 /*::
 type Props = {
   branch?: { name: string },
+  branches: Array<*>,
   component: {
     analysisDate?: string,
     breadcrumbs: Array<{ key: string }>,
@@ -75,14 +76,19 @@ export default class App extends React.PureComponent {
   }
 
   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 (
index f89d83cf4808ddaf6100ef7d12692805062c8651..a3bf2cd7872b42ffab29b39d12da552d036636e8 100644 (file)
 // @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>
index f163dc8a96977166aadb4e408d50c21d06d5e8c0..9c959e11246f95c145f332d590c505af172fb8fb 100644 (file)
@@ -21,12 +21,18 @@ import React from 'react';
 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();
+});
diff --git a/server/sonar-web/src/main/js/apps/overview/components/__tests__/__snapshots__/EmptyOverview-test.js.snap b/server/sonar-web/src/main/js/apps/overview/components/__tests__/__snapshots__/EmptyOverview-test.js.snap
new file mode 100644 (file)
index 0000000..d4eb72e
--- /dev/null
@@ -0,0 +1,35 @@
+// 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>
+`;
index 643a52789a9047b531d281b65ab473384b12e2aa..ac022e64f7c7411971293dd52efb1e5afaaa3bbb 100644 (file)
@@ -161,6 +161,9 @@ small,
 .text-text-bottom {
   vertical-align: text-bottom !important;
 }
+.text-baseline {
+  vertical-align: baseline !important;
+}
 
 // Overflow
 
index b70c333d50899cc39f136793bcf0cbbdca743c33..2ee56009dfaa9b10f619f87a15adcec9f8566c46 100644 (file)
@@ -1396,6 +1396,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.
 
 
 #------------------------------------------------------------------------------