]> source.dussan.org Git - sonarqube.git/commitdiff
apply feedback on profiles page
authorStas Vilchik <vilchiks@gmail.com>
Fri, 15 Jul 2016 12:01:13 +0000 (14:01 +0200)
committerStas Vilchik <vilchiks@gmail.com>
Fri, 15 Jul 2016 12:17:38 +0000 (14:17 +0200)
server/sonar-web/src/main/js/apps/overview/meta/MetaQualityProfiles.js
server/sonar-web/src/main/js/apps/overview/styles.css
server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileRules.js
server/sonar-web/src/main/js/apps/quality-profiles/home/EvolutionDeprecated.js
server/sonar-web/src/main/js/apps/quality-profiles/home/EvolutionRules.js
server/sonar-web/src/main/js/apps/quality-profiles/styles.css
sonar-core/src/main/resources/org/sonar/l10n/core.properties

index b72a1d9607897f760bb9f38de15b9dc25540769f..1fc958a58b80a46409fc4e95f0ef22367ff402d8 100644 (file)
@@ -20,9 +20,8 @@
 import React from 'react';
 import { TooltipsContainer } from '../../../components/mixins/tooltips-mixin';
 import { translate, translateWithParameters } from '../../../helpers/l10n';
-import { getQualityProfileUrl } from '../../../helpers/urls';
+import { getQualityProfileUrl, getRulesUrl } from '../../../helpers/urls';
 import { searchRules } from '../../../api/rules';
-import { getRulesUrl } from '../../../helpers/urls';
 
 export default class MetaQualityProfiles extends React.Component {
   state = {
@@ -64,6 +63,11 @@ export default class MetaQualityProfiles extends React.Component {
     return searchRules(data).then(r => r.total);
   }
 
+  getDeprecatedRulesCount (profile) {
+    const count = this.state.deprecatedByKey[profile.key];
+    return count || 0;
+  }
+
   renderDeprecated (profile) {
     const count = this.state.deprecatedByKey[profile.key];
     if (!count) {
@@ -84,9 +88,50 @@ export default class MetaQualityProfiles extends React.Component {
     );
   }
 
+  renderProfile (profile) {
+    const inner = (
+        <div>
+          <span className="note spacer-right">
+            {'(' + profile.language + ')'}
+          </span>
+          <a href={getQualityProfileUrl(profile.key)}>
+            {profile.name}
+          </a>
+        </div>
+    );
+
+    const count = this.getDeprecatedRulesCount(profile);
+
+    if (count > 0) {
+      const tooltip =
+          translateWithParameters('overview.deprecated_profile', count);
+      return (
+          <li key={profile.key}
+              className="overview-deprecated-rules"
+              title={tooltip}
+              data-toggle="tooltip">
+            {inner}
+          </li>
+      );
+    }
+
+    return (
+        <li key={profile.key}>
+          {inner}
+        </li>
+    );
+  }
+
   render () {
     const { profiles } = this.props;
 
+    const deprecatedStyles = {
+      padding: '3px 6px',
+      border: '1px solid #ebccd1',
+      borderRadius: '3px',
+      backgroundColor: '#f2dede'
+    };
+
     return (
         <TooltipsContainer>
           <div>
@@ -95,17 +140,7 @@ export default class MetaQualityProfiles extends React.Component {
             </h4>
 
             <ul className="overview-meta-list">
-              {profiles.map(profile => (
-                  <li key={profile.key}>
-                    {this.renderDeprecated(profile)}
-                    <span className="note spacer-right">
-                      {'(' + profile.language + ')'}
-                    </span>
-                    <a href={getQualityProfileUrl(profile.key)}>
-                      {profile.name}
-                    </a>
-                  </li>
-              ))}
+              {profiles.map(profile => this.renderProfile(profile))}
             </ul>
           </div>
         </TooltipsContainer>
index eaeed145c22a3c883713554e76c227e3d75e1a79..2c920297fb1fd89c03bd269752ce7f2ef2c9da80 100644 (file)
   background-color: transparent !important;
 }
 
+.overview-deprecated-rules {
+  margin: 4px -6px 4px;
+  padding: 3px 6px;
+  border: 1px solid #ebccd1;
+  border-radius: 3px;
+  background-color: #f2dede;
+}
+
 /*
  * Animations
  */
index 02279d92572be2bcbb244d21d19eb9e2347f8328..fd6e98d6f7201391f058e9110fbf56834cee5df9 100644 (file)
@@ -21,7 +21,6 @@ import React from 'react';
 import keyBy from 'lodash/keyBy';
 import ProfileRulesRow from './ProfileRulesRow';
 import { ProfileType } from '../propTypes';
-import { TooltipsContainer } from '../../../components/mixins/tooltips-mixin';
 import { searchRules, takeFacet } from '../../../api/rules';
 import { translate, translateWithParameters } from '../../../helpers/l10n';
 import { formatMeasure } from '../../../helpers/measures';
index 6d26699393a88dce5314db454828c5ceda5216a8..8239e571ca6141b69b068e2d14fee78bf82e5570 100644 (file)
@@ -37,10 +37,6 @@ export default class EvolutionDeprecated extends React.Component {
       return null;
     }
 
-    const totalRules = profilesWithDeprecations
-        .map(p => p.activeDeprecatedRuleCount)
-        .reduce((p, c) => p + c, 0);
-
     const sortedProfiles =
         sortBy(profilesWithDeprecations, p => -p.activeDeprecatedRuleCount);
 
@@ -52,8 +48,7 @@ export default class EvolutionDeprecated extends React.Component {
           </div>
           <div className="spacer-bottom">
             {translateWithParameters(
-                'quality_profiles.x_deprecated_rules_are_still_activated',
-                totalRules,
+                'quality_profiles.deprecated_rules_are_still_activated',
                 profilesWithDeprecations.length
             )}
           </div>
index 213f8877c51b83773c5b2e62f578d03d83618de2..8d31c3e16c9c073f4ec6ef71641f66892082b2b2 100644 (file)
@@ -23,10 +23,11 @@ import sortBy from 'lodash/sortBy';
 import { searchRules } from '../../../api/rules';
 import { translateWithParameters, translate } from '../../../helpers/l10n';
 import { getRulesUrl } from '../../../helpers/urls';
+import { formatMeasure } from '../../../helpers/measures';
 
-const RULES_LIMIT = 3;
+const RULES_LIMIT = 10;
 
-const PERIOD_START_MOMENT = moment().subtract(1, 'month');
+const PERIOD_START_MOMENT = moment().subtract(1, 'year');
 
 function parseRules (r) {
   const { rules, actives } = r;
@@ -82,13 +83,6 @@ export default class EvolutionRules extends React.Component {
             <strong className="pull-left">
               {translate('quality_profiles.latest_new_rules')}
             </strong>
-
-            {this.state.latestRulesTotal > RULES_LIMIT && (
-                <a className="pull-right small text-muted"
-                   href={newRulesUrl}>
-                  {translate('see_all')}
-                </a>
-            )}
           </div>
           <ul>
             {this.state.latestRules.map(rule => (
@@ -117,6 +111,16 @@ export default class EvolutionRules extends React.Component {
                 </li>
             ))}
           </ul>
+          {this.state.latestRulesTotal > RULES_LIMIT && (
+              <div className="spacer-top">
+                <a className="small"
+                   href={newRulesUrl}>
+                  {translate('see_all')}
+                  {' '}
+                  {formatMeasure(this.state.latestRulesTotal, 'SHORT_INT')}
+                </a>
+              </div>
+          )}
         </div>
     );
   }
index 5d97a57c5247c09d9cc6f675075457f219ca3e89..42c96abf9a89fc6842858d9d7c98b0f797f0ca68 100644 (file)
@@ -77,8 +77,7 @@
 
 .quality-profile-rules-deprecated {
   padding: 15px 20px;
-  border-top: 1px solid #e6e6e6;
-  background-color: #fcf8e3;
+  background-color: #f2dede;
 }
 
 .quality-profile-exporters {
index 824ffab50786a9590cdd4f60b3d4700de7577a82..8ff19c3be41b40571594a4eef6b1bb02305266c6 100644 (file)
@@ -1755,7 +1755,7 @@ quality_profiles.deleted_profile=The profile {0} doesn't exist anymore
 quality_profiles.projects_for_default=Every project not specifically associated with a quality profile will be associated to this one by default.
 quality_profiles.projects_for_default.edit=You must not select specific projects for the default quality profile.
 quality_profiles.inherits=Inherits "{0}"
-quality_profile.x_rules={0} rules
+quality_profile.x_rules={0} rule(s)
 quality_profile.x_active_rules={0} active rules
 quality_profiles.x_overridden_rules={0} overridden rules
 quality_profiles.change_parent=Change Parent
@@ -1785,7 +1785,7 @@ quality_profiles.latest_new_rules=Latest New Rules
 quality_profiles.latest_new_rules.activated={0}, activated on {1} profile(s)
 quality_profiles.latest_new_rules.not_activated={0}, not yet activated
 quality_profiles.deprecated_rules=Deprecated Rules
-quality_profiles.x_deprecated_rules_are_still_activated={0} deprecated rule(s) are still activated on {1} quality profile(s):
+quality_profiles.deprecated_rules_are_still_activated=Deprecated rules are still activated on {0} quality profile(s):
 quality_profiles.stagnant_profiles=Stagnant Profiles
 quality_profiles.not_updated_more_than_year=The following profiles haven't been updated for more than 1 year:
 quality_profiles.exporters=Exporters