@@ -3,7 +3,6 @@ import { EyeIcon, LayersIcon, PenLineIcon, UsersIcon, type LucideIcon } from "lu
33import type { RefCallback } from "react" ;
44
55import { cn } from "~/lib/utils" ;
6- import { useShortcutModifierState } from "~/shortcutModifierState" ;
76import { Separator } from "../ui/separator" ;
87import {
98 pullRequestEntryKey ,
@@ -12,7 +11,10 @@ import {
1211 type PullRequestGroup ,
1312} from "./pullRequestList.logic" ;
1413import { PullRequestRow , type PullRequestRowTarget } from "./PullRequestRow" ;
15- import type { PullRequestSpeedActionResult } from "./PullRequestSpeedActions" ;
14+ import {
15+ PullRequestSpeedModeProvider ,
16+ type PullRequestSpeedActionResult ,
17+ } from "./PullRequestSpeedActions" ;
1618
1719const GROUP_ICONS : Record < string , LucideIcon > = {
1820 authored : PenLineIcon ,
@@ -38,10 +40,6 @@ function PullRequestGroupHeader({
3840 ) ;
3941}
4042
41- /**
42- * The grouped rows. Holding Shift turns rows into speed actions, so the modifier subscription lives
43- * here: a key press re-renders the rows, not the page and its open pull request.
44- */
4543export function PullRequestListGroups ( {
4644 groups,
4745 environmentLabels,
@@ -75,47 +73,46 @@ export function PullRequestListGroups({
7573 sweepingKeys : ReadonlySet < string > ;
7674 onCloseSweepStart : ( entry : EnvironmentPullRequestEntry , event : PointerEvent ) => void ;
7775} ) {
78- const modifiers = useShortcutModifierState ( true ) ;
79- const speedMode =
80- modifiers . shiftKey && ! modifiers . metaKey && ! modifiers . ctrlKey && ! modifiers . altKey ;
8176 return (
82- < div className = { cn ( "space-y-3" , sweepingKeys . size > 0 && "**:pointer-events-none" ) } >
83- { groups . map ( ( group ) => (
84- < div key = { group . key } className = "space-y-0.5" >
85- { group . label ? < PullRequestGroupHeader group = { group } /> : null }
86- { group . entries . map ( ( entry ) => {
87- const entryKey = pullRequestEntryKey ( entry ) ;
88- const environmentLabel = environmentLabels ?. get ( entry . environmentId ) ;
89- return (
90- < PullRequestRow
91- key = { entryKey }
92- statsKey = { entryKey }
93- statsRef = { statsRef }
94- entry = { entry }
95- showProjectTitle
96- showProvider = { showProvider }
97- { ...( environmentLabel !== undefined ? { environmentLabel } : { } ) }
98- matchedElsewhere = {
99- query . length > 0 && scorePullRequestMatch ( entry , query ) <= MATCHED_ELSEWHERE_SCORE
100- }
101- selected = {
102- selected ?. environmentId === entry . environmentId &&
103- selected . repository === entry . repository &&
104- selected . host ?. toLowerCase ( ) === entry . host . toLowerCase ( ) &&
105- selected . number === entry . number
106- }
107- onSelect = { onSelect }
108- speedMode = { speedMode }
109- hostActions = { hostActionsOf ( entry ) }
110- onActed = { onActed }
111- closing = { closingKeys . has ( entryKey ) }
112- sweeping = { sweepingKeys . has ( entryKey ) }
113- onCloseSweepStart = { onCloseSweepStart }
114- />
115- ) ;
116- } ) }
117- </ div >
118- ) ) }
119- </ div >
77+ < PullRequestSpeedModeProvider >
78+ < div className = { cn ( "space-y-3" , sweepingKeys . size > 0 && "**:pointer-events-none" ) } >
79+ { groups . map ( ( group ) => (
80+ < div key = { group . key } className = "space-y-0.5" >
81+ { group . label ? < PullRequestGroupHeader group = { group } /> : null }
82+ { group . entries . map ( ( entry ) => {
83+ const entryKey = pullRequestEntryKey ( entry ) ;
84+ const environmentLabel = environmentLabels ?. get ( entry . environmentId ) ;
85+ return (
86+ < PullRequestRow
87+ key = { entryKey }
88+ statsKey = { entryKey }
89+ statsRef = { statsRef }
90+ entry = { entry }
91+ showProjectTitle
92+ showProvider = { showProvider }
93+ { ...( environmentLabel !== undefined ? { environmentLabel } : { } ) }
94+ matchedElsewhere = {
95+ query . length > 0 &&
96+ scorePullRequestMatch ( entry , query ) <= MATCHED_ELSEWHERE_SCORE
97+ }
98+ selected = {
99+ selected ?. environmentId === entry . environmentId &&
100+ selected . repository === entry . repository &&
101+ selected . host ?. toLowerCase ( ) === entry . host . toLowerCase ( ) &&
102+ selected . number === entry . number
103+ }
104+ onSelect = { onSelect }
105+ hostActions = { hostActionsOf ( entry ) }
106+ onActed = { onActed }
107+ closing = { closingKeys . has ( entryKey ) }
108+ sweeping = { sweepingKeys . has ( entryKey ) }
109+ onCloseSweepStart = { onCloseSweepStart }
110+ />
111+ ) ;
112+ } ) }
113+ </ div >
114+ ) ) }
115+ </ div >
116+ </ PullRequestSpeedModeProvider >
120117 ) ;
121118}
0 commit comments