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)}
/>
)}
{this.props.selectedDevice ? (
<FlexRow fill={true}>
{this.props.leftSidebarVisible && <MainSidebar />}
{this.props.selectedDevice ? (
<PluginContainer logger={this.props.logger} />
</FlexRow>
) : this.props.pluginManagerVisible ? (
<PluginManager />
) : (
<WelcomeScreen />
)}
</FlexRow>
<ErrorBar text={this.props.error} />
</FlexColumn>
);

View File

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

View File

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

View File

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

View File

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

View File

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