@@ -21,6 +21,7 @@ import {
2121 DialogTrigger ,
2222} from "~/components/primitives/Dialog" ;
2323import { Input } from "~/components/primitives/Input" ;
24+ import { Checkbox } from "~/components/primitives/Checkbox" ;
2425import { Fieldset } from "~/components/primitives/Fieldset" ;
2526import { InputGroup } from "~/components/primitives/InputGroup" ;
2627import { Hint } from "~/components/primitives/Hint" ;
@@ -210,11 +211,14 @@ function AutoArchiveForm({
210211 } > ( { pending : false } ) ;
211212 const [ requestedKey , setRequestedKey ] = useState < string | null > ( null ) ;
212213 const [ days , setDays ] = useState ( String ( environment . previewAutoArchiveAfterDays ?? 14 ) ) ;
214+ const [ keepSpecificBranches , setKeepSpecificBranches ] = useState (
215+ environment . previewAutoArchiveExcludedBranches . length > 0
216+ ) ;
213217 const [ excludedRows , setExcludedRows ] = useState ( ( ) =>
214218 [ ...environment . previewAutoArchiveExcludedBranches , "" ] . map ( ( name , id ) => ( { id, name } ) )
215219 ) ;
216220 const nextRowId = useRef ( excludedRows . length ) ;
217- const excluded = excludedRows . map ( ( { name } ) => name ) . join ( "\n" ) ;
221+ const excluded = keepSpecificBranches ? excludedRows . map ( ( { name } ) => name ) . join ( "\n" ) : "" ;
218222 const enabled = environment . previewAutoArchiveAfterDays !== null ;
219223
220224 function updateExcludedBranch ( id : number , name : string ) {
@@ -331,38 +335,51 @@ function AutoArchiveForm({
331335 </ div >
332336 </ InputGroup >
333337 < InputGroup fullWidth >
334- < Label htmlFor = { `archive-exclusion-${ excludedRows [ 0 ] . id } ` } required = { false } >
335- Branches to keep
336- </ Label >
337- { excludedRows . map ( ( row , index ) => (
338- < div key = { row . id } className = "flex items-center gap-2" >
339- < Input
340- id = { `archive-exclusion-${ row . id } ` }
341- aria-label = { `Branch to keep ${ index + 1 } ` }
342- aria-describedby = "archive-exclusions-description"
343- maxLength = { 255 }
344- placeholder = { index === 0 ? "Branch name, e.g. staging" : "Add another branch" }
345- disabled = { busy }
346- value = { row . name }
347- onChange = { ( event ) => updateExcludedBranch ( row . id , event . target . value ) }
348- />
349- { ( row . name !== "" || index < excludedRows . length - 1 ) && (
350- < Button
351- type = "button"
352- variant = "secondary/medium"
353- LeadingIcon = { TrashIcon }
354- aria-label = { `Remove branch ${ row . name || index + 1 } ` }
355- disabled = { busy }
356- onClick = { ( ) => removeExcludedBranch ( row . id ) }
357- />
358- ) }
359- </ div >
360- ) ) }
361- < div id = "archive-exclusions-description" >
362- < Hint >
363- Never auto-archive these branches. Use exact names; wildcards aren’t supported.
364- </ Hint >
338+ < div className = "flex items-center gap-2" >
339+ < Checkbox
340+ id = "keep-specific-branches"
341+ checked = { keepSpecificBranches }
342+ disabled = { busy }
343+ onChange = { ( event ) => setKeepSpecificBranches ( event . target . checked ) }
344+ aria-controls = "archive-exclusions"
345+ />
346+ < Label htmlFor = "keep-specific-branches" className = "cursor-pointer" >
347+ Keep specific branches
348+ </ Label >
365349 </ div >
350+ { keepSpecificBranches && (
351+ < div id = "archive-exclusions" className = "grid gap-1.5 pl-6" >
352+ { excludedRows . map ( ( row , index ) => (
353+ < div key = { row . id } className = "flex items-center gap-2" >
354+ < Input
355+ id = { `archive-exclusion-${ row . id } ` }
356+ aria-label = { `Branch to keep ${ index + 1 } ` }
357+ aria-describedby = "archive-exclusions-description"
358+ maxLength = { 255 }
359+ placeholder = { index === 0 ? "Branch name, e.g. staging" : "Add another branch" }
360+ disabled = { busy }
361+ value = { row . name }
362+ onChange = { ( event ) => updateExcludedBranch ( row . id , event . target . value ) }
363+ />
364+ { ( row . name !== "" || index < excludedRows . length - 1 ) && (
365+ < Button
366+ type = "button"
367+ variant = "secondary/medium"
368+ LeadingIcon = { TrashIcon }
369+ aria-label = { `Remove branch ${ row . name || index + 1 } ` }
370+ disabled = { busy }
371+ onClick = { ( ) => removeExcludedBranch ( row . id ) }
372+ />
373+ ) }
374+ </ div >
375+ ) ) }
376+ < div id = "archive-exclusions-description" >
377+ < Hint >
378+ Never auto-archive these branches. Use exact names; wildcards aren’t supported.
379+ </ Hint >
380+ </ div >
381+ </ div >
382+ ) }
366383 </ InputGroup >
367384 < section
368385 className = "max-h-48 overflow-y-auto"
0 commit comments