diff --git a/app/assets/javascripts/behaviors/shortcuts/keybindings.js b/app/assets/javascripts/behaviors/shortcuts/keybindings.js index a001bfe67a4fec6c6b00c36b17674962cbd21e04..13b7636c142c251ad9c525750a47e8c0317084e9 100644 --- a/app/assets/javascripts/behaviors/shortcuts/keybindings.js +++ b/app/assets/javascripts/behaviors/shortcuts/keybindings.js @@ -138,6 +138,12 @@ export const DUO_CHAT = { defaultKeys: ['d'], }; +export const GO_TO_HOMEPAGE = { + id: 'globalShortcuts.goToHomepage', + description: __('Go to homepage'), + defaultKeys: ['shift+h'], +}; + export const BOLD_TEXT = { id: 'editing.boldText', description: __('Bold text'), @@ -622,6 +628,7 @@ const GLOBAL_SHORTCUTS_GROUP = { name: __('Global Shortcuts'), keybindings: [ TOGGLE_KEYBOARD_SHORTCUTS_DIALOG, + GO_TO_HOMEPAGE, GO_TO_YOUR_PROJECTS, GO_TO_YOUR_GROUPS, GO_TO_ACTIVITY_FEED, diff --git a/app/assets/javascripts/behaviors/shortcuts/shortcuts.js b/app/assets/javascripts/behaviors/shortcuts/shortcuts.js index f0666da0261d761196807889cd8eb4df1ac0e75d..0a6ad60a3c2b04d9d020c3e709c362844e70df9f 100644 --- a/app/assets/javascripts/behaviors/shortcuts/shortcuts.js +++ b/app/assets/javascripts/behaviors/shortcuts/shortcuts.js @@ -19,6 +19,7 @@ import { TOGGLE_CANARY, TOGGLE_MARKDOWN_PREVIEW, FIND_AND_REPLACE, + GO_TO_HOMEPAGE, GO_TO_YOUR_TODO_LIST, GO_TO_ACTIVITY_FEED, GO_TO_YOUR_ISSUES, @@ -86,6 +87,7 @@ export default class Shortcuts { [HIDE_APPEARING_CONTENT, Shortcuts.hideAppearingContent], [TOGGLE_CANARY, Shortcuts.onToggleCanary], + [GO_TO_HOMEPAGE, () => findAndFollowLink('.brand-logo')], [GO_TO_YOUR_TODO_LIST, () => findAndFollowLink('.shortcuts-todos')], [GO_TO_ACTIVITY_FEED, () => findAndFollowLink('.dashboard-shortcuts-activity')], [GO_TO_YOUR_ISSUES, () => findAndFollowLink('.dashboard-shortcuts-issues')], diff --git a/doc/user/shortcuts.md b/doc/user/shortcuts.md index 8d239d5bd8fe75b2ca69b36e4fec589220938c0d..c110a1def8d7c2d3014f954432cafc71bc449a26 100644 --- a/doc/user/shortcuts.md +++ b/doc/user/shortcuts.md @@ -33,6 +33,7 @@ These shortcuts are available in most areas of GitLab: | Keyboard shortcut | Description | |------------------------------------|-------------| | ? | Show or hide the shortcut reference sheet. | +| Shift + h | Go to the homepage. | | Shift + p | Go to your **Projects** page. | | Shift + g | Go to your **Groups** page. | | Shift + a | Go to your **Activity** page. | diff --git a/locale/gitlab.pot b/locale/gitlab.pot index a5954aa0a5c12af24fd10cbf6ef7de2fd5ff43c9..a9f19599b42c240bd84c2bd885a507112ed6d9b1 100644 --- a/locale/gitlab.pot +++ b/locale/gitlab.pot @@ -30900,6 +30900,9 @@ msgstr "" msgid "Go to find file" msgstr "" +msgid "Go to homepage" +msgstr "" + msgid "Go to issue boards" msgstr "" diff --git a/spec/features/dashboard/shortcuts_spec.rb b/spec/features/dashboard/shortcuts_spec.rb index 6a4349fe40855c44c9b2566077f1087398437798..6066bd57d0180697d2959beb0a87bf4ecc98e291 100644 --- a/spec/features/dashboard/shortcuts_spec.rb +++ b/spec/features/dashboard/shortcuts_spec.rb @@ -51,6 +51,10 @@ find('body').send_keys([:shift, 'L']) check_page_title('Milestones') + + find('body').send_keys([:shift, 'H']) + + check_page_title('Projects') # This will need to change when we remove the `personal_homepage` feature flag end end diff --git a/spec/frontend/behaviors/shortcuts/keybindings_spec.js b/spec/frontend/behaviors/shortcuts/keybindings_spec.js index 2738339db2d5befd12a8c4abc7691b213707202f..d2445f63ea60a602691d4a496788d7536c4a10a2 100644 --- a/spec/frontend/behaviors/shortcuts/keybindings_spec.js +++ b/spec/frontend/behaviors/shortcuts/keybindings_spec.js @@ -8,6 +8,7 @@ import { HIDE_APPEARING_CONTENT, LOCAL_STORAGE_KEY, BOLD_TEXT, + GO_TO_HOMEPAGE, } from '~/behaviors/shortcuts/keybindings'; describe('~/behaviors/shortcuts/keybindings', () => { @@ -121,4 +122,19 @@ describe('~/behaviors/shortcuts/keybindings', () => { expect(keysFor(HIDE_APPEARING_CONTENT)).toEqual(['esc']); }); }); + + describe('GO_TO_HOMEPAGE command', () => { + beforeEach(() => { + setupCustomizations(); + }); + + it('has the correct default keybinding', () => { + expect(keysFor(GO_TO_HOMEPAGE)).toEqual(['shift+h']); + }); + + it('is included in the global shortcuts group', () => { + const globalGroup = keybindingGroups.find((group) => group.id === 'globalShortcuts'); + expect(globalGroup.keybindings).toContain(GO_TO_HOMEPAGE); + }); + }); }); diff --git a/spec/frontend/behaviors/shortcuts/shortcuts_spec.js b/spec/frontend/behaviors/shortcuts/shortcuts_spec.js index cedbf22e43cd5343e951b537d4312869a7d954b7..c1b32ecc01f97611d79c9752967eac3c86709fb1 100644 --- a/spec/frontend/behaviors/shortcuts/shortcuts_spec.js +++ b/spec/frontend/behaviors/shortcuts/shortcuts_spec.js @@ -8,6 +8,8 @@ import Shortcuts, { LOCAL_MOUSETRAP_DATA_KEY } from '~/behaviors/shortcuts/short import MarkdownPreview from '~/behaviors/preview_markdown'; import { useMockInternalEventsTracking } from 'helpers/tracking_internal_events_helper'; +jest.mock('~/lib/utils/navigation_utility'); + const mockSearchInput = document.createElement('input'); jest.mock('~/lib/utils/dom_utils', () => ({