Killed Flipper headless

Reviewed By: nikoant

Differential Revision: D24160480

fbshipit-source-id: 221e60473dddc0a49cea674e210beb6f85b1b03c
This commit is contained in:
Michel Weststrate
2020-12-15 01:45:29 -08:00
committed by Facebook GitHub Bot
parent 41a1af33cb
commit 08b5644253
32 changed files with 36 additions and 1256 deletions

View File

@@ -14,14 +14,11 @@ import Text from '../ui/components/FlexRow';
import Glyph from '../ui/components/Glyph';
import {colors, brandColors} from '../ui/components/colors';
import isProduction from '../utils/isProduction';
import isHeadless from '../utils/isHeadless';
import constants from '../fb-stubs/constants';
const {shell, remote} = !isHeadless()
? require('electron')
: {shell: undefined, remote: undefined};
import {shell, remote} from 'electron';
import {PureComponent} from 'react';
import React from 'react';
import {Tracked, TrackingScope} from 'flipper-plugin';
import {Logger, Tracked, TrackingScope} from 'flipper-plugin';
const Container = styled(FlexColumn)({
height: '100%',
@@ -95,7 +92,9 @@ const Logo = styled.img({
marginBottom: 20,
});
type Props = {};
type Props = {
logger: Logger;
};
type State = {
isMounted: boolean;
};

View File

@@ -1,12 +0,0 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*/
export class WelcomeScreenHeadless {
// NoOp
}

View File

@@ -56,6 +56,7 @@ import {
NoDevices,
getColorByApp,
getFavoritePlugins,
isStaticViewActive,
} from './sidebarUtils';
import {useLocalStorage} from '../../utils/useLocalStorage';
import {PluginDefinition, ClientPluginMap, DevicePluginMap} from '../../plugin';
@@ -391,13 +392,6 @@ class MainSidebar2 extends PureComponent<Props, State> {
}
}
function isStaticViewActive(
current: StaticView,
selected: StaticView,
): boolean {
return current && selected && current === selected;
}
function groupPluginsByCategory(
plugins: FlipperPlugins,
): PluginsByCategoryType {

View File

@@ -116,7 +116,7 @@ export function isStaticViewActive(
current: StaticView,
selected: StaticView,
): boolean {
return current && selected && current === selected;
return Boolean(current && selected && current === selected);
}
export const CategoryName = styled(PluginName)({

View File

@@ -11,7 +11,6 @@ import {Store} from '../reducers/index';
import {Logger} from '../fb-interfaces/Logger';
import {PluginNotification} from '../reducers/notifications';
import {PluginDefinition, isSandyPlugin} from '../plugin';
import isHeadless from '../utils/isHeadless';
import {setStaticView} from '../reducers/connections';
import {ipcRenderer, IpcRendererEvent} from 'electron';
import {
@@ -158,7 +157,6 @@ export default (store: Store, logger: Logger) => {
}))
.forEach((n: PluginNotification) => {
if (
!isHeadless() &&
store.getState().connections.selectedPlugin !== 'notifications' &&
!knownNotifications.has(n.notification.id) &&
blocklistedPlugins.indexOf(n.pluginId) === -1 &&

View File

@@ -10,6 +10,5 @@
export {LogTypes, TrackType, Logger} from 'flipper-plugin';
export type Args = {
isHeadless?: boolean;
isTest?: boolean;
};

View File

@@ -8,9 +8,10 @@
*/
import React, {Component} from 'react';
import {StaticViewProps} from '../reducers/connections';
import {Text} from '../ui';
export default class extends Component<void, void> {
export default class extends Component<StaticViewProps, {}> {
render() {
return <Text>Build your support request deteails form.</Text>;
}

View File

@@ -8,9 +8,10 @@
*/
import React, {Component} from 'react';
import {StaticViewProps} from '../reducers/connections';
import {Text} from '../ui';
export default class extends Component<void, void> {
export default class extends Component<StaticViewProps, {}> {
render() {
return <Text>Build your support request creation form.</Text>;
}

View File

@@ -8,9 +8,10 @@
*/
import React, {Component} from 'react';
import {StaticViewProps} from '../reducers/connections';
import {Text} from '../ui';
export default class extends Component<void, void> {
export default class extends Component<StaticViewProps, {}> {
render() {
return <Text>Debug Videos on Watch Bugs.</Text>;
}

View File

@@ -7,6 +7,7 @@
* @format
*/
import {ComponentType} from 'react';
import {produce} from 'immer';
import type BaseDevice from '../devices/BaseDevice';
@@ -15,28 +16,18 @@ import type Client from '../Client';
import {UninitializedClient} from '../UninitializedClient';
import {isEqual} from 'lodash';
import {performance} from 'perf_hooks';
import isHeadless from '../utils/isHeadless';
import {Actions} from '.';
const WelcomeScreen = isHeadless()
? require('../chrome/WelcomeScreenHeadless').default
: require('../chrome/WelcomeScreen').default;
import NotificationScreen from '../chrome/NotificationScreen';
import SupportRequestFormV2 from '../fb-stubs/SupportRequestFormV2';
import SupportRequestDetails from '../fb-stubs/SupportRequestDetails';
import WelcomeScreen from '../chrome/WelcomeScreen';
import {getPluginKey, isDevicePluginDefinition} from '../utils/pluginUtils';
import {deconstructClientId} from '../utils/clientUtils';
import {PluginDefinition} from '../plugin';
import {RegisterPluginAction} from './plugins';
import {ConsoleLogs} from '../chrome/ConsoleLogs';
import MetroDevice from '../devices/MetroDevice';
import {Logger} from 'flipper-plugin';
export type StaticView =
| null
| typeof WelcomeScreen
| typeof NotificationScreen
| typeof SupportRequestFormV2
| typeof SupportRequestDetails
| typeof ConsoleLogs;
export type StaticViewProps = {logger: Logger};
export type StaticView = null | ComponentType<StaticViewProps>;
export type State = {
devices: Array<BaseDevice>;

View File

@@ -309,8 +309,7 @@ function ShowSettingsButton() {
function SupportFormButton() {
const dispatch = useDispatch();
const staticView = useStore((state) => state.connections.staticView);
// const isVisible =
return (
return config.isFBBuild ? (
<LeftRailButton
icon={<BugOutlined />}
small
@@ -324,7 +323,7 @@ function SupportFormButton() {
dispatch(setStaticView(SupportRequestFormV2));
}}
/>
);
) : null;
}
function WelcomeScreenButton() {

View File

@@ -127,7 +127,7 @@ export function SandyApp() {
{staticView ? (
<TrackingScope
scope={
staticView.displayName ??
(staticView as any).displayName ??
staticView.name ??
staticView.constructor?.name ??
'unknown static view'

View File

@@ -22,10 +22,7 @@ const {Text, Title} = Typography;
import constants from '../fb-stubs/constants';
import isProduction from '../utils/isProduction';
import isHeadless from '../utils/isHeadless';
const {shell, remote} = !isHeadless()
? require('electron')
: {shell: undefined, remote: undefined};
import {shell, remote} from 'electron';
const RowContainer = styled(FlexRow)({
alignItems: 'flex-start',

View File

@@ -1,12 +0,0 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*/
export default function isHeadless(): boolean {
return typeof global.window === 'undefined';
}