From 90d40ac385544ed6c462286c1dae69da2902c6c2 Mon Sep 17 00:00:00 2001 From: Anton Nikolaev Date: Mon, 7 Jun 2021 05:52:50 -0700 Subject: [PATCH] More actionable notification message in case of www cert exchange failed Summary: Improved message a bit to make it clear that VPN/Lighthouse is required on both sides - computer and mobile device. Also it will now show login link in case user is not signed in yet, because login is also required for www cert exchange. Reviewed By: passy Differential Revision: D28899558 fbshipit-source-id: 89de776f602a9f27a2c068efd8e3f08c28ec5f57 --- desktop/app/src/dispatcher/server.tsx | 34 ++++++++++++++++++---- desktop/app/src/reducers/notifications.tsx | 12 ++++++-- 2 files changed, 39 insertions(+), 7 deletions(-) diff --git a/desktop/app/src/dispatcher/server.tsx b/desktop/app/src/dispatcher/server.tsx index 6b5081982..7be1654eb 100644 --- a/desktop/app/src/dispatcher/server.tsx +++ b/desktop/app/src/dispatcher/server.tsx @@ -16,6 +16,10 @@ import {UninitializedClient} from '../UninitializedClient'; import {addErrorNotification} from '../reducers/notifications'; import {CertificateExchangeMedium} from '../utils/CertificateProvider'; import {selectClient, selectDevice} from '../reducers/connections'; +import {isLoggedIn} from '../fb-stubs/user'; +import React from 'react'; +import {Typography} from 'antd'; +import {ACTIVE_SHEET_SIGN_IN, setActiveSheet} from '../reducers/application'; export default (store: Store, logger: Logger) => { const server = new Server(logger, store); @@ -71,7 +75,6 @@ export default (store: Store, logger: Logger) => { ({ client, medium, - deviceID, }: { client: UninitializedClient; medium: CertificateExchangeMedium; @@ -79,10 +82,31 @@ export default (store: Store, logger: Logger) => { }) => { store.dispatch( addErrorNotification( - `Client ${client.appName} with device ${deviceID} took long time to connect back on the trusted channel.`, - medium === 'WWW' - ? 'Verify that you are on lighthouse on your client and have a working internet connection. To connect to lighthouse on your client, use VPN. Follow this link: https://www.internalfb.com/intern/wiki/Ops/Network/Enterprise_Network_Engineering/ene_wlra/VPN_Help/Vpn/mobile/' - : 'Verify if your client is connected to Flipper and verify if there is no error related to idb.', + `Timed out establishing connection with "${client.appName}" on "${client.deviceName}".`, + medium === 'WWW' ? ( + <> + Verify that both your computer and mobile device are on + Lighthouse/VPN{' '} + {!isLoggedIn().get() && ( + <> + and{' '} + + store.dispatch(setActiveSheet(ACTIVE_SHEET_SIGN_IN)) + }> + log in to Facebook Intern + + + )}{' '} + so they can exchange certificates.{' '} + + Check this link + {' '} + on how to enable VPN on mobile device. + + ) : ( + 'Verify that your client is connected to Flipper and that there is no error related to idb.' + ), ), ); }, diff --git a/desktop/app/src/reducers/notifications.tsx b/desktop/app/src/reducers/notifications.tsx index 6d8256f92..60aa580bc 100644 --- a/desktop/app/src/reducers/notifications.tsx +++ b/desktop/app/src/reducers/notifications.tsx @@ -10,6 +10,7 @@ import {Notification} from 'flipper-plugin'; import {Actions} from './'; import {getStringFromErrorLike} from '../utils'; +import React from 'react'; export type PluginNotification = { notification: Notification; @@ -200,7 +201,7 @@ export function removeNotification( export function addErrorNotification( title: string, - message: string, + message: string | React.ReactNode, error?: any, ): Action { // TODO: use this method for https://github.com/facebook/flipper/pull/1478/files as well @@ -211,7 +212,14 @@ export function addErrorNotification( notification: { id: title, title, - message: error ? message + ' ' + getStringFromErrorLike(error) : message, + message: error ? ( + <> +

{message}

+

{getStringFromErrorLike(error)}

+ + ) : ( + message + ), severity: 'error', }, });