From 18ff69bacd518b18e506cbefc5e420abc8ae8d4a Mon Sep 17 00:00:00 2001 From: Michel Weststrate Date: Tue, 19 Jan 2021 11:35:17 -0800 Subject: [PATCH] Clean up home screen Summary: The default screen without any devices or magic GK's was a bit noisy, this diffs cleans it up Reviewed By: jknoxville Differential Revision: D25946004 fbshipit-source-id: 76b7eec16b433544e9872e726e8f57dd1ce02b0f --- desktop/app/src/reducers/connections.tsx | 13 ++- desktop/app/src/sandy-chrome/SandyApp.tsx | 15 ++- .../app/src/sandy-chrome/WelcomeScreen.tsx | 108 +++++++++++------- .../sandy-chrome/appinspect/AppInspect.tsx | 8 +- 4 files changed, 85 insertions(+), 59 deletions(-) diff --git a/desktop/app/src/reducers/connections.tsx b/desktop/app/src/reducers/connections.tsx index 8f3c1a7d9..834b3c80d 100644 --- a/desktop/app/src/reducers/connections.tsx +++ b/desktop/app/src/reducers/connections.tsx @@ -17,7 +17,7 @@ import {UninitializedClient} from '../UninitializedClient'; import {isEqual} from 'lodash'; import {performance} from 'perf_hooks'; import {Actions} from '.'; -import WelcomeScreen from '../chrome/WelcomeScreen'; +import {WelcomeScreenStaticView} from '../sandy-chrome/WelcomeScreen'; import {getPluginKey, isDevicePluginDefinition} from '../utils/pluginUtils'; import {deconstructClientId} from '../utils/clientUtils'; import {PluginDefinition} from '../plugin'; @@ -27,7 +27,10 @@ import {Logger} from 'flipper-plugin'; export type StaticViewProps = {logger: Logger}; -export type StaticView = null | ComponentType; +export type StaticView = + | null + | ComponentType + | React.FunctionComponent; export type State = { devices: Array; @@ -142,7 +145,7 @@ const INITAL_STATE: State = { clients: [], uninitializedClients: [], deepLinkPayload: null, - staticView: WelcomeScreen, + staticView: WelcomeScreenStaticView, }; export default (state: State = INITAL_STATE, action: Actions): State => { @@ -466,7 +469,7 @@ export function canBeDefaultDevice(device: BaseDevice) { * @param state */ function updateSelection(state: Readonly): State { - if (state.staticView && state.staticView !== WelcomeScreen) { + if (state.staticView && state.staticView !== WelcomeScreenStaticView) { return state; } @@ -488,7 +491,7 @@ function updateSelection(state: Readonly): State { } updates.selectedDevice = device; if (!device) { - updates.staticView = WelcomeScreen; + updates.staticView = WelcomeScreenStaticView; } // Select client based on device diff --git a/desktop/app/src/sandy-chrome/SandyApp.tsx b/desktop/app/src/sandy-chrome/SandyApp.tsx index a8b4877dd..e0e15e4be 100644 --- a/desktop/app/src/sandy-chrome/SandyApp.tsx +++ b/desktop/app/src/sandy-chrome/SandyApp.tsx @@ -33,6 +33,7 @@ import {hasNewChangesToShow} from '../chrome/ChangelogSheet'; import {SandyWelcomScreen} from './SandyWelcomeScreen'; import {getVersionString} from '../utils/versionString'; import config from '../fb-stubs/config'; +import {WelcomeScreenStaticView} from './WelcomeScreen'; export type ToplevelNavItem = | 'appinspect' @@ -136,11 +137,15 @@ export function SandyApp() { staticView.constructor?.name ?? 'unknown static view' }> - - {React.createElement(staticView, { - logger: logger, - })} - + {staticView === WelcomeScreenStaticView ? ( + React.createElement(staticView) /* avoid shadow */ + ) : ( + + {React.createElement(staticView, { + logger: logger, + })} + + )} ) : ( diff --git a/desktop/app/src/sandy-chrome/WelcomeScreen.tsx b/desktop/app/src/sandy-chrome/WelcomeScreen.tsx index 9d7b9a0a9..276847de0 100644 --- a/desktop/app/src/sandy-chrome/WelcomeScreen.tsx +++ b/desktop/app/src/sandy-chrome/WelcomeScreen.tsx @@ -16,7 +16,7 @@ import { CodeOutlined, BugOutlined, } from '@ant-design/icons'; -import {theme, Tracked, TrackingScope} from 'flipper-plugin'; +import {Layout, theme, Tracked, TrackingScope} from 'flipper-plugin'; const {Text, Title} = Typography; @@ -113,48 +113,70 @@ export default function WelcomeScreen({ /> } onCancel={onClose}> - - - - Welcome to Flipper - - {isProduction() && remote - ? `Version ${remote.app.getVersion()}` - : 'Development Mode'} - - - - } - title="Using Flipper" - subtitle="Learn how Flipper can help you debug your App" - onClick={openExternal('https://fbflipper.com/docs/features/index')} - /> - } - title="Create Your Own Plugin" - subtitle="Get started with these pointers" - onClick={openExternal('https://fbflipper.com/docs/tutorial/intro')} - /> - } - title="Add Flipper Support to Your App" - subtitle="Get started with these pointers" - onClick={openExternal( - 'https://fbflipper.com/docs/getting-started/index', - )} - /> - } - title="Contributing and Feedback" - subtitle="Report issues and help us improve Flipper" - onClick={openExternal(constants.FEEDBACK_GROUP_LINK)} - /> - - + ); } + +export function WelcomeScreenStaticView() { + return ( + + + + + + ); +} + +function WelcomeScreenContent() { + return ( + + + + Welcome to Flipper + + {isProduction() && remote + ? `Version ${remote.app.getVersion()}` + : 'Development Mode'} + + + + } + title="Using Flipper" + subtitle="Learn how Flipper can help you debug your App" + onClick={openExternal('https://fbflipper.com/docs/features/index')} + /> + } + title="Create Your Own Plugin" + subtitle="Get started with these pointers" + onClick={openExternal('https://fbflipper.com/docs/tutorial/intro')} + /> + } + title="Add Flipper Support to Your App" + subtitle="Get started with these pointers" + onClick={openExternal( + 'https://fbflipper.com/docs/getting-started/index', + )} + /> + } + title="Contributing and Feedback" + subtitle="Report issues and help us improve Flipper" + onClick={openExternal(constants.FEEDBACK_GROUP_LINK)} + /> + + + ); +} diff --git a/desktop/app/src/sandy-chrome/appinspect/AppInspect.tsx b/desktop/app/src/sandy-chrome/appinspect/AppInspect.tsx index 11442cf88..ac0dd7e91 100644 --- a/desktop/app/src/sandy-chrome/appinspect/AppInspect.tsx +++ b/desktop/app/src/sandy-chrome/appinspect/AppInspect.tsx @@ -71,7 +71,7 @@ export function AppInspect() { ) : ( )} - {!isArchived && ( + {!isArchived && activeDevice && ( @@ -86,11 +86,7 @@ export function AppInspect() { metroDevice={metroDevice} client={client} /> - ) : ( - - - - )} + ) : null}