From 2b8b8be83e310e386db0953fdb473bb3669d5e55 Mon Sep 17 00:00:00 2001 From: Stas Vilchik Date: Mon, 22 Feb 2016 14:24:55 +0100 Subject: SONAR-7377 Remove SQALE characteristics from UI --- .../sonar-web/src/main/js/apps/coding-rules/app.js | 13 ---- .../src/main/js/apps/coding-rules/controller.js | 3 +- .../src/main/js/apps/coding-rules/facets-view.js | 2 - .../coding-rules/facets/characteristic-facet.js | 81 ---------------------- .../src/main/js/apps/coding-rules/models/state.js | 8 +-- .../js/apps/coding-rules/rule/rule-meta-view.js | 1 - .../templates/coding-rules-rule-filter-form.hbs | 18 ----- .../facets/coding-rules-characteristic-facet.hbs | 19 ----- .../templates/rule/coding-rules-rule-meta.hbs | 27 +++----- .../workspace/templates/workspace-rule.hbs | 31 +++------ 10 files changed, 24 insertions(+), 179 deletions(-) delete mode 100644 server/sonar-web/src/main/js/apps/coding-rules/facets/characteristic-facet.js delete mode 100644 server/sonar-web/src/main/js/apps/coding-rules/templates/facets/coding-rules-characteristic-facet.hbs diff --git a/server/sonar-web/src/main/js/apps/coding-rules/app.js b/server/sonar-web/src/main/js/apps/coding-rules/app.js index 5bca4881b0b..a5f63248c28 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/app.js +++ b/server/sonar-web/src/main/js/apps/coding-rules/app.js @@ -86,16 +86,6 @@ App.manualRepository = function () { }; }; -App.getSubCharacteristicName = function (key) { - if (key != null) { - const ch = _.findWhere(App.characteristics, { key }); - const parent = _.findWhere(App.characteristics, { key: ch.parent }); - return [parent.name, ch.name].join(' > '); - } else { - return null; - } -}; - const appXHR = $.get('/api/rules/app').done(function (r) { App.canWrite = r.canWrite; App.qualityProfiles = _.sortBy(r.qualityprofiles, ['name', 'lang']); @@ -108,9 +98,6 @@ const appXHR = $.get('/api/rules/app').done(function (r) { App.repositories = r.repositories; App.repositories.push(App.manualRepository()); App.statuses = r.statuses; - App.characteristics = r.characteristics.map(function (item, index) { - return _.extend(item, { index }); - }); }); App.on('start', function (options) { diff --git a/server/sonar-web/src/main/js/apps/coding-rules/controller.js b/server/sonar-web/src/main/js/apps/coding-rules/controller.js index a657c3322e5..3cfad3f2f3c 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/controller.js +++ b/server/sonar-web/src/main/js/apps/coding-rules/controller.js @@ -26,8 +26,7 @@ import RuleDetailsView from './rule-details-view'; export default Controller.extend({ pageSize: 200, ruleFields: [ - 'name', 'lang', 'langName', 'sysTags', 'tags', 'status', 'severity', - 'debtChar', 'debtCharName', 'debtSubChar', 'debtSubCharName' + 'name', 'lang', 'langName', 'sysTags', 'tags', 'status', 'severity' ], 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 19d288096db..13da648cac3 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 @@ -25,7 +25,6 @@ import LanguageFacet from './facets/language-facet'; import RepositoryFacet from './facets/repository-facet'; import TagFacet from './facets/tag-facet'; import QualityProfileFacet from './facets/quality-profile-facet'; -import CharacteristicFacet from './facets/characteristic-facet'; import SeverityFacet from './facets/severity-facet'; import StatusFacet from './facets/status-facet'; import AvailableSinceFacet from './facets/available-since-facet'; @@ -40,7 +39,6 @@ const viewsMapping = { repositories: RepositoryFacet, tags: TagFacet, qprofile: QualityProfileFacet, - debt_characteristics: CharacteristicFacet, severities: SeverityFacet, statuses: StatusFacet, available_since: AvailableSinceFacet, diff --git a/server/sonar-web/src/main/js/apps/coding-rules/facets/characteristic-facet.js b/server/sonar-web/src/main/js/apps/coding-rules/facets/characteristic-facet.js deleted file mode 100644 index 8245e239174..00000000000 --- a/server/sonar-web/src/main/js/apps/coding-rules/facets/characteristic-facet.js +++ /dev/null @@ -1,81 +0,0 @@ -/* - * 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 'jquery'; -import _ from 'underscore'; -import BaseFacet from './base-facet'; -import Template from '../templates/facets/coding-rules-characteristic-facet.hbs'; - -export default BaseFacet.extend({ - template: Template, - - onRender () { - BaseFacet.prototype.onRender.apply(this, arguments); - const value = this.options.app.state.get('query').has_debt_characteristic; - if (value != null && ('' + value === 'false')) { - this.$('.js-facet').filter('[data-empty-characteristic]').addClass('active'); - } - }, - - toggleFacet (e) { - const noneCharacteristic = $(e.currentTarget).is('[data-empty-characteristic]'); - const property = this.model.get('property'); - const obj = {}; - $(e.currentTarget).toggleClass('active'); - if (noneCharacteristic) { - const checked = $(e.currentTarget).is('.active'); - obj.has_debt_characteristic = checked ? 'false' : null; - obj[property] = null; - } else { - obj.has_debt_characteristic = null; - obj[property] = this.getValue(); - } - this.options.app.state.updateFilter(obj); - }, - - disable () { - const property = this.model.get('property'); - const obj = {}; - obj.has_debt_characteristic = null; - obj[property] = null; - this.options.app.state.updateFilter(obj); - }, - - getValues () { - const values = this.model.getValues(); - const characteristics = this.options.app.characteristics; - return values.map(function (value) { - const ch = _.findWhere(characteristics, { key: value.val }); - if (ch != null) { - _.extend(value, ch, { label: ch.name }); - } - return value; - }); - }, - - sortValues (values) { - return _.sortBy(values, 'index'); - }, - - serializeData () { - return _.extend(BaseFacet.prototype.serializeData.apply(this, arguments), { - values: this.sortValues(this.getValues()) - }); - } -}); 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 48e46b6f3a8..de2daae4d31 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 @@ -26,15 +26,13 @@ export default State.extend({ query: {}, facets: ['languages', 'tags'], allFacets: [ - 'q', 'rule_key', 'languages', 'tags', 'repositories', 'debt_characteristics', 'severities', + 'q', 'rule_key', 'languages', 'tags', 'repositories', 'severities', 'statuses', 'available_since', 'is_template', 'qprofile', 'inheritance', 'active_severities' ], facetsFromServer: [ - 'languages', 'repositories', 'tags', 'severities', 'statuses', 'debt_characteristics', + 'languages', 'repositories', 'tags', 'severities', 'statuses', 'active_severities' ], - transform: { - 'has_debt_characteristic': 'debt_characteristics' - } + transform: {} } }); diff --git a/server/sonar-web/src/main/js/apps/coding-rules/rule/rule-meta-view.js b/server/sonar-web/src/main/js/apps/coding-rules/rule/rule-meta-view.js index f8a182a74a8..a11699b561e 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/rule/rule-meta-view.js +++ b/server/sonar-web/src/main/js/apps/coding-rules/rule/rule-meta-view.js @@ -106,7 +106,6 @@ export default Marionette.ItemView.extend(RuleFilterMixin).extend({ serializeData () { return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), { canWrite: this.options.app.canWrite, - subCharacteristic: this.options.app.getSubCharacteristicName(this.model.get('debtSubChar')), allTags: _.union(this.model.get('sysTags'), this.model.get('tags')), permalink: '/coding_rules#rule_key=' + encodeURIComponent(this.model.id) }); diff --git a/server/sonar-web/src/main/js/apps/coding-rules/templates/coding-rules-rule-filter-form.hbs b/server/sonar-web/src/main/js/apps/coding-rules/templates/coding-rules-rule-filter-form.hbs index e8876920f62..4cc2320273e 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/templates/coding-rules-rule-filter-form.hbs +++ b/server/sonar-web/src/main/js/apps/coding-rules/templates/coding-rules-rule-filter-form.hbs @@ -17,24 +17,6 @@ {{/if}} - {{#if debtChar}} -
  • - -
  • - - {{debtCharName}} - -
  • - - {{#if debtSubChar}} -
  • - - {{debtSubCharName}} - -
  • - {{/if}} - {{/if}} - {{#notEmpty tags}}
  • {{#each tags}} diff --git a/server/sonar-web/src/main/js/apps/coding-rules/templates/facets/coding-rules-characteristic-facet.hbs b/server/sonar-web/src/main/js/apps/coding-rules/templates/facets/coding-rules-characteristic-facet.hbs deleted file mode 100644 index 645205b0c5c..00000000000 --- a/server/sonar-web/src/main/js/apps/coding-rules/templates/facets/coding-rules-characteristic-facet.hbs +++ /dev/null @@ -1,19 +0,0 @@ -{{> '_coding-rules-facet-header'}} - -
    - {{#each values}} - {{#eq val 'NONE'}} - - {{t 'coding_rules.noncharacterized'}} - {{numberShort count}} - - {{else}} - - {{default label val}} - {{numberShort count}} - - {{/eq}} - {{/each}} -
    diff --git a/server/sonar-web/src/main/js/apps/coding-rules/templates/rule/coding-rules-rule-meta.hbs b/server/sonar-web/src/main/js/apps/coding-rules/templates/rule/coding-rules-rule-meta.hbs index 010f827776d..2ca76e8c95d 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/templates/rule/coding-rules-rule-meta.hbs +++ b/server/sonar-web/src/main/js/apps/coding-rules/templates/rule/coding-rules-rule-meta.hbs @@ -64,24 +64,15 @@ ({{t 'coding_rules.show_template'}}) {{/if}} - -{{#if subCharacteristic}} - -{{/if}} + {{#if debtRemFnOffset}}{{debtRemFnOffset}}{{/if}} + {{#if debtRemFnCoeff}}{{#if debtRemFnOffset}}+{{/if}}{{debtRemFnCoeff}}{{/if}} + {{#if effortToFixDescription}}{{effortToFixDescription}}{{/if}} + + {{/if}} + diff --git a/server/sonar-web/src/main/js/components/workspace/templates/workspace-rule.hbs b/server/sonar-web/src/main/js/components/workspace/templates/workspace-rule.hbs index 0624cedeafa..40a1c3ff74b 100644 --- a/server/sonar-web/src/main/js/components/workspace/templates/workspace-rule.hbs +++ b/server/sonar-web/src/main/js/components/workspace/templates/workspace-rule.hbs @@ -27,6 +27,17 @@
  • {{t 'coding_rules.available_since'}} {{d createdAt}}
  • + {{#if debtRemFnType}} +
  • + {{t 'coding_rules.remediation_function' debtRemFnType}}: + + {{#if debtRemFnOffset}}{{debtRemFnOffset}}{{/if}} + {{#if debtRemFnCoeff}}{{#if debtRemFnOffset}}+{{/if}}{{debtRemFnCoeff}}{{/if}} + {{#if effortToFixDescription}}{{effortToFixDescription}}{{/if}} +
  • + {{/if}} +
  • @@ -36,26 +47,6 @@ - {{#if debtCharName}} - - {{/if}} -
    {{{htmlDesc}}}
    {{#if htmlNote}} -- cgit v1.2.3