@@ -4,7 +4,8 @@ import { Account } from '../../models/account'
44import { GitConfigUserForm } from '../lib/git-config-user-form'
55import { getDotComAPIEndpoint } from '../../lib/api'
66import { Row } from '../lib/row'
7- import { RadioButton } from '../lib/radio-button'
7+ import { RadioGroup } from '../lib/radio-group'
8+ import { assertNever } from '../../lib/fatal-error'
89
910interface IGitConfigProps {
1011 readonly account : Account | null
@@ -32,36 +33,41 @@ export class GitConfig extends React.Component<IGitConfigProps> {
3233 this . props . onGitConfigLocationChanged ( value )
3334 }
3435
36+ private renderConfigOptionLabel = ( key : GitConfigLocation ) => {
37+ switch ( key ) {
38+ case GitConfigLocation . Global :
39+ return 'Use my global Git config'
40+ case GitConfigLocation . Local :
41+ return 'Use a local Git config'
42+ default :
43+ return assertNever ( key , `Unknown git config location: ${ key } ` )
44+ }
45+ }
46+
3547 public render ( ) {
3648 const isDotComAccount =
3749 this . props . account !== null &&
3850 this . props . account . endpoint === getDotComAPIEndpoint ( )
3951 const enterpriseAccount = isDotComAccount ? null : this . props . account
4052 const dotComAccount = isDotComAccount ? this . props . account : null
4153
54+ const configOptions = [ GitConfigLocation . Global , GitConfigLocation . Local ]
55+ const selectionOption =
56+ configOptions . find ( o => o === this . props . gitConfigLocation ) ??
57+ GitConfigLocation . Global
58+
4259 return (
4360 < DialogContent >
4461 < div className = "advanced-section" >
45- < h2 > For this repository I wish to</ h2 >
62+ < h2 id = "git-config-heading" > For this repository I wish to</ h2 >
4663 < Row >
47- < div >
48- < RadioButton
49- label = "Use my global Git config"
50- checked = {
51- this . props . gitConfigLocation === GitConfigLocation . Global
52- }
53- value = { GitConfigLocation . Global }
54- onSelected = { this . onGitConfigLocationChanged }
55- />
56- < RadioButton
57- label = "Use a local Git config"
58- checked = {
59- this . props . gitConfigLocation === GitConfigLocation . Local
60- }
61- value = { GitConfigLocation . Local }
62- onSelected = { this . onGitConfigLocationChanged }
63- />
64- </ div >
64+ < RadioGroup < GitConfigLocation >
65+ ariaLabelledBy = "git-config-heading"
66+ selectedKey = { selectionOption }
67+ radioButtonKeys = { configOptions }
68+ onSelectionChanged = { this . onGitConfigLocationChanged }
69+ renderRadioButtonLabelContents = { this . renderConfigOptionLabel }
70+ />
6571 </ Row >
6672 < GitConfigUserForm
6773 email = {
0 commit comments