Update comment tooltip if shortcuts are disabled

Tooltip can be clicked to create a comment which is not clear from
the current text, hence update the text if shortcuts are disabled.

Change-Id: Iccc2ae5ecb6e87e3cf71dca260e840a995b474ae
diff --git a/polygerrit-ui/app/elements/diff/gr-selection-action-box/gr-selection-action-box.ts b/polygerrit-ui/app/elements/diff/gr-selection-action-box/gr-selection-action-box.ts
index ee52ab6..f38824f 100644
--- a/polygerrit-ui/app/elements/diff/gr-selection-action-box/gr-selection-action-box.ts
+++ b/polygerrit-ui/app/elements/diff/gr-selection-action-box/gr-selection-action-box.ts
@@ -23,6 +23,7 @@
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-selection-action-box_html';
 import {fireEvent} from '../../../utils/event-util';
+import {appContext} from '../../../services/app-context';
 
 declare global {
   interface HTMLElementTagNameMap {
@@ -56,6 +57,11 @@
   @property({type: Boolean})
   positionBelow = false;
 
+  @property({type: Boolean})
+  disableKeyboardShortcuts = false;
+
+  private restApiService = appContext.restApiService;
+
   /** @override */
   created() {
     super.created();
@@ -64,6 +70,18 @@
     this.addEventListener('mousedown', e => this._handleMouseDown(e));
   }
 
+  attached() {
+    this.restApiService.getPreferences().then(prefs => {
+      if (prefs?.disable_keyboard_shortcuts) {
+        this.disableKeyboardShortcuts = true;
+      }
+    });
+  }
+
+  _getTextForTooltip(disableKeyboardShortcuts: boolean) {
+    return disableKeyboardShortcuts ? 'Click to comment' : 'Press c to comment';
+  }
+
   placeAbove(el: Text | Element | Range) {
     flush();
     const rect = this._getTargetBoundingRect(el);
diff --git a/polygerrit-ui/app/elements/diff/gr-selection-action-box/gr-selection-action-box_html.ts b/polygerrit-ui/app/elements/diff/gr-selection-action-box/gr-selection-action-box_html.ts
index 24d63b3..d293967 100644
--- a/polygerrit-ui/app/elements/diff/gr-selection-action-box/gr-selection-action-box_html.ts
+++ b/polygerrit-ui/app/elements/diff/gr-selection-action-box/gr-selection-action-box_html.ts
@@ -27,7 +27,7 @@
   </style>
   <gr-tooltip
     id="tooltip"
-    text="Press c to comment"
+    text="[[_getTextForTooltip(disableKeyboardShortcuts)]]"
     position-below="[[positionBelow]]"
   ></gr-tooltip>
 `;