11import React from 'react' ;
22import { useState } from 'react' ;
3- import { Collection , ComboBox , Dialog , Header , Input , Label , ListBox , ListBoxItem , Modal , ModalOverlay , Section , Text } from 'react-aria-components' ;
3+ import { Button , Collection , ComboBox , Dialog , DialogTrigger , Header , Input , Keyboard , Label , ListBox , ListBoxItem , Modal , ModalOverlay , Section , Text } from 'react-aria-components' ;
44import { useNavigate , useParams , useRouteLoaderData } from 'react-router-dom' ;
55
6+ import { constructKeyCombinationDisplay , getPlatformKeyCombinations } from '../../common/hotkeys' ;
67import { fuzzyMatch } from '../../common/misc' ;
78import { isGrpcRequest } from '../../models/grpc-request' ;
89import { isRequest } from '../../models/request' ;
910import { isRequestGroup } from '../../models/request-group' ;
1011import { isWebSocketRequest } from '../../models/websocket-request' ;
1112import { Workspace } from '../../models/workspace' ;
1213import { ProjectLoaderData } from '../routes/project' ;
14+ import { RootLoaderData } from '../routes/root' ;
1315import { Collection as WorkspaceCollection , WorkspaceLoaderData } from '../routes/workspace' ;
1416import { Icon } from './icon' ;
1517import { useDocBodyKeyboardShortcuts } from './keydown-binder' ;
@@ -25,7 +27,7 @@ export const CommandPalette = () => {
2527 } = useParams ( ) ;
2628 const workspaceData = useRouteLoaderData ( ':workspaceId' ) as WorkspaceLoaderData | undefined ;
2729 const projectData = useRouteLoaderData ( '/project/:projectId' ) as ProjectLoaderData | undefined ;
28-
30+ const { settings } = useRouteLoaderData ( 'root' ) as RootLoaderData ;
2931 let collection : WorkspaceCollection = [ ] ;
3032 let workspaces : Workspace [ ] = [ ] ;
3133 if ( workspaceData ) {
@@ -42,8 +44,18 @@ export const CommandPalette = () => {
4244 } ,
4345 } ) ;
4446
47+ const requestSwitchKeyCombination = getPlatformKeyCombinations ( settings . hotKeyRegistry . request_quickSwitch ) [ 0 ] ;
48+
4549 return (
46- < ModalOverlay isOpen = { isOpen } onOpenChange = { setIsOpen } isDismissable className = "w-full h-[--visual-viewport-height] fixed z-10 top-0 left-0 flex pt-20 justify-center bg-black/30" >
50+ < DialogTrigger onOpenChange = { setIsOpen } isOpen = { isOpen } >
51+ < Button data-testid = 'quick-search' className = "px-4 py-1 h-[30.5px] flex-shrink-0 flex items-center justify-center gap-2 bg-[--hl-xs] aria-pressed:bg-[--hl-sm] data-[pressed]:bg-[--hl-sm] rounded-md text-[--color-font] hover:bg-[--hl-xs] ring-inset ring-transparent ring-1 focus:ring-[--hl-md] transition-all text-sm" >
52+ < Icon icon = "search" />
53+ Search..
54+ { requestSwitchKeyCombination && < Keyboard className = 'space-x-0.5 items-center font-sans font-normal text-center text-sm shadow-sm bg-[--hl-xs] text-[--hl] rounded-md py-0.5 px-2 inline-block' >
55+ { constructKeyCombinationDisplay ( requestSwitchKeyCombination , false ) }
56+ </ Keyboard > }
57+ </ Button >
58+ < ModalOverlay isDismissable className = "w-full h-[--visual-viewport-height] fixed z-10 top-0 left-0 flex pt-20 justify-center bg-black/30" >
4759 < Modal className = "max-w-2xl h-max w-full rounded-md flex flex-col overflow-hidden border border-solid border-[--hl-sm] max-h-[80vh] bg-[--color-bg] text-[--color-font]" >
4860 < Dialog className = "outline-none h-max overflow-hidden flex flex-col" >
4961 { ( { close } ) => (
@@ -159,5 +171,6 @@ export const CommandPalette = () => {
159171 </ Dialog >
160172 </ Modal >
161173 </ ModalOverlay >
174+ </ DialogTrigger >
162175 ) ;
163176} ;
0 commit comments