]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-7998 Open rule description in a new window from rules page
authorStas Vilchik <stas.vilchik@sonarsource.com>
Mon, 9 Oct 2017 15:02:38 +0000 (17:02 +0200)
committerStas Vilchik <stas.vilchik@sonarsource.com>
Tue, 10 Oct 2017 09:33:12 +0000 (11:33 +0200)
server/sonar-web/src/main/js/apps/coding-rules/templates/coding-rules-workspace-list-item.hbs
server/sonar-web/src/main/js/apps/coding-rules/workspace-list-item-view.js

index 139d46cdcb60b84cd07e76996ae30a3e2706b5c6..9996447d1bc28581376764605754ec8accc32de5 100644 (file)
@@ -16,7 +16,7 @@
 
     <td>
       <div class="coding-rule-title">
-        <a class="js-rule link-no-underline">{{name}}</a>
+        <a class="js-rule link-no-underline" href="{{permalink}}">{{name}}</a>
       </div>
     </td>
 
index 6235c15c7abf1a59cc8f167e093c37cb2a7e1817..ec836b95cd276a8ff74470c00785b26e94e25bd2 100644 (file)
@@ -26,6 +26,7 @@ import RuleFilterMixin from './rule/rule-filter-mixin';
 import Template from './templates/coding-rules-workspace-list-item.hbs';
 import confirmDialog from './confirm-dialog';
 import { translate, translateWithParameters } from '../../helpers/l10n';
+import { getBaseUrl } from '../../helpers/urls';
 
 export default WorkspaceListItemView.extend(RuleFilterMixin).extend({
   className: 'coding-rule',
@@ -61,9 +62,14 @@ export default WorkspaceListItemView.extend(RuleFilterMixin).extend({
     this.options.app.state.set({ selectedIndex: this.model.get('index') });
   },
 
-  openRule() {
-    this.$('[data-toggle="tooltip"]').tooltip('destroy');
-    this.options.app.controller.showDetails(this.model);
+  openRule(event) {
+    const leftClick =
+      event.button === 0 && !(event.metaKey || event.altKey || event.ctrlKey || event.shiftKey);
+    if (leftClick) {
+      event.preventDefault();
+      this.$('[data-toggle="tooltip"]').tooltip('destroy');
+      this.options.app.controller.showDetails(this.model);
+    }
   },
 
   activate() {
@@ -121,12 +127,19 @@ export default WorkspaceListItemView.extend(RuleFilterMixin).extend({
     const canEditQualityProfile =
       selectedProfile && selectedProfile.actions && selectedProfile.actions.edit;
 
+    const permalinkPath = this.options.app.organization
+      ? `/organizations/${this.options.app.organization}/rules`
+      : '/coding_rules';
+    const permalink =
+      getBaseUrl() + permalinkPath + '#rule_key=' + encodeURIComponent(this.model.id);
+
     return {
       ...WorkspaceListItemView.prototype.serializeData.apply(this, arguments),
       canEditQualityProfile,
       tags: union(this.model.get('sysTags'), this.model.get('tags')),
       selectedProfile: selectedProfileKey,
-      isSelectedProfileBuiltIn
+      isSelectedProfileBuiltIn,
+      permalink
     };
   }
 });