Revert "Suppress keyboard shortcuts if user has disabled them"
This reverts commit 3a609877f0db42d0fd5c5a4310afb15c66352e6c.
Reason for revert: adding restApiService dependency on keyboard-shortcut-mixin is breaking the build
Change-Id: I784c761641a80804cd969620e5d9d0fb02ba9bf1
diff --git a/polygerrit-ui/app/elements/core/gr-error-manager/gr-error-manager_test.js b/polygerrit-ui/app/elements/core/gr-error-manager/gr-error-manager_test.js
index 3f6148b..092daa2 100644
--- a/polygerrit-ui/app/elements/core/gr-error-manager/gr-error-manager_test.js
+++ b/polygerrit-ui/app/elements/core/gr-error-manager/gr-error-manager_test.js
@@ -21,7 +21,6 @@
import {__testOnly_ErrorType} from './gr-error-manager.js';
import {stubRestApi} from '../../../test/test-utils.js';
import {appContext} from '../../../services/app-context.js';
-import {createPreferences} from '../../../test/test-data-generators.js';
const basicFixture = fixtureFromElement('gr-error-manager');
@@ -41,8 +40,6 @@
.returns(Promise.resolve({ok: true, status: 204}));
getLoggedInStub = stubRestApi('getLoggedIn')
.callsFake(() => appContext.authService.authCheck());
- stubRestApi('getPreferences').returns(Promise.resolve(
- createPreferences()));
element = basicFixture.instantiate();
element._authService.clearCache();
toastSpy = sinon.spy(element, '_createToastAlert');
diff --git a/polygerrit-ui/app/elements/settings/gr-settings-view/gr-settings-view.ts b/polygerrit-ui/app/elements/settings/gr-settings-view/gr-settings-view.ts
index 3c00a47..809139d 100644
--- a/polygerrit-ui/app/elements/settings/gr-settings-view/gr-settings-view.ts
+++ b/polygerrit-ui/app/elements/settings/gr-settings-view/gr-settings-view.ts
@@ -76,7 +76,6 @@
'email_strategy',
'diff_view',
'publish_comments_on_push',
- 'disable_keyboard_shortcuts',
'work_in_progress_by_default',
'default_base_for_merges',
'signed_off_by',
@@ -115,7 +114,6 @@
workInProgressByDefault: HTMLInputElement;
showSizeBarsInFileList: HTMLInputElement;
publishCommentsOnPush: HTMLInputElement;
- disableKeyboardShortcuts: HTMLInputElement;
relativeDateInChangeTable: HTMLInputElement;
};
}
@@ -386,13 +384,6 @@
);
}
- _handleDisableKeyboardShortcutsChanged() {
- this.set(
- '_localPrefs.disable_keyboard_shortcuts',
- this.$.disableKeyboardShortcuts.checked
- );
- }
-
_handleWorkInProgressByDefault() {
this.set(
'_localPrefs.work_in_progress_by_default',
diff --git a/polygerrit-ui/app/elements/settings/gr-settings-view/gr-settings-view_html.ts b/polygerrit-ui/app/elements/settings/gr-settings-view/gr-settings-view_html.ts
index b141a86..11372a1 100644
--- a/polygerrit-ui/app/elements/settings/gr-settings-view/gr-settings-view_html.ts
+++ b/polygerrit-ui/app/elements/settings/gr-settings-view/gr-settings-view_html.ts
@@ -278,19 +278,6 @@
</span>
</section>
<section>
- <label for="disableKeyboardShortcuts" class="title"
- >Disable all keyboard shortcuts</label
- >
- <span class="value">
- <input
- id="disableKeyboardShortcuts"
- type="checkbox"
- checked$="[[_localPrefs.disable_keyboard_shortcuts]]"
- on-change="_handleDisableKeyboardShortcutsChanged"
- />
- </span>
- </section>
- <section>
<label for="insertSignedOff" class="title">
Insert Signed-off-by Footer For Inline Edit Changes
</label>
diff --git a/polygerrit-ui/app/mixins/keyboard-shortcut-mixin/keyboard-shortcut-mixin.ts b/polygerrit-ui/app/mixins/keyboard-shortcut-mixin/keyboard-shortcut-mixin.ts
index a907ddb..63a05aa 100644
--- a/polygerrit-ui/app/mixins/keyboard-shortcut-mixin/keyboard-shortcut-mixin.ts
+++ b/polygerrit-ui/app/mixins/keyboard-shortcut-mixin/keyboard-shortcut-mixin.ts
@@ -107,7 +107,6 @@
CustomKeyboardEvent,
ShortcutTriggeredEventDetail,
} from '../../types/events';
-import {appContext} from '../../services/app-context';
/** Enum for all special shortcuts */
export enum SPECIAL_SHORTCUT {
@@ -806,10 +805,6 @@
ShortcutSection = ShortcutSection;
- private _disableKeyboardShortcuts = false;
-
- private readonly restApiService = appContext.restApiService;
-
modifierPressed(event: CustomKeyboardEvent) {
/* We are checking for g/v as modifiers pressed. There are cases such as
* pressing v and then /, where we want the handler for / to be triggered.
@@ -831,7 +826,6 @@
}
shouldSuppressKeyboardShortcut(event: CustomKeyboardEvent) {
- if (this._disableKeyboardShortcuts) return true;
const e = getKeyboardEvent(event);
// TODO(TS): maybe override the EventApi, narrow it down to Element always
const target = (dom(e) as EventApi).rootTarget as Element;
@@ -932,13 +926,6 @@
/** @override */
connectedCallback() {
super.connectedCallback();
-
- this.restApiService.getPreferences().then(prefs => {
- if (prefs?.disable_keyboard_shortcuts) {
- this._disableKeyboardShortcuts = true;
- }
- });
-
const shortcuts = shortcutManager.attachHost(this);
if (!shortcuts) {
return;
diff --git a/polygerrit-ui/app/types/common.ts b/polygerrit-ui/app/types/common.ts
index cf7e37d..95801e7 100644
--- a/polygerrit-ui/app/types/common.ts
+++ b/polygerrit-ui/app/types/common.ts
@@ -1763,7 +1763,6 @@
email_strategy: EmailStrategy;
default_base_for_merges: DefaultBase;
publish_comments_on_push?: boolean;
- disable_keyboard_shortcuts?: boolean;
work_in_progress_by_default?: boolean;
// The email_format doesn't mentioned in doc, but exists in Java class GeneralPreferencesInfo
email_format?: EmailFormat;