move WelcomeScreen

Summary: The sidebar is now shown, even if no device is connected. This prevents the jumping layout when Flipper launches, but still has not connected to devices.

Reviewed By: passy

Differential Revision: D9263892

fbshipit-source-id: d5b96a8619393ee4002863a83d9024f00c6cb396
This commit is contained in:
Daniel Büchele
2018-08-10 08:52:02 -07:00
committed by Facebook Github Bot
parent 7107efcc88
commit aace545ba6
6 changed files with 64 additions and 60 deletions

View File

@@ -52,16 +52,14 @@ export class App extends React.Component<Props> {
close={() => this.props.toggleBugDialogVisible(false)} close={() => this.props.toggleBugDialogVisible(false)}
/> />
)} )}
{this.props.selectedDevice ? ( <FlexRow fill={true}>
<FlexRow fill={true}> {this.props.leftSidebarVisible && <MainSidebar />}
{this.props.leftSidebarVisible && <MainSidebar />} {this.props.selectedDevice ? (
<PluginContainer logger={this.props.logger} /> <PluginContainer logger={this.props.logger} />
</FlexRow> ) : (
) : this.props.pluginManagerVisible ? ( <WelcomeScreen />
<PluginManager /> )}
) : ( </FlexRow>
<WelcomeScreen />
)}
<ErrorBar text={this.props.error} /> <ErrorBar text={this.props.error} />
</FlexColumn> </FlexColumn>
); );

View File

@@ -135,7 +135,8 @@ class PluginSidebarListItem extends Component<{
type MainSidebarProps = {| type MainSidebarProps = {|
selectedPlugin: ?string, selectedPlugin: ?string,
selectedApp: ?string, selectedApp: ?string,
selectedDevice: BaseDevice, selectedDevice: ?BaseDevice,
windowIsFocused: boolean,
selectPlugin: (payload: { selectPlugin: (payload: {
selectedPlugin: ?string, selectedPlugin: ?string,
selectedApp: ?string, selectedApp: ?string,
@@ -150,12 +151,13 @@ class MainSidebar extends Component<MainSidebarProps> {
selectedPlugin, selectedPlugin,
selectedApp, selectedApp,
selectPlugin, selectPlugin,
windowIsFocused,
} = this.props; } = this.props;
let {clients} = this.props; let {clients} = this.props;
let enabledPlugins = []; let enabledPlugins = [];
for (const devicePlugin of devicePlugins) { for (const devicePlugin of devicePlugins) {
if (selectedDevice.supportsPlugin(devicePlugin)) { if (selectedDevice && selectedDevice.supportsPlugin(devicePlugin)) {
enabledPlugins.push(devicePlugin); enabledPlugins.push(devicePlugin);
} }
} }
@@ -179,22 +181,28 @@ class MainSidebar extends Component<MainSidebarProps> {
.sort((a, b) => (a.query.app || '').localeCompare(b.query.app)); .sort((a, b) => (a.query.app || '').localeCompare(b.query.app));
return ( return (
<Sidebar position="left" width={200}> <Sidebar
{devicePlugins position="left"
.filter(selectedDevice.supportsPlugin) width={200}
.map((plugin: Class<SonarDevicePlugin<>>) => ( backgroundColor={
<PluginSidebarListItem process.platform === 'darwin' && windowIsFocused ? 'transparent' : ''
key={plugin.id} }>
isActive={plugin.id === selectedPlugin} {selectedDevice &&
onClick={() => devicePlugins
selectPlugin({ .filter(selectedDevice.supportsPlugin)
selectedPlugin: plugin.id, .map((plugin: Class<SonarDevicePlugin<>>) => (
selectedApp: null, <PluginSidebarListItem
}) key={plugin.id}
} isActive={plugin.id === selectedPlugin}
plugin={plugin} onClick={() =>
/> selectPlugin({
))} selectedPlugin: plugin.id,
selectedApp: null,
})
}
plugin={plugin}
/>
))}
{clients.map((client: Client) => ( {clients.map((client: Client) => (
<React.Fragment key={client.id}> <React.Fragment key={client.id}>
<SidebarHeader>{client.query.app}</SidebarHeader> <SidebarHeader>{client.query.app}</SidebarHeader>
@@ -226,7 +234,11 @@ class MainSidebar extends Component<MainSidebarProps> {
} }
export default connect( export default connect(
({connections: {selectedDevice, selectedPlugin, selectedApp, clients}}) => ({ ({
application: {windowIsFocused},
connections: {selectedDevice, selectedPlugin, selectedApp, clients},
}) => ({
windowIsFocused,
selectedDevice, selectedDevice,
selectedPlugin, selectedPlugin,
selectedApp, selectedApp,

View File

@@ -23,7 +23,7 @@ const Container = FlexColumn.extends({
width: '100%', width: '100%',
justifyContent: 'center', justifyContent: 'center',
alignItems: 'center', alignItems: 'center',
backgroundImage: 'url(./pattern.gif)', backgroundColor: colors.light02,
}); });
const Welcome = FlexColumn.extends( const Welcome = FlexColumn.extends(
@@ -104,12 +104,14 @@ export default class WelcomeScreen extends PureComponent<Props, State> {
}; };
componentDidMount() { componentDidMount() {
// waiting sometime before showing the welcome screen to allow Flipper to
// connect to devices, if there are any
setTimeout( setTimeout(
() => () =>
this.setState({ this.setState({
isMounted: true, isMounted: true,
}), }),
100, 2000,
); );
} }

View File

@@ -8,6 +8,7 @@
import type {StyledComponent} from '../styled/index.js'; import type {StyledComponent} from '../styled/index.js';
import Interactive from './Interactive.js'; import Interactive from './Interactive.js';
import FlexColumn from './FlexColumn.js'; import FlexColumn from './FlexColumn.js';
import {colors} from './colors';
import {Component} from 'react'; import {Component} from 'react';
const SidebarInteractiveContainer = Interactive.extends({ const SidebarInteractiveContainer = Interactive.extends({
@@ -21,7 +22,8 @@ const SidebarContainer: StyledComponent<{
overflow?: boolean, overflow?: boolean,
}> = FlexColumn.extends( }> = FlexColumn.extends(
{ {
backgroundColor: props => props.backgroundColor || '#f7f7f7', backgroundColor: props =>
props.backgroundColor || colors.macOSTitleBarBackgroundBlur,
borderLeft: props => borderLeft: props =>
props.position === 'right' ? '1px solid #b3b3b3' : 'none', props.position === 'right' ? '1px solid #b3b3b3' : 'none',
borderTop: props => borderTop: props =>
@@ -103,7 +105,11 @@ type SidebarState = {|
export default class Sidebar extends Component<SidebarProps, SidebarState> { export default class Sidebar extends Component<SidebarProps, SidebarState> {
constructor(props: SidebarProps, context: Object) { constructor(props: SidebarProps, context: Object) {
super(props, context); super(props, context);
this.state = {userChange: false, width: props.width, height: props.height}; this.state = {
userChange: false,
width: props.width,
height: props.height,
};
} }
static defaultProps = { static defaultProps = {

View File

@@ -9,7 +9,8 @@
<title>Sonar</title> <title>Sonar</title>
<style> <style>
.__infinity-dev-box {
#loading {
-webkit-app-region: drag; -webkit-app-region: drag;
z-index: 999999; z-index: 999999;
position: absolute; position: absolute;
@@ -18,12 +19,13 @@
bottom: 0; bottom: 0;
right: 0; right: 0;
padding: 50px; padding: 50px;
color: #fff;
overflow: auto; overflow: auto;
} display: flex;
align-items: center;
.__infinity-dev-box-loading { justify-content: center;
background-color: #333; font-size: 20px;
color: #525252;
text-align: center;
} }
.__infinity-dev-box-error { .__infinity-dev-box-error {
@@ -33,26 +35,16 @@
font-size: 16px; font-size: 16px;
} }
.__infinity-dev-box-text {
font-size: 30px;
line-height: 200px;
margin-top: -100px;
width: 100%;
position: absolute;
top: 50%;
left: 0;
right: 0;
text-align: center;
}
</style> </style>
</head> </head>
<body> <body>
<div id="root"></div> <div id="root">
<div id="loading">
<div class="__infinity-dev-box __infinity-dev-box-loading"> Loading...
<div class="__infinity-dev-box-text">Loading...</div> </div>
</div> </div>
<div class="__infinity-dev-box __infinity-dev-box-error" hidden> <div class="__infinity-dev-box __infinity-dev-box-error" hidden>
</div> </div>
@@ -83,11 +75,6 @@
const box = document.querySelector('.__infinity-dev-box-error'); const box = document.querySelector('.__infinity-dev-box-error');
box.removeAttribute('hidden'); box.removeAttribute('hidden');
box.textContent = text; box.textContent = text;
onLoad();
}
function onLoad() {
document.querySelector('.__infinity-dev-box-loading').setAttribute('hidden', true);
} }
function init() { function init() {
@@ -98,8 +85,6 @@
openError('Script failure. Check Chrome console for more info.'); openError('Script failure. Check Chrome console for more info.');
}; };
script.onload = onLoad;
document.body.appendChild(script); document.body.appendChild(script);
} }

View File

@@ -141,6 +141,7 @@ function tryCreateWindow() {
fullscreenable: false, fullscreenable: false,
backgroundThrottling: false, backgroundThrottling: false,
titleBarStyle: 'hiddenInset', titleBarStyle: 'hiddenInset',
vibrancy: 'sidebar',
webPreferences: { webPreferences: {
webSecurity: false, webSecurity: false,
scrollBounce: true, scrollBounce: true,