@@ -19,14 +19,15 @@ import {
1919 collectDirectoryPaths ,
2020 diffFileTreeModel ,
2121 diffFileTreePositions ,
22+ diffFileTreeReviewEntries ,
2223 type DiffFileTreeEntry ,
2324} from "./diffFileTree.logic" ;
2425
2526export type { DiffFileTreeEntry } from "./diffFileTree.logic" ;
2627
2728interface DiffFileTreeProps {
2829 readonly entries : ReadonlyArray < DiffFileTreeEntry > ;
29- /** All files affected by a folder review action , including files hidden by filters. */
30+ /** All files affected by review actions , including folder descendants hidden by filters. */
3031 readonly reviewEntries ?: ReadonlyArray < DiffFileTreeEntry > ;
3132 /** Called with the file's path when the reader picks a file row. */
3233 readonly onSelectFile : ( path : string ) => void ;
@@ -37,7 +38,7 @@ interface DiffFileTreeProps {
3738 readonly footer ?: ReactNode ;
3839 readonly className ?: string ;
3940 readonly headerLabel ?: string ;
40- readonly onReviewFolder ?: ( ( path : string , reviewed : boolean ) => void ) | undefined ;
41+ readonly onReviewFiles ?: ( ( paths : ReadonlyArray < string > , reviewed : boolean ) => void ) | undefined ;
4142}
4243
4344export function DiffFileTree ( {
@@ -51,7 +52,7 @@ export function DiffFileTree({
5152 footer,
5253 className,
5354 headerLabel = "Files" ,
54- onReviewFolder ,
55+ onReviewFiles ,
5556} : DiffFileTreeProps ) {
5657 const { resolvedTheme } = useTheme ( ) ;
5758 const paths = entries . map ( ( entry ) => entry . path ) ;
@@ -282,16 +283,18 @@ export function DiffFileTree({
282283 } }
283284 className = "min-h-0 flex-1 overflow-hidden"
284285 style = { pierreTreeStyle ( resolvedTheme ) }
285- { ...( onReviewFolder
286+ { ...( onReviewFiles
286287 ? {
287288 renderContextMenu : ( item , context ) => {
288- if ( item . kind !== "directory" || ! onReviewFolder ) return null ;
289- const prefix = item . path . endsWith ( "/" ) ? item . path : ` ${ item . path } /` ;
290- const descendants = reviewEntriesRef . current . filter ( ( entry ) =>
291- entry . path . startsWith ( prefix ) ,
289+ const matches = diffFileTreeReviewEntries (
290+ reviewEntriesRef . current ,
291+ model . getSelectedPaths ( ) ,
292+ item . path ,
292293 ) ;
293- const canMarkReviewed = descendants . some ( ( entry ) => ! entry . reviewed ) ;
294- const canMarkUnreviewed = descendants . some ( ( entry ) => entry . reviewed ) ;
294+ if ( matches . length === 0 ) return null ;
295+ const paths = matches . map ( ( entry ) => entry . path ) ;
296+ const canMarkReviewed = matches . some ( ( entry ) => ! entry . reviewed ) ;
297+ const canMarkUnreviewed = matches . some ( ( entry ) => entry . reviewed ) ;
295298 return (
296299 < Menu
297300 open
@@ -304,29 +307,25 @@ export function DiffFileTree({
304307 data-file-tree-context-menu-root = "true"
305308 align = "start"
306309 >
307- { onReviewFolder ? (
308- < >
309- { canMarkReviewed ? (
310- < MenuItem
311- onClick = { ( ) => {
312- onReviewFolder ( item . path , true ) ;
313- context . close ( ) ;
314- } }
315- >
316- Mark as reviewed
317- </ MenuItem >
318- ) : null }
319- { canMarkUnreviewed ? (
320- < MenuItem
321- onClick = { ( ) => {
322- onReviewFolder ( item . path , false ) ;
323- context . close ( ) ;
324- } }
325- >
326- Mark as unreviewed
327- </ MenuItem >
328- ) : null }
329- </ >
310+ { canMarkReviewed ? (
311+ < MenuItem
312+ onClick = { ( ) => {
313+ onReviewFiles ( paths , true ) ;
314+ context . close ( ) ;
315+ } }
316+ >
317+ Mark as reviewed
318+ </ MenuItem >
319+ ) : null }
320+ { canMarkUnreviewed ? (
321+ < MenuItem
322+ onClick = { ( ) => {
323+ onReviewFiles ( paths , false ) ;
324+ context . close ( ) ;
325+ } }
326+ >
327+ Mark as unreviewed
328+ </ MenuItem >
330329 ) : null }
331330 </ MenuPopup >
332331 </ Menu >
0 commit comments