@@ -3,7 +3,8 @@ import { DialogContent } from '../dialog'
33import { ForkContributionTarget } from '../../models/workflow-preferences'
44import { RepositoryWithForkedGitHubRepository } from '../../models/repository'
55import { ForkSettingsDescription } from './fork-contribution-target-description'
6- import { RadioButton } from '../lib/radio-button'
6+ import { RadioGroup } from '../lib/radio-group'
7+ import { assertNever } from '../../lib/fatal-error'
78
89interface IForkSettingsProps {
910 readonly forkContributionTarget : ForkContributionTarget
@@ -15,27 +16,33 @@ interface IForkSettingsProps {
1516
1617/** A view for creating or modifying the repository's gitignore file */
1718export class ForkSettings extends React . Component < IForkSettingsProps , { } > {
19+ private renderForkOptionsLabel = ( key : ForkContributionTarget ) => {
20+ switch ( key ) {
21+ case ForkContributionTarget . Parent :
22+ return 'To contribute to the parent repository'
23+ case ForkContributionTarget . Self :
24+ return 'For my own purposes'
25+ default :
26+ return assertNever ( key , `Unknown fork contribution target: ${ key } ` )
27+ }
28+ }
29+
1830 public render ( ) {
31+ const options = [ ForkContributionTarget . Parent , ForkContributionTarget . Self ]
32+ const selectionOption =
33+ options . find ( o => o === this . props . forkContributionTarget ) ??
34+ ForkContributionTarget . Parent
35+
1936 return (
2037 < DialogContent >
21- < h2 > I'll be using this fork…</ h2 >
22-
23- < RadioButton
24- value = { ForkContributionTarget . Parent }
25- checked = {
26- this . props . forkContributionTarget === ForkContributionTarget . Parent
27- }
28- label = "To contribute to the parent repository"
29- onSelected = { this . onForkContributionTargetChanged }
30- />
38+ < h2 id = "fork-usage-heading" > I'll be using this fork…</ h2 >
3139
32- < RadioButton
33- value = { ForkContributionTarget . Self }
34- checked = {
35- this . props . forkContributionTarget === ForkContributionTarget . Self
36- }
37- label = "For my own purposes"
38- onSelected = { this . onForkContributionTargetChanged }
40+ < RadioGroup < ForkContributionTarget >
41+ ariaLabelledBy = "fork-usage-heading"
42+ selectedKey = { selectionOption }
43+ radioButtonKeys = { options }
44+ onSelectionChanged = { this . onForkContributionTargetChanged }
45+ renderRadioButtonLabelContents = { this . renderForkOptionsLabel }
3946 />
4047
4148 < ForkSettingsDescription
0 commit comments