/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*/
import React, {useEffect} from 'react';
import {
TrackingScope,
useLogger,
_Sidebar,
Layout,
Dialog,
_PortalsManager,
getFlipperLib,
} from 'flipper-plugin';
import {Link, styled} from '../ui';
import {theme} from 'flipper-plugin';
import {Logger} from 'flipper-common';
import {Navbar} from './Navbar';
import {useStore} from '../utils/useStore';
import {AppInspect} from './appinspect/AppInspect';
import PluginContainer from '../PluginContainer';
import {ContentContainer} from './ContentContainer';
import {showChangelog} from '../chrome/ChangelogSheet';
import PlatformSelectWizard, {
hasPlatformWizardBeenDone,
} from '../chrome/PlatformSelectWizard';
import PWAInstallationWizard, {
shouldShowPWAInstallationWizard,
} from '../chrome/PWAppInstallationWizard';
import {getVersionString} from '../utils/versionString';
import config from '../fb-stubs/config';
import {WelcomeScreenStaticView} from './WelcomeScreen';
import fbConfig from '../fb-stubs/config';
import {isFBEmployee} from '../utils/fbEmployee';
import {Button, Modal, notification} from 'antd';
import isProduction from '../utils/isProduction';
import {getRenderHostInstance} from 'flipper-frontend-core';
import {uiPerfTracker} from '../utils/UIPerfTracker';
import {WarningOutlined} from '@ant-design/icons';
export function SandyApp() {
const logger = useLogger();
const leftSidebarVisible = useStore(
(state) => state.application.leftSidebarVisible,
);
const staticView = useStore((state) => state.connections.staticView);
const serverConfig = getRenderHostInstance().serverConfig;
useEffect(() => {
let title = `Flipper (${getVersionString()}${
config.isFBBuild ? '@FB' : ''
})`;
if (!serverConfig.environmentInfo.isHeadlessBuild) {
title += ' (Unsupported)';
}
document.title = title;
registerStartupTime(logger);
uiPerfTracker.track('ui-perf-sandy-container-rendered');
if (hasPlatformWizardBeenDone(window.localStorage)) {
Dialog.showModal((onHide) => (
));
}
if (shouldShowPWAInstallationWizard()) {
console.info('Attempt to install PWA, launch installation wizard.');
Dialog.showModal((onHide) => );
}
if (serverConfig.environmentInfo.isHeadlessBuild) {
showChangelog(true);
}
// don't warn about logger, even with a new logger we don't want to re-register
// eslint-disable-next-line
}, []);
useEffect(() => {
isFBEmployee()
.then((isEmployee) => {
if (isEmployee) {
if (process.env.FLIPPER_REACT_NATIVE_ONLY) {
Dialog.showModal((onHide) => (
onHide()}
width={570}
title={
<>
This Version of Flipper is Unsupported
>
}
footer={
<>
>
}>
This version is only meant to be used for React Native
debugging. It is not maintained and it doesn't receive updates.
Instead, you should be using the main Flipper version from
Managed Software Center for all other purposes.
));
} else if (fbConfig.warnFBEmployees && isProduction()) {
notification.warning({
placement: 'bottomLeft',
message: 'Please use Flipper@FB',
description: (
<>
You are using the open-source version of Flipper. Install the
internal build from{' '}
Managed Software Center
{' '}
to get access to more plugins.
>
),
duration: null,
});
}
}
})
.catch((e) => {
console.warn('Failed to check if user is employee', e);
});
}, []);
return (
<_Sidebar width={250} minWidth={220} maxWidth={800} gutter>
{leftSidebarVisible ? : null}
{staticView ? (
{staticView === WelcomeScreenStaticView ? (
React.createElement(staticView) /* avoid shadow */
) : (
{React.createElement(staticView, {
logger: logger,
})}
)}
) : (
)}
{outOfContentsContainer}
<_PortalsManager />
);
}
const outOfContentsContainer = (