Open-Source API Development Ecosystem • https://hoppscotch.io • Offline, On-Prem & Cloud • Web, Desktop & CLI • Open-Source Alternative to Postman, Insomnia
TypeScript apiapi-clientapi-restapi-testingdeveloper-toolsgraphqlhttphttp-clientpwarestrest-apispatestingtesting-toolstoolsvuevuejswebsocket
feat(desktop): tab shortcuts discoverability (#5229)
Shreyas5a79c3ba2aac
diff --git a/packages/hoppscotch-common/locales/en.json b/packages/hoppscotch-common/locales/en.jsonindex 885357adf..ee67abf91 100644--- a/packages/hoppscotch-common/locales/en.json+++ b/packages/hoppscotch-common/locales/en.json@@ -1114,6 +1114,16 @@"download": "Download response as file","title": "Response"},+ "tabs": {+ "title": "Tabs",+ "new_tab": "New Tab",+ "close_tab": "Close Tab",+ "reopen_tab": "Reopen Closed Tab",+ "next_tab": "Next Tab",+ "previous_tab": "Previous Tab",+ "first_tab": "Switch to First Tab",+ "last_tab": "Switch to Last Tab"+ },"theme": {"black": "Switch theme to Black Mode","dark": "Switch theme to Dark Mode",diff --git a/packages/hoppscotch-common/src/helpers/shortcuts.ts b/packages/hoppscotch-common/src/helpers/shortcuts.tsindex 573cb2a61..35ab8a2f5 100644--- a/packages/hoppscotch-common/src/helpers/shortcuts.ts+++ b/packages/hoppscotch-common/src/helpers/shortcuts.ts@@ -1,4 +1,5 @@import { getPlatformAlternateKey, getPlatformSpecialKey } from "./platformutils"+import { getKernelMode } from "@hoppscotch/kernel"export type ShortcutDef = {label: string@@ -7,8 +8,11 @@ export type ShortcutDef = {}export function getShortcuts(t: (x: string) => string): ShortcutDef[] {- // General- return [+ const kernelMode = getKernelMode()+ const isDesktop = kernelMode === "desktop"++ const baseShortcuts: ShortcutDef[] = [+ // General{label: t("shortcut.general.help_menu"),keys: ["?"],@@ -143,4 +147,41 @@ export function getShortcuts(t: (x: string) => string): ShortcutDef[] {section: t("shortcut.miscellaneous.title"),},]++ // Desktop-only shortcuts+ const desktopShortcuts: ShortcutDef[] = [+ {+ keys: [getPlatformSpecialKey(), "T"],+ label: t("shortcut.tabs.new_tab"),+ section: t("shortcut.tabs.title"),+ },+ {+ keys: [getPlatformSpecialKey(), "W"],+ label: t("shortcut.tabs.close_tab"),+ section: t("shortcut.tabs.title"),+ },+ {+ keys: [getPlatformSpecialKey(), getPlatformAlternateKey(), "→"],+ label: t("shortcut.tabs.next_tab"),+ section: t("shortcut.tabs.title"),+ },+ {+ keys: [getPlatformSpecialKey(), getPlatformAlternateKey(), "←"],+ label: t("shortcut.tabs.previous_tab"),+ section: t("shortcut.tabs.title"),+ },+ {+ keys: [getPlatformSpecialKey(), getPlatformAlternateKey(), "9"],+ label: t("shortcut.tabs.first_tab"),+ section: t("shortcut.tabs.title"),+ },+ {+ keys: [getPlatformSpecialKey(), getPlatformAlternateKey(), "0"],+ label: t("shortcut.tabs.last_tab"),+ section: t("shortcut.tabs.title"),+ },+ ]++ // Return base shortcuts + desktop shortcuts only if in desktop mode+ return isDesktop ? [...baseShortcuts, ...desktopShortcuts] : baseShortcuts}