summaryrefslogtreecommitdiffstats
path: root/server/sonar-web
diff options
context:
space:
mode:
Diffstat (limited to 'server/sonar-web')
-rw-r--r--server/sonar-web/src/main/js/apps/coding-rules/facets-view.js4
-rw-r--r--server/sonar-web/src/main/js/apps/coding-rules/facets/type-facet.js35
-rw-r--r--server/sonar-web/src/main/js/apps/coding-rules/models/state.js29
-rw-r--r--server/sonar-web/src/main/js/apps/coding-rules/templates/facets/coding-rules-type-facet.hbs13
4 files changed, 75 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>