From 1d777d3f5298c7e71f6a6a6da106698029c49bd6 Mon Sep 17 00:00:00 2001 From: Stas Vilchik Date: Tue, 15 Sep 2015 12:15:52 +0200 Subject: [PATCH] SONAR-6207 Provide a keyboard shortcut to activate a rule from the list of rules --- .../src/main/js/apps/coding-rules/controller.js | 12 ++++++++++++ .../main/js/apps/coding-rules/workspace-list-view.js | 8 ++++++++ .../js/apps/nav/templates/nav-shortcuts-help.hbs | 2 ++ .../main/resources/org/sonar/l10n/core.properties | 2 ++ 4 files changed, 24 insertions(+) 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 5ee32475e99..f36d9bd33c9 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 @@ -156,6 +156,18 @@ define([ if (firstPage) { this.app.workspaceListView.scrollTo(); } + }, + + activateCurrent: function () { + var rule = this.app.list.at(this.app.state.get('selectedIndex')); + var ruleView = this.app.workspaceListView.children.findByModel(rule); + ruleView.$('.coding-rules-detail-quality-profile-activate').click(); + }, + + deactivateCurrent: function () { + var rule = this.app.list.at(this.app.state.get('selectedIndex')); + var ruleView = this.app.workspaceListView.children.findByModel(rule); + ruleView.$('.coding-rules-detail-quality-profile-deactivate').click(); } }); diff --git a/server/sonar-web/src/main/js/apps/coding-rules/workspace-list-view.js b/server/sonar-web/src/main/js/apps/coding-rules/workspace-list-view.js index e77a504fa7f..e100c02cf67 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/workspace-list-view.js +++ b/server/sonar-web/src/main/js/apps/coding-rules/workspace-list-view.js @@ -37,6 +37,14 @@ define([ that.options.app.controller.showDetailsForSelected(); return false; }); + key('a', function () { + that.options.app.controller.activateCurrent(); + return false; + }); + key('d', function () { + that.options.app.controller.deactivateCurrent(); + return false; + }); } }); diff --git a/server/sonar-web/src/main/js/apps/nav/templates/nav-shortcuts-help.hbs b/server/sonar-web/src/main/js/apps/nav/templates/nav-shortcuts-help.hbs index 5230e7f5912..f49ed110e0e 100644 --- a/server/sonar-web/src/main/js/apps/nav/templates/nav-shortcuts-help.hbs +++ b/server/sonar-web/src/main/js/apps/nav/templates/nav-shortcuts-help.hbs @@ -29,6 +29,8 @@ class="shortcut-button">↓    {{t 'shortcuts.section.rules.navigate_between_rules'}}
  •    {{t 'shortcuts.section.rules.open_details'}}
  •    {{t 'shortcuts.section.rules.return_to_list'}}
  • +
  • a    {{t 'shortcuts.section.rules.activate'}}
  • +
  • d    {{t 'shortcuts.section.rules.deactivate'}}
  • 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 5fb13b140bc..d5e4292365b 100644 --- a/sonar-core/src/main/resources/org/sonar/l10n/core.properties +++ b/sonar-core/src/main/resources/org/sonar/l10n/core.properties @@ -1097,6 +1097,8 @@ shortcuts.section.rules=Rules Page shortcuts.section.rules.navigate_between_rules=navigate between rules shortcuts.section.rules.open_details=go from the list of rules to the rule details shortcuts.section.rules.return_to_list=return back to the list +shortcuts.section.rules.activate=activate selected rule +shortcuts.section.rules.deactivate=deactivate selected rule #------------------------------------------------------------------------------ -- 2.39.5