@@ -129,7 +129,7 @@ function OperationsFilter({
129
129
/>
130
130
) ;
131
131
} ,
132
- [ visibleOperations , selectedItems , onSelect ] ,
132
+ [ visibleOperations , selectedItems , onSelect , clientFilteredOperations ] ,
133
133
) ;
134
134
135
135
return (
@@ -416,11 +416,19 @@ function ClientRow({
416
416
...props
417
417
} : {
418
418
client : FragmentType < typeof ClientRow_ClientStatsValuesFragment > ;
419
+ clientOperationStats :
420
+ | FragmentType < typeof ClientRow_ClientStatsValuesFragment >
421
+ | false
422
+ | undefined ;
419
423
selected : boolean ;
420
424
onSelect ( id : string , selected : boolean ) : void ;
421
425
style : any ;
422
426
} ) : ReactElement {
423
427
const client = useFragment ( ClientRow_ClientStatsValuesFragment , props . client ) ;
428
+ const clientOperation =
429
+ props . clientOperationStats === false
430
+ ? false
431
+ : useFragment ( ClientRow_ClientStatsValuesFragment , props . clientOperationStats ) ;
424
432
const requests = useFormattedNumber ( client . count ) ;
425
433
const hash = client . name ;
426
434
const change = useCallback ( ( ) => {
@@ -429,6 +437,18 @@ function ClientRow({
429
437
}
430
438
} , [ onSelect , hash , selected ] ) ;
431
439
440
+ const Totals = ( ) => {
441
+ if ( clientOperation !== false ) {
442
+ return (
443
+ < div className = "flex shrink-0 text-right text-gray-500" >
444
+ < span > { clientOperation ?. count ?? 0 } </ span >
445
+ < span className = "ml-1 truncate text-gray-600" > / { requests } </ span >
446
+ </ div >
447
+ ) ;
448
+ }
449
+ return < div className = "shrink-0 text-right text-gray-600" > { requests } </ div > ;
450
+ } ;
451
+
432
452
return (
433
453
< div style = { style } className = "flex items-center gap-4 truncate" >
434
454
< Checkbox checked = { selected } onCheckedChange = { change } id = { hash } />
@@ -437,7 +457,7 @@ function ClientRow({
437
457
className = "flex w-full cursor-pointer items-center justify-between gap-4 overflow-hidden"
438
458
>
439
459
< span className = "grow overflow-hidden text-ellipsis" > { client . name } </ span >
440
- < div className = "shrink-0 text-right text-gray-500" > { requests } </ div >
460
+ < Totals / >
441
461
</ label >
442
462
</ div >
443
463
) ;
@@ -459,12 +479,16 @@ function ClientsFilter({
459
479
isOpen,
460
480
onFilter,
461
481
clientStatsConnection,
482
+ operationStatsConnection,
462
483
selected,
463
484
} : {
464
485
onClose ( ) : void ;
465
486
onFilter ( keys : string [ ] ) : void ;
466
487
isOpen : boolean ;
467
488
clientStatsConnection : FragmentType < typeof ClientsFilter_ClientStatsValuesConnectionFragment > ;
489
+ operationStatsConnection ?:
490
+ | FragmentType < typeof ClientsFilter_ClientStatsValuesConnectionFragment >
491
+ | undefined ;
468
492
selected ?: string [ ] ;
469
493
} ) : ReactElement {
470
494
const clientConnection = useFragment (
@@ -520,21 +544,30 @@ function ClientsFilter({
520
544
setSelectedItems ( [ ] ) ;
521
545
} , [ setSelectedItems ] ) ;
522
546
547
+ const operationConnection = operationStatsConnection
548
+ ? useFragment ( ClientsFilter_ClientStatsValuesConnectionFragment , operationStatsConnection )
549
+ : null ;
550
+
523
551
const renderRow = useCallback < ComponentType < ListChildComponentProps > > (
524
552
( { index, style } ) => {
525
553
const client = visibleOperations [ index ] . node ;
554
+ const operationStats =
555
+ operationConnection == null
556
+ ? false
557
+ : operationConnection . edges . find ( e => e . node . name === client . name ) ?. node ;
526
558
527
559
return (
528
560
< ClientRow
529
561
style = { style }
530
562
key = { client . name }
531
563
client = { client }
564
+ clientOperationStats = { operationStats }
532
565
selected = { selectedItems . includes ( client . name || '' ) }
533
566
onSelect = { onSelect }
534
567
/>
535
568
) ;
536
569
} ,
537
- [ visibleOperations , selectedItems , onSelect ] ,
570
+ [ visibleOperations , selectedItems , onSelect , operationConnection ] ,
538
571
) ;
539
572
540
573
return (
@@ -577,6 +610,11 @@ function ClientsFilter({
577
610
</ Button >
578
611
</ div >
579
612
< div className = "grow pl-1" >
613
+ { operationStatsConnection && (
614
+ < div className = "text-right text-xs text-gray-600" >
615
+ < span className = "text-gray-500" > selected</ span > / all operations
616
+ </ div >
617
+ ) }
580
618
< AutoSizer >
581
619
{ ( { height, width } ) =>
582
620
! height || ! width ? (
@@ -605,6 +643,8 @@ const ClientsFilterContainer_ClientStatsQuery = graphql(`
605
643
query ClientsFilterContainer_ClientStats(
606
644
$targetSelector: TargetSelectorInput!
607
645
$period: DateRangeInput!
646
+ $filter: OperationStatsFilterInput
647
+ $hasFilter: Boolean!
608
648
) {
609
649
target(reference: { bySelector: $targetSelector }) {
610
650
id
@@ -618,6 +658,17 @@ const ClientsFilterContainer_ClientStatsQuery = graphql(`
618
658
}
619
659
}
620
660
}
661
+ filteredOperationStats: operationsStats(period: $period, filter: $filter)
662
+ @include(if: $hasFilter) {
663
+ clients {
664
+ ...ClientsFilter_ClientStatsValuesConnectionFragment
665
+ edges {
666
+ node {
667
+ __typename
668
+ }
669
+ }
670
+ }
671
+ }
621
672
}
622
673
}
623
674
` ) ;
@@ -628,6 +679,7 @@ function ClientsFilterContainer({
628
679
onClose,
629
680
onFilter,
630
681
selected,
682
+ selectedOperationIds,
631
683
organizationSlug,
632
684
projectSlug,
633
685
targetSlug,
@@ -640,6 +692,7 @@ function ClientsFilterContainer({
640
692
organizationSlug : string ;
641
693
projectSlug : string ;
642
694
targetSlug : string ;
695
+ selectedOperationIds ?: string [ ] ;
643
696
} ) : ReactElement | null {
644
697
const [ query , refresh ] = useQuery ( {
645
698
query : ClientsFilterContainer_ClientStatsQuery ,
@@ -650,6 +703,8 @@ function ClientsFilterContainer({
650
703
targetSlug,
651
704
} ,
652
705
period,
706
+ filter : selectedOperationIds ? { operationIds : selectedOperationIds } : undefined ,
707
+ hasFilter : ! ! selectedOperationIds ?. length ,
653
708
} ,
654
709
} ) ;
655
710
@@ -672,6 +727,7 @@ function ClientsFilterContainer({
672
727
return (
673
728
< ClientsFilter
674
729
clientStatsConnection = { query . data . target . operationsStats . clients }
730
+ operationStatsConnection = { query . data . target . filteredOperationStats ?. clients }
675
731
selected = { selected }
676
732
isOpen = { isOpen }
677
733
onClose = { onClose }
@@ -689,10 +745,12 @@ export function ClientsFilterTrigger({
689
745
organizationSlug,
690
746
projectSlug,
691
747
targetSlug,
748
+ selectedOperationIds,
692
749
} : {
693
750
period : DateRangeInput ;
694
751
onFilter ( keys : string [ ] ) : void ;
695
752
selected ?: string [ ] ;
753
+ selectedOperationIds ?: string [ ] ;
696
754
organizationSlug : string ;
697
755
projectSlug : string ;
698
756
targetSlug : string ;
@@ -713,6 +771,7 @@ export function ClientsFilterTrigger({
713
771
onClose = { toggle }
714
772
period = { period }
715
773
selected = { selected }
774
+ selectedOperationIds = { selectedOperationIds }
716
775
onFilter = { onFilter }
717
776
/>
718
777
</ >
0 commit comments