From 2c40039908c972b3c6a0e2e8406a318ca2e656dc Mon Sep 17 00:00:00 2001 From: Stas Vilchik Date: Fri, 26 Dec 2014 16:03:25 +0100 Subject: [PATCH] Fix quality flaws --- .../src/main/js/coding-rules/facets-view.js | 65 ++++++++----------- .../facets/active-severity-facet.js | 6 +- 2 files changed, 31 insertions(+), 40 deletions(-) diff --git a/server/sonar-web/src/main/js/coding-rules/facets-view.js b/server/sonar-web/src/main/js/coding-rules/facets-view.js index ac85233ba5a..1e3a3077a2f 100644 --- a/server/sonar-web/src/main/js/coding-rules/facets-view.js +++ b/server/sonar-web/src/main/js/coding-rules/facets-view.js @@ -1,17 +1,17 @@ define([ - 'components/navigator/facets-view', - 'coding-rules/facets/base-facet', - 'coding-rules/facets/query-facet', - 'coding-rules/facets/language-facet', - 'coding-rules/facets/repository-facet', - 'coding-rules/facets/quality-profile-facet', - 'coding-rules/facets/characteristic-facet', - 'coding-rules/facets/severity-facet', - 'coding-rules/facets/status-facet', - 'coding-rules/facets/available-since-facet', - 'coding-rules/facets/inheritance-facet', - 'coding-rules/facets/active-severity-facet' -], + 'components/navigator/facets-view', + 'coding-rules/facets/base-facet', + 'coding-rules/facets/query-facet', + 'coding-rules/facets/language-facet', + 'coding-rules/facets/repository-facet', + 'coding-rules/facets/quality-profile-facet', + 'coding-rules/facets/characteristic-facet', + 'coding-rules/facets/severity-facet', + 'coding-rules/facets/status-facet', + 'coding-rules/facets/available-since-facet', + 'coding-rules/facets/inheritance-facet', + 'coding-rules/facets/active-severity-facet' + ], function (FacetsView, BaseFacet, QueryFacet, @@ -25,33 +25,24 @@ define([ InheritanceFacet, ActiveSeverityFacet) { + var viewsMapping = { + q: QueryFacet, + languages: LanguageFacet, + repositories: RepositoryFacet, + qprofile: QualityProfileFacet, + debt_characteristics: CharacteristicFacet, + severities: SeverityFacet, + statuses: StatusFacet, + available_since: AvailableSinceFacet, + inheritance: InheritanceFacet, + active_severities: ActiveSeverityFacet + }; + return FacetsView.extend({ getItemView: function (model) { - switch (model.get('property')) { - case 'q': - return QueryFacet; - case 'languages': - return LanguageFacet; - case 'repositories': - return RepositoryFacet; - case 'qprofile': - return QualityProfileFacet; - case 'debt_characteristics': - return CharacteristicFacet; - case 'severities': - return SeverityFacet; - case 'statuses': - return StatusFacet; - case 'available_since': - return AvailableSinceFacet; - case 'inheritance': - return InheritanceFacet; - case 'active_severities': - return ActiveSeverityFacet; - default: - return BaseFacet; - } + var view = viewsMapping[model.get('property')]; + return view ? view : BaseFacet; } }); diff --git a/server/sonar-web/src/main/js/coding-rules/facets/active-severity-facet.js b/server/sonar-web/src/main/js/coding-rules/facets/active-severity-facet.js index 9d19a498ecd..f6ec4dd731b 100644 --- a/server/sonar-web/src/main/js/coding-rules/facets/active-severity-facet.js +++ b/server/sonar-web/src/main/js/coding-rules/facets/active-severity-facet.js @@ -1,8 +1,8 @@ define([ - 'coding-rules/facets/base-facet', - 'templates/coding-rules' + 'coding-rules/facets/base-facet', + 'templates/coding-rules' ], function (BaseFacet, Templates) { - + return BaseFacet.extend({ template: Templates['coding-rules-severity-facet'], severities: ['BLOCKER', 'MINOR', 'CRITICAL', 'INFO', 'MAJOR'], -- 2.39.5