@@ -149,6 +149,10 @@ function ProviderAccount({
149149 const complete = useAtomCommand ( serverEnvironment . completeProviderAuth , options ) ;
150150 const cancel = useAtomCommand ( serverEnvironment . cancelProviderAuth , options ) ;
151151 const logout = useAtomCommand ( serverEnvironment . logoutProviderAuth , options ) ;
152+ const removeMethod = useAtomCommand ( serverEnvironment . removeProviderAuthMethod , options ) ;
153+ const canRemoveMethod = useAtomValue (
154+ serverEnvironment . removeProviderAuthMethod . permissionAtom ( environmentId ) ,
155+ ) ;
152156 // Matches ListRowLayout: large text stacks the action below instead of squeezing the status.
153157 const stacked = useWindowDimensions ( ) . fontScale >= 1.5 ;
154158 const [ pending , setPending ] = useState ( false ) ;
@@ -260,6 +264,21 @@ function ProviderAccount({
260264 id : `method:${ method . id } ` ,
261265 title : method . name ,
262266 } ) ) ;
267+ const removableMethods = methods . filter ( ( method ) => method . canRemove ) ;
268+ const removeActions : MenuAction [ ] = removableMethods . length
269+ ? [
270+ {
271+ id : "remove" ,
272+ title : "Remove incomplete connection" ,
273+ attributes : { disabled : disabled || active || ! canRemoveMethod } ,
274+ subactions : removableMethods . map ( ( method ) => ( {
275+ id : `remove:${ method . id } ` ,
276+ title : method . name ,
277+ attributes : { destructive : true , disabled : disabled || active || ! canRemoveMethod } ,
278+ } ) ) ,
279+ } ,
280+ ]
281+ : [ ] ;
263282 function startSignIn ( methodId ?: string ) {
264283 void run ( ( ) => start ( methodId ? { environmentId, input : { instanceId, methodId } } : target ) ) ;
265284 }
@@ -283,10 +302,16 @@ function ProviderAccount({
283302 if ( id === "signOut" ) signOut ( ) ;
284303 // iOS keeps a disabled submenu's children selectable, so sign-in guards here too.
285304 else if ( signInDisabled ) return ;
286- else if ( id . startsWith ( "method:" ) ) startSignIn ( id . slice ( "method:" . length ) ) ;
305+ else if ( id . startsWith ( "remove:" ) ) {
306+ if ( active || ! canRemoveMethod ) return ;
307+ const methodId = id . slice ( "remove:" . length ) ;
308+ if ( ! removableMethods . some ( ( method ) => method . id === methodId ) ) return ;
309+ void run ( ( ) => removeMethod ( { environmentId, input : { instanceId, methodId } } ) ) ;
310+ } else if ( id . startsWith ( "method:" ) ) startSignIn ( id . slice ( "method:" . length ) ) ;
287311 else if ( id === "change" ) startSignIn ( ) ;
288312 }
289313 const accountActions : MenuAction [ ] = [
314+ ...removeActions ,
290315 ...( canSignIn
291316 ? [
292317 {
@@ -357,7 +382,7 @@ function ProviderAccount({
357382 accessibilityRole = "button"
358383 accessibilityLabel = { `Sign in to ${ name } ` }
359384 title = "Sign in with"
360- actions = { methodActions }
385+ actions = { [ ... methodActions , ... removeActions ] }
361386 onPressAction = { ( { nativeEvent } ) => onMenuAction ( nativeEvent . event ) }
362387 >
363388 < ControlPill variant = "primary" label = "Sign in" accessibilityLabel = { `Sign in to ${ name } ` } />
0 commit comments