From e52e0f46355bbd8c43bfac90cf1f52c806852297 Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Mon, 22 Jan 2018 16:45:27 -0500 Subject: [PATCH] FIX: Disable the keyboard shortcut if private messages are disabled --- .../javascripts/discourse/lib/keyboard-shortcuts.js.es6 | 6 ++++++ .../discourse/templates/modal/keyboard-shortcuts-help.hbs | 4 +++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/discourse/lib/keyboard-shortcuts.js.es6 b/app/assets/javascripts/discourse/lib/keyboard-shortcuts.js.es6 index 3537ec1d975..367e6aa3048 100644 --- a/app/assets/javascripts/discourse/lib/keyboard-shortcuts.js.es6 +++ b/app/assets/javascripts/discourse/lib/keyboard-shortcuts.js.es6 @@ -68,6 +68,12 @@ export default { this.searchService = this.container.lookup('search-service:main'); this.appEvents = this.container.lookup('app-events:main'); this.currentUser = this.container.lookup('current-user:main'); + let siteSettings = this.container.lookup('site-settings:main'); + + // Disable the shortcut if private messages are disabled + if (!siteSettings.enable_private_messages) { + delete bindings['g m']; + } Object.keys(bindings).forEach(key => { const binding = bindings[key]; diff --git a/app/assets/javascripts/discourse/templates/modal/keyboard-shortcuts-help.hbs b/app/assets/javascripts/discourse/templates/modal/keyboard-shortcuts-help.hbs index c426e91d038..9dceda5cf87 100644 --- a/app/assets/javascripts/discourse/templates/modal/keyboard-shortcuts-help.hbs +++ b/app/assets/javascripts/discourse/templates/modal/keyboard-shortcuts-help.hbs @@ -11,7 +11,9 @@
  • {{{i18n 'keyboard_shortcuts_help.jump_to.top'}}}
  • {{{i18n 'keyboard_shortcuts_help.jump_to.bookmarks'}}}
  • {{{i18n 'keyboard_shortcuts_help.jump_to.profile'}}}
  • -
  • {{{i18n 'keyboard_shortcuts_help.jump_to.messages'}}}
  • + {{#if siteSettings.enable_private_messages}} +
  • {{{i18n 'keyboard_shortcuts_help.jump_to.messages'}}}
  • + {{/if}}

    {{i18n 'keyboard_shortcuts_help.navigation.title'}}