From: Julien Lancelot Date: Thu, 24 Mar 2016 14:08:48 +0000 (+0100) Subject: SONAR-7470 Drop ability to manage manual rules from UI X-Git-Tag: 5.5-M12~38 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=2b604976da1f7dbd47840728ec61b17833e43654;p=sonarqube.git SONAR-7470 Drop ability to manage manual rules from UI --- diff --git a/server/sonar-server/src/main/resources/org/sonar/server/platform/ws/l10n-index-example.json b/server/sonar-server/src/main/resources/org/sonar/server/platform/ws/l10n-index-example.json index 5a5718adc50..96e8d6bac83 100644 --- a/server/sonar-server/src/main/resources/org/sonar/server/platform/ws/l10n-index-example.json +++ b/server/sonar-server/src/main/resources/org/sonar/server/platform/ws/l10n-index-example.json @@ -34,7 +34,6 @@ "to.downcase": "to", "widget.sqaleSunburst.cant_display": "SQALE technical debt is 0 so the breakdown by characteristic can't be displayed.", "measure_filter.name_contains": "Name contains", - "manual_rules.page": "Manual Rules", "name_too_long_x": "Name is too long (maximum is {0} characters)", "metric.line_coverage.name": "Line coverage", "measure_filter.criteria.key": "Key", 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 b6dd113f837..282c5dd1cc7 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 @@ -78,14 +78,6 @@ const init = function () { Backbone.history.start(); }; -App.manualRepository = function () { - return { - key: 'manual', - name: translate('coding_rules.manual_rule'), - language: 'none' - }; -}; - const appXHR = $.get('/api/rules/app').done(function (r) { App.canWrite = r.canWrite; App.qualityProfiles = _.sortBy(r.qualityprofiles, ['name', 'lang']); @@ -96,7 +88,6 @@ const appXHR = $.get('/api/rules/app').done(function (r) { profile.language = App.languages[profile.lang]; }); App.repositories = r.repositories; - App.repositories.push(App.manualRepository()); App.statuses = r.statuses; }); diff --git a/server/sonar-web/src/main/js/apps/coding-rules/filters-view.js b/server/sonar-web/src/main/js/apps/coding-rules/filters-view.js index fb91769a46f..8f783009933 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/filters-view.js +++ b/server/sonar-web/src/main/js/apps/coding-rules/filters-view.js @@ -19,22 +19,11 @@ */ import _ from 'underscore'; import Marionette from 'backbone.marionette'; -import ManualRuleCreationView from './rule/manual-rule-creation-view'; import Template from './templates/coding-rules-filters.hbs'; export default Marionette.ItemView.extend({ template: Template, - events: { - 'click .js-create-manual-rule': 'createManualRule' - }, - - createManualRule () { - new ManualRuleCreationView({ - app: this.options.app - }).render(); - }, - serializeData () { return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), { canWrite: this.options.app.canWrite diff --git a/server/sonar-web/src/main/js/apps/coding-rules/rule-details-view.js b/server/sonar-web/src/main/js/apps/coding-rules/rule-details-view.js index 1a36a9c688d..e788c19cef2 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/rule-details-view.js +++ b/server/sonar-web/src/main/js/apps/coding-rules/rule-details-view.js @@ -27,7 +27,6 @@ import DescView from './rule/rule-description-view'; import ParamView from './rule/rule-parameters-view'; import ProfilesView from './rule/rule-profiles-view'; import CustomRulesView from './rule/custom-rules-view'; -import ManualRuleCreationView from './rule/manual-rule-creation-view'; import CustomRuleCreationView from './rule/custom-rule-creation-view'; import DeleteRuleView from './rule/delete-rule-view'; import IssuesView from './rule/rule-issues-view'; @@ -47,7 +46,6 @@ export default Marionette.LayoutView.extend({ }, events: { - 'click .js-edit-manual': 'editManualRule', 'click .js-edit-custom': 'editCustomRule', 'click .js-delete': 'deleteRule' }, @@ -131,13 +129,6 @@ export default Marionette.LayoutView.extend({ key.deleteScope('details'); }, - editManualRule () { - new ManualRuleCreationView({ - app: this.options.app, - model: this.model - }).render(); - }, - editCustomRule () { new CustomRuleCreationView({ app: this.options.app, @@ -162,18 +153,12 @@ export default Marionette.LayoutView.extend({ }, serializeData () { - const isManual = this.model.get('isManual'); const isCustom = this.model.has('templateKey'); - const isEditable = this.options.app.canWrite && (isManual || isCustom); - let qualityProfilesVisible = !isManual; - - if (qualityProfilesVisible) { - if (this.model.get('isTemplate')) { - qualityProfilesVisible = !_.isEmpty(this.options.actives); - } - else { - qualityProfilesVisible = (this.options.app.canWrite || !_.isEmpty(this.options.actives)); - } + const isEditable = this.options.app.canWrite && (isCustom); + let qualityProfilesVisible = true; + + if (this.model.get('isTemplate')) { + qualityProfilesVisible = !_.isEmpty(this.options.actives); } return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), { diff --git a/server/sonar-web/src/main/js/apps/coding-rules/rule/manual-rule-creation-view.js b/server/sonar-web/src/main/js/apps/coding-rules/rule/manual-rule-creation-view.js deleted file mode 100644 index a34ad593ce6..00000000000 --- a/server/sonar-web/src/main/js/apps/coding-rules/rule/manual-rule-creation-view.js +++ /dev/null @@ -1,136 +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 ModalFormView from '../../../components/common/modal-form'; -import Template from '../templates/rule/coding-rules-manual-rule-creation.hbs'; -import latinize from '../../../helpers/latinize'; -import { translate } from '../../../helpers/l10n'; - -export default ModalFormView.extend({ - template: Template, - - ui () { - return _.extend(ModalFormView.prototype.ui.apply(this.arguments), { - manualRuleCreationKey: '#coding-rules-manual-rule-creation-key', - manualRuleCreationName: '#coding-rules-manual-rule-creation-name', - manualRuleCreationHtmlDescription: '#coding-rules-manual-rule-creation-html-description', - manualRuleCreationSeverity: '#coding-rules-manual-rule-creation-severity', - manualRuleCreationStatus: '#coding-rules-manual-rule-creation-status', - manualRuleCreationParameters: '[name]', - manualRuleCreationCreate: '#coding-rules-manual-rule-creation-create', - manualRuleCreationReactivate: '#coding-rules-manual-rule-creation-reactivate', - modalFoot: '.modal-foot' - }); - }, - - events () { - return _.extend(ModalFormView.prototype.events.apply(this.arguments), { - 'input @ui.manualRuleCreationName': 'generateKey', - 'keydown @ui.manualRuleCreationName': 'generateKey', - 'keyup @ui.manualRuleCreationName': 'generateKey', - - 'input @ui.manualRuleCreationKey': 'flagKey', - 'keydown @ui.manualRuleCreationKey': 'flagKey', - 'keyup @ui.manualRuleCreationKey': 'flagKey', - - 'click #coding-rules-manual-rule-creation-cancel': 'hide', - 'click @ui.manualRuleCreationCreate': 'create', - 'click @ui.manualRuleCreationReactivate': 'reactivate' - }); - }, - - onRender () { - ModalFormView.prototype.onRender.apply(this, arguments); - this.keyModifiedByUser = false; - this.ui.manualRuleCreationReactivate.addClass('hidden'); - }, - - generateKey () { - if (!this.keyModifiedByUser && this.ui.manualRuleCreationKey) { - const generatedKey = latinize(this.ui.manualRuleCreationName.val()).replace(/[^A-Za-z0-9]/g, '_'); - this.ui.manualRuleCreationKey.val(generatedKey); - } - }, - - flagKey () { - this.keyModifiedByUser = true; - }, - - create () { - const action = (this.model && this.model.has('key')) ? 'update' : 'create'; - const options = { - name: this.ui.manualRuleCreationName.val(), - markdown_description: this.ui.manualRuleCreationHtmlDescription.val() - }; - if (action === 'update') { - options.key = this.model.get('key'); - } else { - options.manual_key = this.ui.manualRuleCreationKey.val(); - options.prevent_reactivation = true; - } - this.sendRequest(action, options); - }, - - reactivate () { - const options = { - name: this.existingRule.name, - markdown_description: this.existingRule.mdDesc, - manual_key: this.ui.manualRuleCreationKey.val(), - prevent_reactivation: false - }; - this.sendRequest('create', options); - }, - - sendRequest (action, options) { - const that = this; - const url = '/api/rules/' + action; - return $.ajax({ - url, - type: 'POST', - data: options, - statusCode: { - // do not show global error - 400: null - } - }).done(function (r) { - if (typeof r === 'string') { - r = JSON.parse(r); - } - that.options.app.controller.showDetails(r.rule.key); - that.destroy(); - }).fail(function (jqXHR) { - if (jqXHR.status === 409) { - that.existingRule = jqXHR.responseJSON.rule; - that.showErrors([], [{ msg: translate('coding_rules.reactivate.help') }]); - that.ui.manualRuleCreationCreate.addClass('hidden'); - that.ui.manualRuleCreationReactivate.removeClass('hidden'); - } else { - that.showErrors(jqXHR.responseJSON.errors, jqXHR.responseJSON.warnings); - } - }); - }, - - serializeData () { - return _.extend(ModalFormView.prototype.serializeData.apply(this, arguments), { - change: this.model && this.model.has('key') - }); - } -}); diff --git a/server/sonar-web/src/main/js/apps/coding-rules/rule/rule-description-view.js b/server/sonar-web/src/main/js/apps/coding-rules/rule/rule-description-view.js index 80ddf0dd6b2..9ed27e3238f 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/rule/rule-description-view.js +++ b/server/sonar-web/src/main/js/apps/coding-rules/rule/rule-description-view.js @@ -93,7 +93,7 @@ export default Marionette.ItemView.extend({ }, serializeData () { - const isEditable = this.options.app.canWrite && (this.model.get('isManual') || this.model.get('isCustom')); + const isEditable = this.options.app.canWrite && (this.model.get('isCustom')); return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), { isEditable, diff --git a/server/sonar-web/src/main/js/apps/coding-rules/rule/rule-parameters-view.js b/server/sonar-web/src/main/js/apps/coding-rules/rule/rule-parameters-view.js index 89a66d8ad03..205a43c58b6 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/rule/rule-parameters-view.js +++ b/server/sonar-web/src/main/js/apps/coding-rules/rule/rule-parameters-view.js @@ -33,7 +33,7 @@ export default Marionette.ItemView.extend({ }, serializeData () { - const isEditable = this.options.app.canWrite && (this.model.get('isManual') || this.model.get('isCustom')); + const isEditable = this.options.app.canWrite && this.model.get('isCustom'); return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), { isEditable, diff --git a/server/sonar-web/src/main/js/apps/coding-rules/rule/rule-profiles-view.js b/server/sonar-web/src/main/js/apps/coding-rules/rule/rule-profiles-view.js index 88c5dc208ea..e3abef640bf 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/rule/rule-profiles-view.js +++ b/server/sonar-web/src/main/js/apps/coding-rules/rule/rule-profiles-view.js @@ -45,16 +45,10 @@ export default Marionette.CompositeView.extend({ }, onRender () { - const isManual = this.model.get('isManual'); - let qualityProfilesVisible = !isManual; + let qualityProfilesVisible = true; - if (qualityProfilesVisible) { - if (this.model.get('isTemplate')) { - qualityProfilesVisible = this.collection.length > 0; - } - else { - qualityProfilesVisible = (this.options.app.canWrite || this.collection.length > 0); - } + if (this.model.get('isTemplate')) { + qualityProfilesVisible = this.collection.length > 0; } this.$el.toggleClass('hidden', !qualityProfilesVisible); diff --git a/server/sonar-web/src/main/js/apps/coding-rules/templates/coding-rules-filters.hbs b/server/sonar-web/src/main/js/apps/coding-rules/templates/coding-rules-filters.hbs index fb62c872c25..e307b61b100 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/templates/coding-rules-filters.hbs +++ b/server/sonar-web/src/main/js/apps/coding-rules/templates/coding-rules-filters.hbs @@ -1,9 +1,3 @@

{{t 'coding_rules.page'}}

- -{{#if canWrite}} -
- -
-{{/if}} diff --git a/server/sonar-web/src/main/js/apps/coding-rules/templates/coding-rules-rule-details.hbs b/server/sonar-web/src/main/js/apps/coding-rules/templates/coding-rules-rule-details.hbs index f889780e6c6..eba42ee65ef 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/templates/coding-rules-rule-details.hbs +++ b/server/sonar-web/src/main/js/apps/coding-rules/templates/coding-rules-rule-details.hbs @@ -5,11 +5,7 @@ {{#if isEditable}}
- {{#if isManual}} - - {{else}} - - {{/if}} +
diff --git a/server/sonar-web/src/main/js/apps/coding-rules/templates/rule/coding-rules-manual-rule-creation.hbs b/server/sonar-web/src/main/js/apps/coding-rules/templates/rule/coding-rules-manual-rule-creation.hbs deleted file mode 100644 index 858bebf3854..00000000000 --- a/server/sonar-web/src/main/js/apps/coding-rules/templates/rule/coding-rules-manual-rule-creation.hbs +++ /dev/null @@ -1,51 +0,0 @@ -
- - - - - -
diff --git a/server/sonar-web/src/main/js/apps/coding-rules/templates/rule/coding-rules-rule-description.hbs b/server/sonar-web/src/main/js/apps/coding-rules/templates/rule/coding-rules-rule-description.hbs index f9ad18feb91..9992055a7c6 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/templates/rule/coding-rules-rule-description.hbs +++ b/server/sonar-web/src/main/js/apps/coding-rules/templates/rule/coding-rules-rule-description.hbs @@ -1,48 +1,46 @@
{{{htmlDesc}}}
{{#unless isEditable}} - {{#unless isManual}} -
-
- {{#if htmlNote}} -
{{{htmlNote}}}
- {{/if}} - {{#if canWrite}} -
- -
- {{/if}} -
- +
+
+ {{#if htmlNote}} +
{{{htmlNote}}}
+ {{/if}} {{#if canWrite}} - - {{/unless}} + + {{#if canWrite}} + + {{/if}} +
{{/unless}} 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 1b225182a0d..57503382826 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 @@ -15,17 +15,15 @@
    - {{#unless isManual}} -
  • - {{issueType this.type}} -
  • +
  • + {{issueType this.type}} +
  • -
  • - {{severityIcon severity}} {{t "severity" severity}} -
  • - {{/unless}} +
  • + {{severityIcon severity}} {{t "severity" severity}} +
  • {{#notEq status 'READY'}}
  • {{t 'coding_rules.available_since'}} {{d createdAt}}
  • - {{repoName}}{{#unless isManual}} ({{langName}}){{/unless}} + data-toggle="tooltip" data-placement="bottom" title="Rule repository{(language)"> + {{repoName}}({{langName}})
  • {{#if isTemplate}} 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 1618f444b62..230088e7e87 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 @@ -6,17 +6,15 @@
      {{#if severity}} - {{#unless isManual}} -
    • - {{issueType this.type}} -
    • - -
    • - {{severityIcon severity}} {{t "severity" severity}} -
    • - {{/unless}} +
    • + {{issueType this.type}} +
    • + +
    • + {{severityIcon severity}} {{t "severity" severity}} +
    • {{/if}} {{#notEq status 'READY'}} 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 de0089abafe..bfe8d4bd1db 100644 --- a/sonar-core/src/main/resources/org/sonar/l10n/core.properties +++ b/sonar-core/src/main/resources/org/sonar/l10n/core.properties @@ -471,10 +471,6 @@ manual_measures.page=Manual Measures manual_measures.page.description=Update the values of manual metrics for this project. Changes will take effect at the project's next analysis. Manual Metrics must be created at the global level. custom_measures.page=Custom Measures custom_measures.page.description=Update the values of custom metrics for this project. Changes will take effect at the project's next analysis. Custom metrics must be created at the global level. -manual_rules.page=Manual Rules -manual_rules.page.description=These rules are available for all projects. Manual issues can be created at project level via the component code viewer. -manual_rules.delete_manual_rule=Delete Manual Rule -manual_rules.delete_manual_rule_message=Are you sure that you want to delete manual rule "{0}"? roles.page=Project Permissions roles.page.description=Grant and revoke project-level permissions to Browse (view a project's metrics), See Source Code, and Administer individual projects. Permissions can be granted to groups or individual users. roles.page.description2=Grant and revoke project-level permissions. Permissions can be granted to groups or individual users. @@ -714,8 +710,6 @@ issue.unresolved.description=Unresolved issues have not been addressed in any wa issue.updated=Updated: issue.manual.missing_rule=Missing rule -issue.manual.no_rules.admin=Manual rules must be defined before manual issues can be created. -issue.manual.no_rules.non_admin=At least one manual rule must exist before manual issues can be created. Please contact your project administrator. issue.reported_by=Reported by issue.authorLogin=Author: issue.component_deleted=Removed @@ -1846,14 +1840,12 @@ coding_rules.change_severity_in=Change Severity In coding_rules.change_details=Change Details of Quality Profile coding_rules.create=Create coding_rules.create_custom_rule=Create Custom Rule -coding_rules.create_manual_rule=Create Manual Rule coding_rules.custom_rule=Custom Rule coding_rules.custom_rule.title=This rule has been created through customization of a rule template coding_rules.custom_rule.activation_notice=Note: parameters of a custom rule are not customizable on rule activation, only during creation/edit. coding_rules.custom_rules=Custom Rules coding_rules.delete_rule=Delete Rule coding_rules.delete.custom.confirm=Are you sure you want to delete custom rule "{0}"? -coding_rules.delete.manual.confirm=Are you sure you want to delete manual rule "{0}"? coding_rules.extend_description=Extend Description coding_rules.deactivate_in=Deactivate In coding_rules.deactivate=Deactivate @@ -1864,8 +1856,6 @@ coding_rules.found=Found coding_rules.inherits="{0}" inherits from "{1}" coding_rules.issues=Issues coding_rules.key=Key: -coding_rules.manual_rule=Manual Rule -coding_rules.manual_rules=Manual Rules coding_rules.most_violated_projects=Most Violated Projects coding_rules.new_search=New Search coding_rules.no_results=No Coding Rules @@ -1899,7 +1889,6 @@ coding_rules.type.tooltip.BUG=Bug Detection Rule coding_rules.type.tooltip.VULNERABILITY=Vulnerability Detection Rule coding_rules.noncharacterized=Uncharacterized coding_rules.update_custom_rule=Update Custom Rule -coding_rules.update_manual_rule=Update Manual Rule coding_rules.filter_similar_rules=Filter Similar Rules coding_rules.validation.invalid_rule_key=The rule key "%s" is invalid, it should only contain: a-z, 0-9, "_" @@ -1908,7 +1897,6 @@ coding_rules.validation.missing_description=The description is missing coding_rules.validation.missing_severity=The severity is missing coding_rules.validation.invalid_severity=Severity "{0}" is invalid coding_rules.validation.missing_status=The status is missing -coding_rules.validation.manual_rule_params=No parameter can be set on a manual rule coding_rules.filters.activation=Activation coding_rules.filters.activation.active=Active @@ -2951,7 +2939,6 @@ component_viewer.tests.status=status component_viewer.x_lines_are_covered={0} lines are covered component_viewer.details=Details -component_viewer.add_manual_issue=Add Manual Issue component_viewer.line_actions=Line Actions component_viewer.no_issues=No Issues component_viewer.no_coverage=No Coverage