From c3314dd186855070c800be1cbc07add48777a31c Mon Sep 17 00:00:00 2001 From: Sivin Varghese <64252451+iamsivin@users.noreply.github.com> Date: Tue, 10 Aug 2021 09:53:40 +0530 Subject: [PATCH] feat: Creates a modal showing all the available keyboard shortcuts (#2728) * feat: Adds modal showing all the available keyboard shortcuts * Minor fixes * Minor fixes * Spacing fixes * fix translations * Adds i18n * Review fixes * Review fixes * spacing fixes * Review fixes * Minor fixes Co-authored-by: Muhsin Keloth --- .../components/buttons/ResolveAction.vue | 3 + .../dashboard/components/layout/Sidebar.vue | 26 ++- .../layout/sidebarComponents/OptionsMenu.vue | 10 + .../modal/WootKeyShortcutModal.stories.js | 17 ++ .../widgets/modal/WootKeyShortcutModal.vue | 182 ++++++++++++++++++ .../components/widgets/modal/constants.js | 86 +++++++++ .../dashboard/i18n/locale/en/settings.json | 26 +++ .../shared/helpers/KeyboardHelpers.js | 4 + 8 files changed, 353 insertions(+), 1 deletion(-) create mode 100644 app/javascript/dashboard/components/widgets/modal/WootKeyShortcutModal.stories.js create mode 100644 app/javascript/dashboard/components/widgets/modal/WootKeyShortcutModal.vue create mode 100644 app/javascript/dashboard/components/widgets/modal/constants.js diff --git a/app/javascript/dashboard/components/buttons/ResolveAction.vue b/app/javascript/dashboard/components/buttons/ResolveAction.vue index e7219cdf0..819ca9097 100644 --- a/app/javascript/dashboard/components/buttons/ResolveAction.vue +++ b/app/javascript/dashboard/components/buttons/ResolveAction.vue @@ -175,6 +175,9 @@ export default { const allConversations = document.querySelectorAll( '.conversations-list .conversation' ); + if (hasPressedAltAndMKey(e)) { + this.$refs.arrowDownButton.$el.click(); + } if (hasPressedAltAndEKey(e)) { const activeConversation = document.querySelector( 'div.conversations-list div.conversation.active' diff --git a/app/javascript/dashboard/components/layout/Sidebar.vue b/app/javascript/dashboard/components/layout/Sidebar.vue index 61405f6cd..5db8e704d 100644 --- a/app/javascript/dashboard/components/layout/Sidebar.vue +++ b/app/javascript/dashboard/components/layout/Sidebar.vue @@ -50,10 +50,17 @@ :show="showOptionsMenu" @toggle-accounts="toggleAccountModal" @show-support-chat-window="toggleSupportChatWindow" + @key-shortcut-modal="toggleKeyShortcutModal" @close="toggleOptions" /> + + + + + {{ $t('SIDEBAR_ITEMS.KEYBOARD_SHORTCUTS') }} + + ({ + props: Object.keys(argTypes), + components: { WootKeyboardShortcutModal }, + template: + '', +}); + +export const KeyboardShortcut = Template.bind({}); +KeyboardShortcut.args = {}; diff --git a/app/javascript/dashboard/components/widgets/modal/WootKeyShortcutModal.vue b/app/javascript/dashboard/components/widgets/modal/WootKeyShortcutModal.vue new file mode 100644 index 000000000..fb4bef960 --- /dev/null +++ b/app/javascript/dashboard/components/widgets/modal/WootKeyShortcutModal.vue @@ -0,0 +1,182 @@ + + + + + diff --git a/app/javascript/dashboard/components/widgets/modal/constants.js b/app/javascript/dashboard/components/widgets/modal/constants.js new file mode 100644 index 000000000..faec60dc1 --- /dev/null +++ b/app/javascript/dashboard/components/widgets/modal/constants.js @@ -0,0 +1,86 @@ +export const SHORTCUT_KEYS = [ + { + id: 1, + label: 'NAVIGATE_DROPDOWN', + firstkey: 'Up', + secondKey: 'Down', + }, + { + id: 2, + label: 'RESOLVE_CONVERSATION', + firstkey: 'Alt / ⌥', + secondKey: 'E', + }, + { + id: 3, + label: 'GO_TO_CONVERSATION_DASHBOARD', + firstkey: 'Alt / ⌥', + secondKey: 'C', + }, + { + id: 4, + label: 'ADD_ATTACHMENT', + firstkey: 'Alt / ⌥', + secondKey: 'A', + }, + { + id: 5, + label: 'GO_TO_CONTACTS_DASHBOARD', + firstkey: 'Alt / ⌥', + secondKey: 'V', + }, + { + id: 6, + label: 'TOGGLE_SIDEBAR', + firstkey: 'Alt / ⌥', + secondKey: 'O', + }, + { + id: 7, + label: 'GO_TO_REPORTS_SIDEBAR', + firstkey: 'Alt / ⌥', + secondKey: 'R', + }, + { + id: 8, + label: 'MOVE_TO_NEXT_TAB', + firstkey: 'Alt / ⌥', + secondKey: 'N', + }, + { + id: 9, + label: 'GO_TO_SETTINGS', + firstkey: 'Alt / ⌥', + secondKey: 'S', + }, + { + id: 10, + label: 'SWITCH_CONVERSATION_STATUS', + firstkey: 'Alt / ⌥', + secondKey: 'B', + }, + { + id: 11, + label: 'SWITCH_TO_PRIVATE_NOTE', + firstkey: 'Alt / ⌥', + secondKey: 'P', + }, + { + id: 12, + label: 'TOGGLE_RICH_CONTENT_EDITOR', + firstkey: 'Alt / ⌥', + secondKey: 'W', + }, + { + id: 13, + label: 'SWITCH_TO_REPLY', + firstkey: 'Alt / ⌥', + secondKey: 'L', + }, + { + id: 14, + label: 'TOGGLE_SNOOZE_DROPDOWN', + firstkey: 'Alt / ⌥', + secondKey: 'M', + }, +]; diff --git a/app/javascript/dashboard/i18n/locale/en/settings.json b/app/javascript/dashboard/i18n/locale/en/settings.json index a5405bd63..34ce3e4d4 100644 --- a/app/javascript/dashboard/i18n/locale/en/settings.json +++ b/app/javascript/dashboard/i18n/locale/en/settings.json @@ -98,6 +98,7 @@ "CHANGE_ACCOUNTS": "Switch Account", "SELECTOR_SUBTITLE": "Select an account from the following list", "PROFILE_SETTINGS": "Profile Settings", + "KEYBOARD_SHORTCUTS": "Keyboard Shortcuts", "LOGOUT": "Logout" }, "APP_GLOBAL": { @@ -159,5 +160,30 @@ }, "SUBMIT": "Submit" } + }, + "KEYBOARD_SHORTCUTS": { + "TITLE": { + "OPEN_CONVERSATION": "Open conversation", + "RESOLVE_AND_NEXT": "Resolve and move to next", + "NAVIGATE_DROPDOWN": "Navigate dropdown items", + "RESOLVE_CONVERSATION": "Resolve Conversation", + "GO_TO_CONVERSATION_DASHBOARD": "Go to Conversation Dashboard", + "ADD_ATTACHMENT": "Add Attachment", + "GO_TO_CONTACTS_DASHBOARD": "Go to Contacts Dashboard", + "TOGGLE_SIDEBAR": "Toggle Sidebar", + "GO_TO_REPORTS_SIDEBAR": "Go to Reports sidebar", + "MOVE_TO_NEXT_TAB": "Move to next tab in conversation list", + "GO_TO_SETTINGS": "Go to Settings", + "SWITCH_CONVERSATION_STATUS": "Switch Conversation status", + "SWITCH_TO_PRIVATE_NOTE": "Switch to Private Note", + "TOGGLE_RICH_CONTENT_EDITOR": "Toggle Rich Content editor", + "SWITCH_TO_REPLY": "Switch to Reply", + "TOGGLE_SNOOZE_DROPDOWN": "Toggle snooze dropdown" + }, + "KEYS": { + "COMMAND_KEY": "⌘", + "ALT_OR_OPTION_KEY": "Alt / ⌥", + "FORWARD_SLASH_KEY": "/" + } } } diff --git a/app/javascript/shared/helpers/KeyboardHelpers.js b/app/javascript/shared/helpers/KeyboardHelpers.js index 6671eaff6..f5ff556c6 100644 --- a/app/javascript/shared/helpers/KeyboardHelpers.js +++ b/app/javascript/shared/helpers/KeyboardHelpers.js @@ -10,6 +10,10 @@ export const hasPressedShift = e => { return e.shiftKey; }; +export const hasPressedCommandAndForwardSlash = e => { + return e.metaKey && e.keyCode === 191; +}; + export const hasPressedAltAndCKey = e => { return e.altKey && e.keyCode === 67; };