@@ -2,7 +2,6 @@ import * as Ariakit from "@ariakit/react";
22import type { RuntimeEnvironment } from "@trigger.dev/database" ;
33import type { ReactNode } from "react" ;
44import { startTransition , useCallback , useMemo , useState } from "react" ;
5- import { EnvironmentLabel , environmentTitle } from "~/components/environments/EnvironmentLabel" ;
65import { AppliedFilter } from "~/components/primitives/AppliedFilter" ;
76import { DateField } from "~/components/primitives/DateField" ;
87import { DateTime } from "~/components/primitives/DateTime" ;
@@ -14,7 +13,6 @@ import {
1413 SelectList ,
1514 SelectPopover ,
1615 SelectProvider ,
17- shortcutFromIndex ,
1816} from "~/components/primitives/Select" ;
1917import { useSearchParams } from "~/hooks/useSearchParam" ;
2018import { Button } from "../../primitives/Buttons" ;
@@ -51,102 +49,6 @@ export function FilterMenuProvider({
5149 ) ;
5250}
5351
54- export function EnvironmentsDropdown ( {
55- trigger,
56- clearSearchValue,
57- searchValue,
58- onClose,
59- possibleEnvironments,
60- } : {
61- trigger : ReactNode ;
62- clearSearchValue : ( ) => void ;
63- searchValue : string ;
64- onClose ?: ( ) => void ;
65- possibleEnvironments : DisplayableEnvironment [ ] ;
66- } ) {
67- const { values, replace } = useSearchParams ( ) ;
68-
69- const handleChange = ( values : string [ ] ) => {
70- clearSearchValue ( ) ;
71- replace ( { environments : values , cursor : undefined , direction : undefined } ) ;
72- } ;
73-
74- const filtered = useMemo ( ( ) => {
75- return possibleEnvironments . filter ( ( item ) => {
76- const title = environmentTitle ( item , item . userName ) ;
77- return title . toLowerCase ( ) . includes ( searchValue . toLowerCase ( ) ) ;
78- } ) ;
79- } , [ searchValue , possibleEnvironments ] ) ;
80-
81- return (
82- < SelectProvider value = { values ( "environments" ) } setValue = { handleChange } virtualFocus = { true } >
83- { trigger }
84- < SelectPopover
85- className = "min-w-0 max-w-[min(240px,var(--popover-available-width))]"
86- hideOnEscape = { ( ) => {
87- if ( onClose ) {
88- onClose ( ) ;
89- return false ;
90- }
91-
92- return true ;
93- } }
94- >
95- < ComboBox placeholder = { "Filter by environment..." } value = { searchValue } />
96- < SelectList >
97- { filtered . map ( ( item , index ) => (
98- < SelectItem
99- key = { item . id }
100- value = { item . id }
101- shortcut = { shortcutFromIndex ( index , { shortcutsEnabled : true } ) }
102- >
103- < EnvironmentLabel environment = { item } />
104- </ SelectItem >
105- ) ) }
106- </ SelectList >
107- </ SelectPopover >
108- </ SelectProvider >
109- ) ;
110- }
111-
112- export function AppliedEnvironmentFilter ( {
113- possibleEnvironments,
114- } : {
115- possibleEnvironments : DisplayableEnvironment [ ] ;
116- } ) {
117- const { values, del } = useSearchParams ( ) ;
118-
119- if ( values ( "environments" ) . length === 0 ) {
120- return null ;
121- }
122-
123- return (
124- < FilterMenuProvider >
125- { ( search , setSearch ) => (
126- < EnvironmentsDropdown
127- trigger = {
128- < Ariakit . Select render = { < div className = "group cursor-pointer focus-custom" /> } >
129- < AppliedFilter
130- label = "Environment"
131- value = { appliedSummary (
132- values ( "environments" ) . map ( ( v ) => {
133- const environment = possibleEnvironments . find ( ( env ) => env . id === v ) ;
134- return environment ? environmentTitle ( environment , environment . userName ) : v ;
135- } )
136- ) }
137- onRemove = { ( ) => del ( [ "environments" , "cursor" , "direction" ] ) }
138- />
139- </ Ariakit . Select >
140- }
141- searchValue = { search }
142- clearSearchValue = { ( ) => setSearch ( "" ) }
143- possibleEnvironments = { possibleEnvironments }
144- />
145- ) }
146- </ FilterMenuProvider >
147- ) ;
148- }
149-
15052const timePeriods = [
15153 {
15254 label : "Last 5 mins" ,
0 commit comments