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:
committed by
Facebook Github Bot
parent
7107efcc88
commit
aace545ba6
16
src/App.js
16
src/App.js
@@ -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 />}
|
||||
<FlexRow fill={true}>
|
||||
{this.props.leftSidebarVisible && <MainSidebar />}
|
||||
{this.props.selectedDevice ? (
|
||||
<PluginContainer logger={this.props.logger} />
|
||||
</FlexRow>
|
||||
) : this.props.pluginManagerVisible ? (
|
||||
<PluginManager />
|
||||
) : (
|
||||
<WelcomeScreen />
|
||||
)}
|
||||
) : (
|
||||
<WelcomeScreen />
|
||||
)}
|
||||
</FlexRow>
|
||||
<ErrorBar text={this.props.error} />
|
||||
</FlexColumn>
|
||||
);
|
||||
|
||||
@@ -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,22 +181,28 @@ class MainSidebar extends Component<MainSidebarProps> {
|
||||
.sort((a, b) => (a.query.app || '').localeCompare(b.query.app));
|
||||
|
||||
return (
|
||||
<Sidebar position="left" width={200}>
|
||||
{devicePlugins
|
||||
.filter(selectedDevice.supportsPlugin)
|
||||
.map((plugin: Class<SonarDevicePlugin<>>) => (
|
||||
<PluginSidebarListItem
|
||||
key={plugin.id}
|
||||
isActive={plugin.id === selectedPlugin}
|
||||
onClick={() =>
|
||||
selectPlugin({
|
||||
selectedPlugin: plugin.id,
|
||||
selectedApp: null,
|
||||
})
|
||||
}
|
||||
plugin={plugin}
|
||||
/>
|
||||
))}
|
||||
<Sidebar
|
||||
position="left"
|
||||
width={200}
|
||||
backgroundColor={
|
||||
process.platform === 'darwin' && windowIsFocused ? 'transparent' : ''
|
||||
}>
|
||||
{selectedDevice &&
|
||||
devicePlugins
|
||||
.filter(selectedDevice.supportsPlugin)
|
||||
.map((plugin: Class<SonarDevicePlugin<>>) => (
|
||||
<PluginSidebarListItem
|
||||
key={plugin.id}
|
||||
isActive={plugin.id === selectedPlugin}
|
||||
onClick={() =>
|
||||
selectPlugin({
|
||||
selectedPlugin: plugin.id,
|
||||
selectedApp: null,
|
||||
})
|
||||
}
|
||||
plugin={plugin}
|
||||
/>
|
||||
))}
|
||||
{clients.map((client: Client) => (
|
||||
<React.Fragment key={client.id}>
|
||||
<SidebarHeader>{client.query.app}</SidebarHeader>
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -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 = {
|
||||
|
||||
@@ -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,26 +35,16 @@
|
||||
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>
|
||||
|
||||
</div>
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -141,6 +141,7 @@ function tryCreateWindow() {
|
||||
fullscreenable: false,
|
||||
backgroundThrottling: false,
|
||||
titleBarStyle: 'hiddenInset',
|
||||
vibrancy: 'sidebar',
|
||||
webPreferences: {
|
||||
webSecurity: false,
|
||||
scrollBounce: true,
|
||||
|
||||
Reference in New Issue
Block a user