diff --git a/desktop/app/src/chrome/UpdateIndicator.tsx b/desktop/app/src/chrome/UpdateIndicator.tsx index f622fb392..5750c6c83 100644 --- a/desktop/app/src/chrome/UpdateIndicator.tsx +++ b/desktop/app/src/chrome/UpdateIndicator.tsx @@ -49,32 +49,7 @@ export default function UpdateIndicator() { placement: 'bottomLeft', key: 'flipperupdatecheck', message: 'Update available', - description: ( - <> - Flipper version {versionCheckResult.version} is now available. - {fbConfig.isFBBuild ? ( - fbConfig.getReleaseChannel() === ReleaseChannel.INSIDERS ? ( - <> Restart Flipper to update to the latest version. - ) : ( - <> - {' '} - Run arc pull (optionally with{' '} - --latest) in ~/fbsource and - restart Flipper to update to the latest version. - - ) - ) : ( - <> - {' '} - Click to{' '} - - download - - . - - )} - - ), + description: getUpdateAvailableMessage(versionCheckResult), duration: null, // no auto close }); break; @@ -127,3 +102,35 @@ export default function UpdateIndicator() { return null; } + +export function getUpdateAvailableMessage(versionCheckResult: { + url: string; + version: string; +}): React.ReactNode { + return ( + <> + Flipper version {versionCheckResult.version} is now available. + {fbConfig.isFBBuild ? ( + fbConfig.getReleaseChannel() === ReleaseChannel.INSIDERS ? ( + <> Restart Flipper to update to the latest version. + ) : ( + <> + {' '} + Run arc pull (optionally with --latest) in{' '} + ~/fbsource and restart Flipper to update to the latest + version. + + ) + ) : ( + <> + {' '} + Click to{' '} + + download + + . + + )} + + ); +} diff --git a/desktop/app/src/dispatcher/__tests__/handleOpenPluginDeeplink.node.tsx b/desktop/app/src/dispatcher/__tests__/handleOpenPluginDeeplink.node.tsx index 397e56683..41f340c2b 100644 --- a/desktop/app/src/dispatcher/__tests__/handleOpenPluginDeeplink.node.tsx +++ b/desktop/app/src/dispatcher/__tests__/handleOpenPluginDeeplink.node.tsx @@ -92,7 +92,10 @@ test('Triggering a deeplink will work', async () => { jest.runAllTimers(); expect(linksSeen).toEqual(['universe']); expect(renderer.baseElement).toMatchInlineSnapshot(` - +
{ if (!getFlipperLib().isFB || process.env.NODE_ENV === 'test') { return true; // ok, continue } - const title = `Starting plugin ${params.pluginId}…`; - // repeat until connection succeeded while (true) { const spinnerDialog = Dialog.loading({ @@ -136,6 +138,41 @@ async function waitForLogin(store: Store) { }); } +async function verifyFlipperIsUpToDate(title: string) { + const currentVersion = getAppVersion(); + const handle = Dialog.loading({ + title, + message: 'Checking if Flipper is up-to-date', + }); + try { + const result = await checkForUpdate(currentVersion); + handle.close(); + switch (result.kind) { + case 'error': + // if we can't tell if we're up to date, we don't want to halt the process on that. + console.warn('Failed to verify Flipper version', result); + return; + case 'up-to-date': + return; + case 'update-available': + await Dialog.confirm({ + title, + message: ( + + {getUpdateAvailableMessage(result)} + + ), + okText: 'Skip', + }); + return; + } + } catch (e) { + // if we can't tell if we're up to date, we don't want to halt the process on that. + console.warn('Failed to verify Flipper version', e); + handle.close(); + } +} + function openPlugin(store: Store, params: OpenPluginParams) { store.dispatch( selectPlugin({ diff --git a/desktop/flipper-plugin/src/ui/Dialog.tsx b/desktop/flipper-plugin/src/ui/Dialog.tsx index 31542ca6b..feeab4c5f 100644 --- a/desktop/flipper-plugin/src/ui/Dialog.tsx +++ b/desktop/flipper-plugin/src/ui/Dialog.tsx @@ -79,7 +79,7 @@ export const Dialog = { message, ...rest }: { - message: string | React.ReactElement; + message: React.ReactNode; } & BaseDialogOptions): DialogResult { return Dialog.show({ ...rest, @@ -94,7 +94,7 @@ export const Dialog = { onConfirm, ...rest }: BaseDialogOptions & { - message: string | React.ReactElement; + message: React.ReactNode; defaultValue?: string; onConfirm?: (value: string) => Promise; }): DialogResult { @@ -123,7 +123,7 @@ export const Dialog = { width, }: { title?: string; - message: string | React.ReactElement; + message: React.ReactNode; width?: number; }) { let cancel: () => void;