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
This commit is contained in:
Michel Weststrate
2021-01-19 11:35:17 -08:00
committed by Facebook GitHub Bot
parent 69c8413c57
commit 18ff69bacd
4 changed files with 85 additions and 59 deletions

View File

@@ -17,7 +17,7 @@ import {UninitializedClient} from '../UninitializedClient';
import {isEqual} from 'lodash'; import {isEqual} from 'lodash';
import {performance} from 'perf_hooks'; import {performance} from 'perf_hooks';
import {Actions} from '.'; import {Actions} from '.';
import WelcomeScreen from '../chrome/WelcomeScreen'; import {WelcomeScreenStaticView} from '../sandy-chrome/WelcomeScreen';
import {getPluginKey, isDevicePluginDefinition} from '../utils/pluginUtils'; import {getPluginKey, isDevicePluginDefinition} from '../utils/pluginUtils';
import {deconstructClientId} from '../utils/clientUtils'; import {deconstructClientId} from '../utils/clientUtils';
import {PluginDefinition} from '../plugin'; import {PluginDefinition} from '../plugin';
@@ -27,7 +27,10 @@ import {Logger} from 'flipper-plugin';
export type StaticViewProps = {logger: Logger}; export type StaticViewProps = {logger: Logger};
export type StaticView = null | ComponentType<StaticViewProps>; export type StaticView =
| null
| ComponentType<StaticViewProps>
| React.FunctionComponent<any>;
export type State = { export type State = {
devices: Array<BaseDevice>; devices: Array<BaseDevice>;
@@ -142,7 +145,7 @@ const INITAL_STATE: State = {
clients: [], clients: [],
uninitializedClients: [], uninitializedClients: [],
deepLinkPayload: null, deepLinkPayload: null,
staticView: WelcomeScreen, staticView: WelcomeScreenStaticView,
}; };
export default (state: State = INITAL_STATE, action: Actions): State => { export default (state: State = INITAL_STATE, action: Actions): State => {
@@ -466,7 +469,7 @@ export function canBeDefaultDevice(device: BaseDevice) {
* @param state * @param state
*/ */
function updateSelection(state: Readonly<State>): State { function updateSelection(state: Readonly<State>): State {
if (state.staticView && state.staticView !== WelcomeScreen) { if (state.staticView && state.staticView !== WelcomeScreenStaticView) {
return state; return state;
} }
@@ -488,7 +491,7 @@ function updateSelection(state: Readonly<State>): State {
} }
updates.selectedDevice = device; updates.selectedDevice = device;
if (!device) { if (!device) {
updates.staticView = WelcomeScreen; updates.staticView = WelcomeScreenStaticView;
} }
// Select client based on device // Select client based on device

View File

@@ -33,6 +33,7 @@ import {hasNewChangesToShow} from '../chrome/ChangelogSheet';
import {SandyWelcomScreen} from './SandyWelcomeScreen'; import {SandyWelcomScreen} from './SandyWelcomeScreen';
import {getVersionString} from '../utils/versionString'; import {getVersionString} from '../utils/versionString';
import config from '../fb-stubs/config'; import config from '../fb-stubs/config';
import {WelcomeScreenStaticView} from './WelcomeScreen';
export type ToplevelNavItem = export type ToplevelNavItem =
| 'appinspect' | 'appinspect'
@@ -136,11 +137,15 @@ export function SandyApp() {
staticView.constructor?.name ?? staticView.constructor?.name ??
'unknown static view' 'unknown static view'
}> }>
<ContentContainer> {staticView === WelcomeScreenStaticView ? (
{React.createElement(staticView, { React.createElement(staticView) /* avoid shadow */
logger: logger, ) : (
})} <ContentContainer>
</ContentContainer> {React.createElement(staticView, {
logger: logger,
})}
</ContentContainer>
)}
</TrackingScope> </TrackingScope>
) : ( ) : (
<PluginContainer logger={logger} isSandy /> <PluginContainer logger={logger} isSandy />

View File

@@ -16,7 +16,7 @@ import {
CodeOutlined, CodeOutlined,
BugOutlined, BugOutlined,
} from '@ant-design/icons'; } from '@ant-design/icons';
import {theme, Tracked, TrackingScope} from 'flipper-plugin'; import {Layout, theme, Tracked, TrackingScope} from 'flipper-plugin';
const {Text, Title} = Typography; const {Text, Title} = Typography;
@@ -113,48 +113,70 @@ export default function WelcomeScreen({
/> />
} }
onCancel={onClose}> onCancel={onClose}>
<TrackingScope scope="welcomescreen"> <WelcomeScreenContent />
<Space
direction="vertical"
size="middle"
style={{width: '100%', padding: '32px', alignItems: 'center'}}>
<Image width={125} height={125} src="./icon.png" preview={false} />
<Title level={1}>Welcome to Flipper</Title>
<Text style={{color: theme.textColorPlaceholder}}>
{isProduction() && remote
? `Version ${remote.app.getVersion()}`
: 'Development Mode'}
</Text>
</Space>
<Space direction="vertical" size="large" style={{width: '100%'}}>
<Row
icon={<RocketOutlined />}
title="Using Flipper"
subtitle="Learn how Flipper can help you debug your App"
onClick={openExternal('https://fbflipper.com/docs/features/index')}
/>
<Row
icon={<AppstoreAddOutlined />}
title="Create Your Own Plugin"
subtitle="Get started with these pointers"
onClick={openExternal('https://fbflipper.com/docs/tutorial/intro')}
/>
<Row
icon={<CodeOutlined />}
title="Add Flipper Support to Your App"
subtitle="Get started with these pointers"
onClick={openExternal(
'https://fbflipper.com/docs/getting-started/index',
)}
/>
<Row
icon={<BugOutlined />}
title="Contributing and Feedback"
subtitle="Report issues and help us improve Flipper"
onClick={openExternal(constants.FEEDBACK_GROUP_LINK)}
/>
</Space>
</TrackingScope>
</Modal> </Modal>
); );
} }
export function WelcomeScreenStaticView() {
return (
<Layout.Container
center
style={{
justifyContent: 'center',
}}
pad
grow>
<Layout.Container width={400} center>
<WelcomeScreenContent />
</Layout.Container>
</Layout.Container>
);
}
function WelcomeScreenContent() {
return (
<TrackingScope scope="welcomescreen">
<Space
direction="vertical"
size="middle"
style={{width: '100%', padding: '0 32px 32px', alignItems: 'center'}}>
<Image width={125} height={125} src="./icon.png" preview={false} />
<Title level={1}>Welcome to Flipper</Title>
<Text style={{color: theme.textColorPlaceholder}}>
{isProduction() && remote
? `Version ${remote.app.getVersion()}`
: 'Development Mode'}
</Text>
</Space>
<Space direction="vertical" size="large" style={{width: '100%'}}>
<Row
icon={<RocketOutlined />}
title="Using Flipper"
subtitle="Learn how Flipper can help you debug your App"
onClick={openExternal('https://fbflipper.com/docs/features/index')}
/>
<Row
icon={<AppstoreAddOutlined />}
title="Create Your Own Plugin"
subtitle="Get started with these pointers"
onClick={openExternal('https://fbflipper.com/docs/tutorial/intro')}
/>
<Row
icon={<CodeOutlined />}
title="Add Flipper Support to Your App"
subtitle="Get started with these pointers"
onClick={openExternal(
'https://fbflipper.com/docs/getting-started/index',
)}
/>
<Row
icon={<BugOutlined />}
title="Contributing and Feedback"
subtitle="Report issues and help us improve Flipper"
onClick={openExternal(constants.FEEDBACK_GROUP_LINK)}
/>
</Space>
</TrackingScope>
);
}

View File

@@ -71,7 +71,7 @@ export function AppInspect() {
) : ( ) : (
<BookmarkSection /> <BookmarkSection />
)} )}
{!isArchived && ( {!isArchived && activeDevice && (
<Toolbar gap> <Toolbar gap>
<MetroButton useSandy /> <MetroButton useSandy />
<ScreenCaptureButtons useSandy /> <ScreenCaptureButtons useSandy />
@@ -86,11 +86,7 @@ export function AppInspect() {
metroDevice={metroDevice} metroDevice={metroDevice}
client={client} client={client}
/> />
) : ( ) : null}
<Layout.Container padh>
<Alert message="No device or app selected." type="info" />
</Layout.Container>
)}
</Layout.ScrollContainer> </Layout.ScrollContainer>
</Layout.Top> </Layout.Top>
</LeftSidebar> </LeftSidebar>