@@ -37,6 +37,7 @@ import {
3737 type QueryWidgetData ,
3838} from "~/components/metrics/QueryWidget" ;
3939import { SaveToDashboardDialog } from "~/components/metrics/SaveToDashboardDialog" ;
40+ import { ScopeFilter } from "~/components/metrics/ScopeFilter" ;
4041import { Button , LinkButton } from "~/components/primitives/Buttons" ;
4142import { Callout } from "~/components/primitives/Callout" ;
4243import {
@@ -89,12 +90,6 @@ function toISOString(value: Date | string): string {
8990 return value . toISOString ( ) ;
9091}
9192
92- const scopeOptions = [
93- { value : "environment" , label : "Environment" } ,
94- { value : "project" , label : "Project" } ,
95- { value : "organization" , label : "Organization" } ,
96- ] as const ;
97-
9893// Type for the query action response
9994type QueryActionResponse = {
10095 error : string | null ;
@@ -277,7 +272,7 @@ const QueryEditorForm = forwardRef<
277272 < input type = "hidden" name = "from" value = { from ?? "" } />
278273 < input type = "hidden" name = "to" value = { to ?? "" } />
279274 < QueryHistoryPopover history = { history } onQuerySelected = { handleHistorySelected } />
280- < div className = "flex items-center gap-1" >
275+ < div className = "flex items-center gap-1.5 " >
281276 { isAdmin && (
282277 < Button
283278 type = "submit"
@@ -289,24 +284,11 @@ const QueryEditorForm = forwardRef<
289284 Explain
290285 </ Button >
291286 ) }
292- < Select
287+ < ScopeFilter
293288 value = { scope }
294- setValue = { ( value ) => setScope ( value as QueryScope ) }
295- variant = "secondary/small"
296- dropdownIcon = { true }
297- items = { [ ...scopeOptions ] }
298- text = { ( value ) => {
299- return < ScopeItem scope = { value as QueryScope } /> ;
300- } }
301- >
302- { ( items ) =>
303- items . map ( ( item ) => (
304- < SelectItem key = { item . value } value = { item . value } >
305- < ScopeItem scope = { item . value as QueryScope } />
306- </ SelectItem >
307- ) )
308- }
309- </ Select >
289+ onValueChange = { setScope }
290+ shortcut = { { key : "e" } }
291+ />
310292 { queryHasTriggeredAt ? (
311293 < SimpleTooltip
312294 asChild
@@ -335,6 +317,7 @@ const QueryEditorForm = forwardRef<
335317 period = { period }
336318 from = { from }
337319 to = { to }
320+ shortcut = { { key : "d" } }
338321 applyShortcut = { { key : "enter" , enabledOnInputElements : true } }
339322 onValueChange = { ( values ) => {
340323 flushSync ( ( ) => {
@@ -1133,27 +1116,6 @@ function ExportResultsButton({
11331116 ) ;
11341117}
11351118
1136- function ScopeItem ( { scope } : { scope : QueryScope } ) {
1137- const organization = useOrganization ( ) ;
1138- const project = useProject ( ) ;
1139- const environment = useEnvironment ( ) ;
1140-
1141- switch ( scope ) {
1142- case "organization" :
1143- return < span className = "text-text-bright" > { `Org: ${ organization . title } ` } </ span > ;
1144- case "project" :
1145- return < span className = "text-text-bright" > { `Project: ${ project . name } ` } </ span > ;
1146- case "environment" :
1147- return (
1148- < span className = "text-text-bright" >
1149- Env: < EnvironmentLabel environment = { environment } />
1150- </ span >
1151- ) ;
1152- default :
1153- return < span className = "text-text-bright" > { scope } </ span > ;
1154- }
1155- }
1156-
11571119function QueryResultsCallouts ( {
11581120 hiddenColumns,
11591121 periodClipped,
0 commit comments