@@ -164,6 +164,7 @@ export function GitHubAccountSettings({
164164 const hosts = github . hosts ;
165165 const projects = useAtomValue ( environmentProjects . environmentProjectsAtom ( environmentId ) ) ;
166166 const identities = projects . map ( ( project ) => project . repositoryIdentity ) ;
167+ const writable = useAtomValue ( serverEnvironment . updateSettings . permissionAtom ( environmentId ) ) ;
167168 const updateSettings = useAtomCommand ( serverEnvironment . updateSettings , {
168169 label : "save GitHub account settings" ,
169170 } ) ;
@@ -226,7 +227,6 @@ export function GitHubAccountSettings({
226227 revealed = { revealed }
227228 />
228229 ) ;
229- // What an owner without a rule reads as: the host's pinned login, else gh's active one.
230230 const hostAccount = pinned === DEFAULT_ACCOUNT ? group . activeAccount : pinned ;
231231 const multiple = group . selectable . length > 1 ;
232232 const owners = multiple
@@ -249,7 +249,7 @@ export function GitHubAccountSettings({
249249 </ div >
250250 < Switch
251251 checked = { enabled }
252- disabled = { saving }
252+ disabled = { saving || ! writable }
253253 aria-label = { `Use GitHub on ${ group . host } ` }
254254 onCheckedChange = { ( checked ) => void save ( group . host , { enabled : checked } ) }
255255 />
@@ -262,7 +262,7 @@ export function GitHubAccountSettings({
262262 accounts = { group . selectable }
263263 defaultLabel = { activeLabel }
264264 revealed = { revealed }
265- disabled = { saving }
265+ disabled = { saving || ! writable }
266266 ariaLabel = { `GitHub account for ${ group . host } ` }
267267 onChange = { ( account ) => void save ( group . host , { account } ) }
268268 />
@@ -276,7 +276,7 @@ export function GitHubAccountSettings({
276276 < Button
277277 size = "xs"
278278 variant = "outline"
279- disabled = { saving }
279+ disabled = { saving || ! writable }
280280 onClick = { ( ) => void save ( group . host , { account : null } ) }
281281 >
282282 Use active login
@@ -305,7 +305,7 @@ export function GitHubAccountSettings({
305305 < DefaultLabel prefix = "Default" account = { hostAccount } revealed = { revealed } />
306306 }
307307 revealed = { revealed }
308- disabled = { saving }
308+ disabled = { saving || ! writable }
309309 ariaLabel = { `GitHub account for ${ owner } on ${ group . host } ` }
310310 staleWarning = { `This login is no longer signed in, so ${ owner } uses the default account.` }
311311 onChange = { ( account ) =>
@@ -334,7 +334,7 @@ export function GitHubAccountSettings({
334334 />
335335 }
336336 revealed = { revealed }
337- disabled = { saving }
337+ disabled = { saving || ! writable }
338338 ariaLabel = { `GitHub account for ${ repository } on ${ group . host } ` }
339339 staleWarning = { `This login is no longer signed in, so ${ repository } reads as its owner's account.` }
340340 onChange = { ( account ) =>
@@ -373,6 +373,7 @@ export function ProjectGitHubAccountRow({
373373 ) ;
374374 const projects = useAtomValue ( environmentProjects . environmentProjectsAtom ( environmentId ) ) ;
375375 const hosts = useEnvironmentSettings ( environmentId , readGitHubSettings ) . hosts ;
376+ const writable = useAtomValue ( serverEnvironment . updateSettings . permissionAtom ( environmentId ) ) ;
376377 const updateSettings = useAtomCommand ( serverEnvironment . updateSettings , {
377378 label : "save GitHub account settings" ,
378379 } ) ;
@@ -449,7 +450,12 @@ export function ProjectGitHubAccountRow({
449450 { revealed ? < EyeOffIcon /> : < EyeIcon /> }
450451 </ Button >
451452 { stale ? (
452- < Button size = "xs" variant = "outline" disabled = { saving } onClick = { ( ) => void save ( null ) } >
453+ < Button
454+ size = "xs"
455+ variant = "outline"
456+ disabled = { saving || ! writable }
457+ onClick = { ( ) => void save ( null ) }
458+ >
453459 Clear override
454460 </ Button >
455461 ) : null }
@@ -460,7 +466,7 @@ export function ProjectGitHubAccountRow({
460466 < DefaultLabel prefix = "Owner's account" account = { ownerAccount } revealed = { revealed } />
461467 }
462468 revealed = { revealed }
463- disabled = { saving }
469+ disabled = { saving || ! writable }
464470 ariaLabel = { `GitHub account for ${ repository . repository } ` }
465471 onChange = { ( account ) => void save ( account ) }
466472 />
0 commit comments