]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-7402 sort measures inside domain
authorStas Vilchik <vilchiks@gmail.com>
Thu, 10 Mar 2016 14:40:52 +0000 (15:40 +0100)
committerStas Vilchik <vilchiks@gmail.com>
Thu, 10 Mar 2016 14:43:47 +0000 (15:43 +0100)
server/sonar-web/package.json
server/sonar-web/src/main/js/apps/component-measures/components/AllMeasuresDomain.js
server/sonar-web/src/main/js/apps/component-measures/config/domains.js [new file with mode: 0644]

index b68a902c342df8cc9a2ae12a1ce4e56e93fa0796..43a3f6e3f3d38bca6f00bdb5c115712b8ab28030 100644 (file)
@@ -47,6 +47,7 @@
     "isparta": "4.0.0",
     "jquery": "2.2.0",
     "jsdom": "6.5.1",
+    "lodash": "4.6.1",
     "mocha": "2.3.4",
     "moment": "2.10.6",
     "numeral": "1.5.3",
index 4b3f7222ec11e11a45fae1e7869978e3a632a156..f70f0afd2032a5bc82648546f76f62b16255bb28 100644 (file)
  * along with this program; if not, write to the Free Software Foundation,
  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  */
+import sortBy from 'lodash/sortBy';
+import partition from 'lodash/partition';
 import React from 'react';
 import { Link } from 'react-router';
 
+import domains from '../config/domains';
 import { formatLeak } from '../utils';
 import { formatMeasure } from '../../../helpers/measures';
 import { translateWithParameters } from '../../../helpers/l10n';
 
 export default function AllMeasuresDomain ({ domain, component, displayLeakHeader, leakPeriodLabel }) {
   const hasLeak = !!leakPeriodLabel;
+  const { measures } = domain;
+  const knownMetrics = domains[domain.name] || [];
+
+  const [knownMeasures, otherMeasures] =
+      partition(measures, measure => knownMetrics.indexOf(measure.metric.key) !== -1);
+
+  const finalMeasures = [
+    ...sortBy(knownMeasures, measure => knownMetrics.indexOf(measure.metric.key)),
+    ...sortBy(otherMeasures, measure => measure.metric.name)
+  ];
 
   return (
       <li>
@@ -39,7 +52,7 @@ export default function AllMeasuresDomain ({ domain, component, displayLeakHeade
         </header>
 
         <ul className="domain-measures">
-          {domain.measures.map(measure => (
+          {finalMeasures.map(measure => (
               <li key={measure.metric.key}>
                 <Link to={{ pathname: measure.metric.key, query: { id: component.key } }}>
                   <div className="domain-measures-name">
diff --git a/server/sonar-web/src/main/js/apps/component-measures/config/domains.js b/server/sonar-web/src/main/js/apps/component-measures/config/domains.js
new file mode 100644 (file)
index 0000000..1a0b2da
--- /dev/null
@@ -0,0 +1,99 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2016 SonarSource SA
+ * mailto:contact AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+export default {
+  'Issues': [
+    'violations',
+    'new_violations',
+    'blocker_violations',
+    'new_blocker_violations',
+    'critical_violations',
+    'new_critical_violations',
+    'major_violations',
+    'new_major_violations',
+    'minor_violations',
+    'new_minor_violations',
+    'info_violations',
+    'new_info_violations',
+    'open_issues',
+    'reopened_issues',
+    'confirmed_issues',
+    'false_positive_issues'
+  ],
+
+  'Maintainability': [
+    'code_smells',
+    'new_code_smells',
+    'sqale_index',
+    'new_technical_debt',
+    'sqale_rating',
+    'sqale_debt_ratio',
+    'new_sqale_debt_ratio',
+    'effort_to_reach_maintainability_rating_a'
+  ],
+
+  'Reliability': [
+    'bugs',
+    'new_bugs',
+    'reliability_rating',
+    'reliability_remediation_effort',
+    'new_reliability_remediation_effort',
+    'effort_to_reach_reliability_rating_a'
+  ],
+
+  'Security': [
+    'vulnerabilities',
+    'new_vulnerabilities',
+    'security_rating',
+    'security_remediation_effort',
+    'new_security_remediation_effort',
+    'effort_to_reach_security_rating_a'
+  ],
+
+  'Size': [
+    'ncloc',
+    'lines'
+  ],
+
+  'Tests': [
+    'overall_coverage',
+    'overall_line_coverage',
+    'overall_branch_coverage',
+    'overall_uncovered_lines',
+    'overall_uncovered_conditions',
+    'coverage',
+    'line_coverage',
+    'branch_coverage',
+    'uncovered_lines',
+    'uncovered_conditions',
+    'it_coverage',
+    'it_line_coverage',
+    'it_branch_coverage',
+    'it_uncovered_lines',
+    'it_uncovered_conditions',
+    'lines_to_cover',
+    'tests',
+    'test_success',
+    'test_errors',
+    'test_failures',
+    'skipped_tests',
+    'test_success_density',
+    'test_execution_time'
+  ]
+};