diff options
author | Stas Vilchik <vilchiks@gmail.com> | 2016-03-03 11:04:07 +0100 |
---|---|---|
committer | Stas Vilchik <vilchiks@gmail.com> | 2016-03-03 11:16:00 +0100 |
commit | 0284c071909c365e22a9d3b0dda151bb78dbb839 (patch) | |
tree | 3e7d2edb60a630ece21d5452b23fe03a75e988dc | |
parent | 7420bd61b6d3d669046ad9bc2a4586317c0436ec (diff) | |
download | sonarqube-0284c071909c365e22a9d3b0dda151bb78dbb839.tar.gz sonarqube-0284c071909c365e22a9d3b0dda151bb78dbb839.zip |
SONAR-7331 Add new "Type" facet on Rules page
5 files changed, 76 insertions, 6 deletions
diff --git a/server/sonar-web/src/main/js/apps/coding-rules/facets-view.js b/server/sonar-web/src/main/js/apps/coding-rules/facets-view.js index 13da648cac3..688493a90ea 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/facets-view.js +++ b/server/sonar-web/src/main/js/apps/coding-rules/facets-view.js @@ -31,6 +31,7 @@ import AvailableSinceFacet from './facets/available-since-facet'; import InheritanceFacet from './facets/inheritance-facet'; import ActiveSeverityFacet from './facets/active-severity-facet'; import TemplateFacet from './facets/template-facet'; +import TypeFacet from './facets/type-facet'; const viewsMapping = { q: QueryFacet, @@ -44,7 +45,8 @@ const viewsMapping = { available_since: AvailableSinceFacet, inheritance: InheritanceFacet, active_severities: ActiveSeverityFacet, - is_template: TemplateFacet + is_template: TemplateFacet, + types: TypeFacet }; export default FacetsView.extend({ diff --git a/server/sonar-web/src/main/js/apps/coding-rules/facets/type-facet.js b/server/sonar-web/src/main/js/apps/coding-rules/facets/type-facet.js new file mode 100644 index 00000000000..eb4822407ee --- /dev/null +++ b/server/sonar-web/src/main/js/apps/coding-rules/facets/type-facet.js @@ -0,0 +1,35 @@ +/* + * 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. + */ +import _ from 'underscore'; +import BaseFacet from './base-facet'; +import Template from '../templates/facets/coding-rules-type-facet.hbs'; + +export default BaseFacet.extend({ + template: Template, + + sortValues (values) { + const order = ['BUG', 'VULNERABILITY', 'CODE_SMELL']; + return _.sortBy(values, function (v) { + return order.indexOf(v.val); + }); + } +}); + + diff --git a/server/sonar-web/src/main/js/apps/coding-rules/models/state.js b/server/sonar-web/src/main/js/apps/coding-rules/models/state.js index de2daae4d31..74cbb8fdcbe 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/models/state.js +++ b/server/sonar-web/src/main/js/apps/coding-rules/models/state.js @@ -24,14 +24,33 @@ export default State.extend({ page: 1, maxResultsReached: false, query: {}, - facets: ['languages', 'tags'], + facets: [ + 'types', + 'languages' + ], allFacets: [ - 'q', 'rule_key', 'languages', 'tags', 'repositories', 'severities', - 'statuses', 'available_since', 'is_template', 'qprofile', 'inheritance', 'active_severities' + 'q', + 'rule_key', + 'languages', + 'types', + 'tags', + 'repositories', + 'severities', + 'statuses', + 'available_since', + 'is_template', + 'qprofile', + 'inheritance', + 'active_severities' ], facetsFromServer: [ - 'languages', 'repositories', 'tags', 'severities', 'statuses', - 'active_severities' + 'languages', + 'repositories', + 'tags', + 'severities', + 'statuses', + 'active_severities', + 'types' ], transform: {} } diff --git a/server/sonar-web/src/main/js/apps/coding-rules/templates/facets/coding-rules-type-facet.hbs b/server/sonar-web/src/main/js/apps/coding-rules/templates/facets/coding-rules-type-facet.hbs new file mode 100644 index 00000000000..b5c53585993 --- /dev/null +++ b/server/sonar-web/src/main/js/apps/coding-rules/templates/facets/coding-rules-type-facet.hbs @@ -0,0 +1,13 @@ +{{> '_coding-rules-facet-header'}} + +<div class="search-navigator-facet-list"> + {{#each values}} + <a class="facet search-navigator-facet js-facet" + data-value="{{val}}"> + <span class="facet-name">{{t 'issue.type' val}}</span> + <span class="facet-stat"> + {{numberShort count}} + </span> + </a> + {{/each}} +</div> diff --git a/sonar-core/src/main/resources/org/sonar/l10n/core.properties b/sonar-core/src/main/resources/org/sonar/l10n/core.properties index fefb2fd734b..cbcf0cba9ba 100644 --- a/sonar-core/src/main/resources/org/sonar/l10n/core.properties +++ b/sonar-core/src/main/resources/org/sonar/l10n/core.properties @@ -2013,6 +2013,7 @@ coding_rules.facet.inheritance=Inheritance coding_rules.facet.active_severities=Activation Severity coding_rules.facet.is_template=Template coding_rules.facet.rule_key=Rule +coding_rules.facet.types=Type coding_rules.facets.languages=Languages coding_rules.facets.tags=Tags |