diff --git a/src/app/components/ActionUIA.tsx b/src/app/components/ActionUIA.tsx index 19cf11cf..63bd5a69 100644 --- a/src/app/components/ActionUIA.tsx +++ b/src/app/components/ActionUIA.tsx @@ -1,5 +1,20 @@ -import React, { ReactNode } from 'react'; -import { AuthResponse, AuthType, UIAFlow } from '../utils/matrix-uia'; +import React, { ReactNode, useState } from 'react'; +import { + config, + Dialog, + Header, + Text, + IconButton, + Box, + Icon, + Icons, + Button, + OverlayBackdrop, + Overlay, + OverlayCenter, +} from 'folds'; +import FocusTrap from 'focus-trap-react'; +import { AuthResponse, AuthType, getUIAFlowForStages, UIAFlow } from '../utils/matrix-uia'; import { useSupportedUIAFlows, useUIACompleted, useUIAFlow } from '../hooks/useUIAFlows'; import { UIAFlowOverlay } from './UIAFlowOverlay'; import { OAuthStage, PasswordStage, SSOStage } from './uia-stages'; @@ -57,20 +72,97 @@ export function ActionUIA({ authData, ongoingFlow, action, onCancel }: ActionUIA ); } +function UIAFlowPicker({ + flows, + onCancel, + onSelect, +}: { + flows: UIAFlow[]; + onCancel: () => void; + onSelect: (flow: UIAFlow) => void; +}) { + const passwordFlow = getUIAFlowForStages(flows, [AuthType.Password]); + const ssoFlow = getUIAFlowForStages(flows, [AuthType.Sso]); + + return ( + }> + + + +
+ + Authentication + + + + +
+ + + Choose an authentication method to perform this action. + + + {passwordFlow && ( + + )} + {ssoFlow && ( + + )} + + +
+
+
+
+ ); +} + type ActionUIAFlowsLoaderProps = { authData: AuthResponse; + onCancel: () => void; unsupported: () => ReactNode; children: (ongoingFlow: UIAFlow) => ReactNode; }; export function ActionUIAFlowsLoader({ authData, + onCancel, unsupported, children, }: ActionUIAFlowsLoaderProps) { const supportedFlows = useSupportedUIAFlows(authData.flows ?? [], SUPPORTED_IN_APP_UIA_STAGES); - const ongoingFlow = supportedFlows.length > 0 ? supportedFlows[0] : undefined; + const [ongoingFlow, setOngoingFlow] = useState( + supportedFlows.length === 1 ? supportedFlows[0] : undefined + ); - if (!ongoingFlow) return unsupported(); + if (supportedFlows.length === 0) return unsupported(); + + if (!ongoingFlow) { + return ; + } return children(ongoingFlow); } diff --git a/src/app/components/DeviceVerificationSetup.tsx b/src/app/components/DeviceVerificationSetup.tsx index c12eab35..f482e569 100644 --- a/src/app/components/DeviceVerificationSetup.tsx +++ b/src/app/components/DeviceVerificationSetup.tsx @@ -329,6 +329,7 @@ function SetupVerification({ onComplete }: SetupVerificationProps) { {uiaData && ( ( Authentication steps to perform this action are not supported by client. diff --git a/src/app/features/settings/devices/OtherDevices.tsx b/src/app/features/settings/devices/OtherDevices.tsx index 8c491a98..68321963 100644 --- a/src/app/features/settings/devices/OtherDevices.tsx +++ b/src/app/features/settings/devices/OtherDevices.tsx @@ -219,6 +219,7 @@ export function OtherDevices({ devices, refreshDeviceList, showVerification }: O {authData && ( ( Authentication steps to perform this action are not supported by client.