diff --git a/frontend/public/locales/en/titles.json b/frontend/public/locales/en/titles.json index 2c5d2bd887..82fad7f472 100644 --- a/frontend/public/locales/en/titles.json +++ b/frontend/public/locales/en/titles.json @@ -41,5 +41,6 @@ "SUPPORT": "SigNoz | Support", "LOGS_SAVE_VIEWS": "SigNoz | Logs Save Views", "TRACES_SAVE_VIEWS": "SigNoz | Traces Save Views", - "DEFAULT": "Open source Observability Platform | SigNoz" + "DEFAULT": "Open source Observability Platform | SigNoz", + "SHORTCUTS": "SigNoz | Shortcuts" } diff --git a/frontend/src/AppRoutes/pageComponents.ts b/frontend/src/AppRoutes/pageComponents.ts index 749a9ebfe7..0a2e0e59f2 100644 --- a/frontend/src/AppRoutes/pageComponents.ts +++ b/frontend/src/AppRoutes/pageComponents.ts @@ -182,3 +182,7 @@ export const WorkspaceBlocked = Loadable( () => import(/* webpackChunkName: "WorkspaceLocked" */ 'pages/WorkspaceLocked'), ); + +export const ShortcutsPage = Loadable( + () => import(/* webpackChunkName: "ShortcutsPage" */ 'pages/Shortcuts'), +); diff --git a/frontend/src/AppRoutes/routes.ts b/frontend/src/AppRoutes/routes.ts index dbf7c2a35f..e9d202c420 100644 --- a/frontend/src/AppRoutes/routes.ts +++ b/frontend/src/AppRoutes/routes.ts @@ -1,4 +1,5 @@ import ROUTES from 'constants/routes'; +import Shortcuts from 'pages/Shortcuts/Shortcuts'; import WorkspaceBlocked from 'pages/WorkspaceLocked'; import { RouteProps } from 'react-router-dom'; @@ -319,6 +320,13 @@ const routes: AppRoutes[] = [ isPrivate: true, key: 'WORKSPACE_LOCKED', }, + { + path: ROUTES.SHORTCUTS, + exact: true, + component: Shortcuts, + isPrivate: true, + key: 'SHORTCUTS', + }, ]; export const SUPPORT_ROUTE: AppRoutes = { diff --git a/frontend/src/constants/routes.ts b/frontend/src/constants/routes.ts index 71179a0df9..0dae80950d 100644 --- a/frontend/src/constants/routes.ts +++ b/frontend/src/constants/routes.ts @@ -44,6 +44,7 @@ const ROUTES = { LOGS_SAVE_VIEWS: '/logs-save-views', TRACES_SAVE_VIEWS: '/traces-save-views', WORKSPACE_LOCKED: '/workspace-locked', + SHORTCUTS: '/shortcuts', } as const; export default ROUTES; diff --git a/frontend/src/constants/shortcuts/globalShortcuts.ts b/frontend/src/constants/shortcuts/globalShortcuts.ts index 0a439cee77..d4d5536b5a 100644 --- a/frontend/src/constants/shortcuts/globalShortcuts.ts +++ b/frontend/src/constants/shortcuts/globalShortcuts.ts @@ -1,3 +1,19 @@ export const GlobalShortcuts = { SidebarCollapse: '\\+meta', + NavigateToServices: 's+shift', + NavigateToTraces: 't+shift', + NavigateToLogs: 'l+shift', + NavigateToDashboards: 'd+shift', + NavigateToAlerts: 'a+shift', + NavigateToExceptions: 'e+shift', +}; + +export const GlobalShortcutsDescription = { + SidebarCollapse: 'Collpase the sidebar', + NavigateToServices: 'Navigate to Services page', + NavigateToTraces: 'Navigate to Traces page', + NavigateToLogs: 'Navigate to logs page', + NavigateToDashboards: 'Navigate to dashboards page', + NavigateToAlerts: 'Navigate to alerts page', + NavigateToExceptions: 'Navigate to Exceptions page', }; diff --git a/frontend/src/constants/shortcuts/logsExplorerShortcuts.ts b/frontend/src/constants/shortcuts/logsExplorerShortcuts.ts new file mode 100644 index 0000000000..a9c22be550 --- /dev/null +++ b/frontend/src/constants/shortcuts/logsExplorerShortcuts.ts @@ -0,0 +1,9 @@ +export const LogsExplorerShortcuts = { + StageAndRunQuery: 'enter+meta', + FocusTheSearchBar: 's', +}; + +export const LogsExplorerShortcutsDescription = { + StageAndRunQuery: 'Stage and Run the current query', + FocusTheSearchBar: 'Shift the focus to the filter bar', +}; diff --git a/frontend/src/container/QueryBuilder/components/ToolbarActions/RightToolbarActions.tsx b/frontend/src/container/QueryBuilder/components/ToolbarActions/RightToolbarActions.tsx index 64cabf1615..aea205d569 100644 --- a/frontend/src/container/QueryBuilder/components/ToolbarActions/RightToolbarActions.tsx +++ b/frontend/src/container/QueryBuilder/components/ToolbarActions/RightToolbarActions.tsx @@ -1,7 +1,10 @@ import './ToolbarActions.styles.scss'; import { Button } from 'antd'; +import { LogsExplorerShortcuts } from 'constants/shortcuts/logsExplorerShortcuts'; +import { useKeyboardHotkeys } from 'hooks/hotkeys/useKeyboardHotkeys'; import { Play } from 'lucide-react'; +import { useEffect } from 'react'; interface RightToolbarActionsProps { onStageRunQuery: () => void; @@ -10,6 +13,16 @@ interface RightToolbarActionsProps { export default function RightToolbarActions({ onStageRunQuery, }: RightToolbarActionsProps): JSX.Element { + const { registerShortcut, deregisterShortcut } = useKeyboardHotkeys(); + + useEffect(() => { + registerShortcut(LogsExplorerShortcuts.StageAndRunQuery, onStageRunQuery); + + return (): void => { + deregisterShortcut(LogsExplorerShortcuts.StageAndRunQuery); + }; + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [onStageRunQuery]); return (