@@ -249,11 +249,13 @@ export const LogsToolbar = memo(function LogsToolbar({
249249
250250 const statusOptions : ComboboxOption [ ] = useMemo (
251251 ( ) =>
252- ( Object . keys ( STATUS_CONFIG ) as LogStatus [ ] ) . map ( ( status ) => ( {
253- value : status ,
254- label : STATUS_CONFIG [ status ] . label ,
255- icon : getColorIcon ( STATUS_CONFIG [ status ] . color ) ,
256- } ) ) ,
252+ ( Object . keys ( STATUS_CONFIG ) as LogStatus [ ] )
253+ . filter ( ( status ) => STATUS_CONFIG [ status ] . filterable )
254+ . map ( ( status ) => ( {
255+ value : status ,
256+ label : STATUS_CONFIG [ status ] . label ,
257+ icon : getColorIcon ( STATUS_CONFIG [ status ] . color ) ,
258+ } ) ) ,
257259 [ ]
258260 )
259261
@@ -305,34 +307,29 @@ export const LogsToolbar = memo(function LogsToolbar({
305307 [ setTriggers , workspaceId ]
306308 )
307309
308- const statusDisplayLabel = useMemo ( ( ) => {
309- if ( selectedStatuses . length === 0 ) return 'Status'
310- if ( selectedStatuses . length === 1 ) {
311- const status = statusOptions . find ( ( s ) => s . value === selectedStatuses [ 0 ] )
312- return status ?. label || '1 selected'
313- }
314- return `${ selectedStatuses . length } selected`
315- } , [ selectedStatuses , statusOptions ] )
310+ const statusDisplayLabel =
311+ selectedStatuses . length === 0
312+ ? 'Status'
313+ : selectedStatuses . length === 1
314+ ? ( statusOptions . find ( ( s ) => s . value === selectedStatuses [ 0 ] ) ?. label ?? '1 selected' )
315+ : `${ selectedStatuses . length } selected`
316316
317- const selectedStatusColor = useMemo ( ( ) => {
318- if ( selectedStatuses . length !== 1 ) return null
319- const status = selectedStatuses [ 0 ] as LogStatus
320- return STATUS_CONFIG [ status ] ?. color ?? null
321- } , [ selectedStatuses ] )
317+ const selectedStatusColor =
318+ selectedStatuses . length === 1
319+ ? ( STATUS_CONFIG [ selectedStatuses [ 0 ] as LogStatus ] ?. color ?? null )
320+ : null
322321
323322 const workflowOptions : ComboboxOption [ ] = useMemo (
324323 ( ) => workflows . map ( ( w ) => ( { value : w . id , label : w . name , icon : getColorIcon ( w . color , true ) } ) ) ,
325324 [ workflows ]
326325 )
327326
328- const workflowDisplayLabel = useMemo ( ( ) => {
329- if ( workflowIds . length === 0 ) return 'Workflow'
330- if ( workflowIds . length === 1 ) {
331- const workflow = workflows . find ( ( w ) => w . id === workflowIds [ 0 ] )
332- return workflow ?. name || '1 selected'
333- }
334- return `${ workflowIds . length } workflows`
335- } , [ workflowIds , workflows ] )
327+ const workflowDisplayLabel =
328+ workflowIds . length === 0
329+ ? 'Workflow'
330+ : workflowIds . length === 1
331+ ? ( workflows . find ( ( w ) => w . id === workflowIds [ 0 ] ) ?. name ?? '1 selected' )
332+ : `${ workflowIds . length } workflows`
336333
337334 const selectedWorkflow =
338335 workflowIds . length === 1 ? workflows . find ( ( w ) => w . id === workflowIds [ 0 ] ) : null
@@ -342,14 +339,12 @@ export const LogsToolbar = memo(function LogsToolbar({
342339 [ folderList ]
343340 )
344341
345- const folderDisplayLabel = useMemo ( ( ) => {
346- if ( folderIds . length === 0 ) return 'Folder'
347- if ( folderIds . length === 1 ) {
348- const folder = folderList . find ( ( f ) => f . id === folderIds [ 0 ] )
349- return folder ?. name || '1 selected'
350- }
351- return `${ folderIds . length } folders`
352- } , [ folderIds , folderList ] )
342+ const folderDisplayLabel =
343+ folderIds . length === 0
344+ ? 'Folder'
345+ : folderIds . length === 1
346+ ? ( folderList . find ( ( f ) => f . id === folderIds [ 0 ] ) ?. name ?? '1 selected' )
347+ : `${ folderIds . length } folders`
353348
354349 const triggerOptions : ComboboxOption [ ] = useMemo (
355350 ( ) =>
@@ -361,23 +356,21 @@ export const LogsToolbar = memo(function LogsToolbar({
361356 [ ]
362357 )
363358
364- const triggerDisplayLabel = useMemo ( ( ) => {
365- if ( triggers . length === 0 ) return 'Trigger'
366- if ( triggers . length === 1 ) {
367- const trigger = triggerOptions . find ( ( t ) => t . value === triggers [ 0 ] )
368- return trigger ?. label || '1 selected'
369- }
370- return `${ triggers . length } triggers`
371- } , [ triggers , triggerOptions ] )
372-
373- const timeDisplayLabel = useMemo ( ( ) => {
374- if ( timeRange === 'All time' ) return 'Time'
375- if ( timeRange === 'Custom range' && startDate && endDate ) {
376- return `${ formatDateShort ( startDate ) } - ${ formatDateShort ( endDate ) } `
377- }
378- if ( timeRange === 'Custom range' ) return 'Custom range'
379- return timeRange
380- } , [ timeRange , startDate , endDate ] )
359+ const triggerDisplayLabel =
360+ triggers . length === 0
361+ ? 'Trigger'
362+ : triggers . length === 1
363+ ? ( triggerOptions . find ( ( t ) => t . value === triggers [ 0 ] ) ?. label ?? '1 selected' )
364+ : `${ triggers . length } triggers`
365+
366+ const timeDisplayLabel =
367+ timeRange === 'All time'
368+ ? 'Time'
369+ : timeRange === 'Custom range' && startDate && endDate
370+ ? `${ formatDateShort ( startDate ) } - ${ formatDateShort ( endDate ) } `
371+ : timeRange === 'Custom range'
372+ ? 'Custom range'
373+ : timeRange
381374
382375 /**
383376 * Handles time range selection from combobox.
@@ -792,42 +785,32 @@ export const LogsToolbar = memo(function LogsToolbar({
792785 />
793786
794787 { /* Timeline Filter */ }
795- < DropdownMenu open = { datePickerOpen } onOpenChange = { setDatePickerOpen } >
796- < DropdownMenuTrigger asChild >
797- < div >
798- < Combobox
799- options = { TIME_RANGE_OPTIONS as unknown as ComboboxOption [ ] }
800- value = { timeRange }
801- onChange = { handleTimeRangeChange }
802- placeholder = 'Time'
803- overlayContent = {
804- < span className = 'truncate text-[var(--text-primary)]' >
805- { timeDisplayLabel }
806- </ span >
807- }
808- size = 'sm'
809- align = 'end'
810- className = 'h-[32px] w-[120px] rounded-md'
811- />
812- </ div >
813- </ DropdownMenuTrigger >
814- < DropdownMenuContent
815- side = 'bottom'
788+ < div className = 'relative' >
789+ < Combobox
790+ options = { TIME_RANGE_OPTIONS as unknown as ComboboxOption [ ] }
791+ value = { timeRange }
792+ onChange = { handleTimeRangeChange }
793+ placeholder = 'Time'
794+ overlayContent = {
795+ < span className = 'truncate text-[var(--text-primary)]' > { timeDisplayLabel } </ span >
796+ }
797+ size = 'sm'
816798 align = 'end'
817- sideOffset = { 4 }
818- collisionPadding = { 16 }
819- className = 'w-auto p-0'
820- >
821- < DatePicker
822- mode = 'range'
823- startDate = { startDate }
824- endDate = { endDate }
825- onRangeChange = { handleDateRangeApply }
826- onCancel = { handleDatePickerCancel }
827- inline
828- />
829- </ DropdownMenuContent >
830- </ DropdownMenu >
799+ className = 'h-[32px] w-[120px] rounded-md'
800+ />
801+ < DatePicker
802+ mode = 'range'
803+ showTrigger = { false }
804+ open = { datePickerOpen }
805+ onOpenChange = { ( isOpen ) => {
806+ if ( ! isOpen ) handleDatePickerCancel ( )
807+ } }
808+ startDate = { startDate }
809+ endDate = { endDate }
810+ onRangeChange = { handleDateRangeApply }
811+ onCancel = { handleDatePickerCancel }
812+ />
813+ </ div >
831814 </ div >
832815 </ div >
833816 </ div >
0 commit comments