From 0d4c9030ff33b893bfcf9e36b89d984f76905f27 Mon Sep 17 00:00:00 2001 From: Lorenzo Blasa Date: Mon, 2 Oct 2023 05:06:03 -0700 Subject: [PATCH] Unsupported modal Summary: Show an unsupported modal for Electron builds (FB employees only) Reviewed By: antonk52 Differential Revision: D49770083 fbshipit-source-id: 3616dce3206e976f2fdccd834b2c57748f19fcb0 --- .../src/sandy-chrome/SandyApp.tsx | 88 ++++++++++++++----- 1 file changed, 67 insertions(+), 21 deletions(-) diff --git a/desktop/flipper-ui-core/src/sandy-chrome/SandyApp.tsx b/desktop/flipper-ui-core/src/sandy-chrome/SandyApp.tsx index dfdb33568..b47791cf6 100644 --- a/desktop/flipper-ui-core/src/sandy-chrome/SandyApp.tsx +++ b/desktop/flipper-ui-core/src/sandy-chrome/SandyApp.tsx @@ -15,31 +15,32 @@ import { Layout, Dialog, _PortalsManager, + getFlipperLib, + styled, } from 'flipper-plugin'; -import {Link, styled} from '../ui'; import {theme} from 'flipper-plugin'; -import {Logger} from 'flipper-common'; - +import {isProduction, Logger} from 'flipper-common'; import {Navbar} from './Navbar'; import {useStore} from '../utils/useStore'; import {AppInspect} from './appinspect/AppInspect'; import PluginContainer from '../PluginContainer'; import {ContentContainer} from './ContentContainer'; -import {showChangelog} from '../chrome/ChangelogSheet'; import PlatformSelectWizard, { hasPlatformWizardBeenDone, } from '../chrome/PlatformSelectWizard'; -import PWAInstallationWizard, { - shouldShowPWAInstallationWizard, -} from '../chrome/PWAppInstallationWizard'; import {getVersionString} from '../utils/versionString'; import config from '../fb-stubs/config'; import {WelcomeScreenStaticView} from './WelcomeScreen'; -import fbConfig from '../fb-stubs/config'; import {isFBEmployee} from '../utils/fbEmployee'; -import {notification} from 'antd'; -import isProduction from '../utils/isProduction'; +import {Button, Modal, notification} from 'antd'; import {getRenderHostInstance} from 'flipper-frontend-core'; +import {WarningOutlined} from '@ant-design/icons'; +import PWAInstallationWizard, { + shouldShowPWAInstallationWizard, +} from '../chrome/PWAppInstallationWizard'; +import {showChangelog} from '../chrome/ChangelogSheet'; +import {Link} from '../ui'; +import fbConfig from '../fb-stubs/config'; export function SandyApp() { const logger = useLogger(); @@ -48,10 +49,17 @@ export function SandyApp() { ); const staticView = useStore((state) => state.connections.staticView); + const serverConfig = getRenderHostInstance().serverConfig; + useEffect(() => { - document.title = `Flipper (${getVersionString()}${ + let title = `Flipper (${getVersionString()}${ config.isFBBuild ? '@FB' : '' })`; + if (!serverConfig.environmentInfo.isHeadlessBuild) { + title += ' (Unsupported)'; + } + + document.title = title; registerStartupTime(logger); @@ -71,17 +79,55 @@ export function SandyApp() { Dialog.showModal((onHide) => ); } - showChangelog(true); + if (serverConfig.environmentInfo.isHeadlessBuild) { + showChangelog(true); + } // don't warn about logger, even with a new logger we don't want to re-register // eslint-disable-next-line }, []); useEffect(() => { - if (fbConfig.warnFBEmployees && isProduction()) { - isFBEmployee() - .then((isEmployee) => { - if (isEmployee) { + isFBEmployee() + .then((isEmployee) => { + if (isEmployee) { + if (!serverConfig.environmentInfo.isHeadlessBuild) { + Dialog.showModal((onHide) => ( + onHide()} + width={570} + title={ + <> + This Version of Flipper is Unsupported + + } + footer={ + <> + + + + }> + This version is only meant to be used for React Native + debugging. It is not maintained and it doesn't receive updates. + Instead, you should be using the main Flipper version from + Managed Software Center for all other purposes. + + )); + } else if (fbConfig.warnFBEmployees && isProduction()) { notification.warning({ placement: 'bottomLeft', message: 'Please use Flipper@FB', @@ -98,11 +144,11 @@ export function SandyApp() { duration: null, }); } - }) - .catch((e) => { - console.warn('Failed to check if user is employee', e); - }); - } + } + }) + .catch((e) => { + console.warn('Failed to check if user is employee', e); + }); }, []); return (