From 1efb6827372ecc1e6da1895131f493e17a587511 Mon Sep 17 00:00:00 2001 From: Chaiwat Ekkaewnumchai Date: Thu, 10 Sep 2020 02:10:30 -0700 Subject: [PATCH] Add Opt-in Switch to Sandy UI Summary: With the new design from vpileggi, this diff separated a new app UI to the current one. This diffs show the toggle switch to enable Sandy UI for devs who are in `flipper_sandy` GK. When toggled, it will bring Sandy UI up. Reviewed By: mweststrate Differential Revision: D23599398 fbshipit-source-id: d85c707e0fe7726a418b3551cedb36e455fb7d14 --- desktop/app/src/chrome/SettingsSheet.tsx | 12 +++++ desktop/app/src/fb-stubs/App.tsx | 38 ++++++++++++++ .../app/src/fb-stubs/SandySettingsPanel.tsx | 15 ++++++ desktop/app/src/init.tsx | 52 +++++-------------- desktop/app/src/reducers/settings.tsx | 2 + 5 files changed, 81 insertions(+), 38 deletions(-) create mode 100644 desktop/app/src/fb-stubs/App.tsx create mode 100644 desktop/app/src/fb-stubs/SandySettingsPanel.tsx diff --git a/desktop/app/src/chrome/SettingsSheet.tsx b/desktop/app/src/chrome/SettingsSheet.tsx index 08df6622d..71377b680 100644 --- a/desktop/app/src/chrome/SettingsSheet.tsx +++ b/desktop/app/src/chrome/SettingsSheet.tsx @@ -25,6 +25,7 @@ import KeyboardShortcutInput from './settings/KeyboardShortcutInput'; import {isEqual} from 'lodash'; import restartFlipper from '../utils/restartFlipper'; import LauncherSettingsPanel from '../fb-stubs/LauncherSettingsPanel'; +import SandySettingsPanel from '../fb-stubs/SandySettingsPanel'; import {reportUsage} from '../utils/metrics'; const Container = styled(FlexColumn)({ @@ -183,6 +184,17 @@ class SettingsSheet extends Component { }); }} /> + { + this.setState({ + updatedSettings: { + ...this.state.updatedSettings, + enableSandy: v, + }, + }); + }} + /> { + if (fbConfig.warnFBEmployees) { + isFBEmployee().then((isEmployee) => { + setWarnEmployee(isEmployee); + }); + } + }, []); + return warnEmployee ? ( + { + setWarnEmployee(false); + }} + /> + ) : ( + + ); +} diff --git a/desktop/app/src/fb-stubs/SandySettingsPanel.tsx b/desktop/app/src/fb-stubs/SandySettingsPanel.tsx new file mode 100644 index 000000000..d7d4a82b1 --- /dev/null +++ b/desktop/app/src/fb-stubs/SandySettingsPanel.tsx @@ -0,0 +1,15 @@ +/** + * 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 (_props: { + toggled: boolean; + onChange: (value: boolean) => void; +}) { + return null; +} diff --git a/desktop/app/src/init.tsx b/desktop/app/src/init.tsx index 5bf3ee075..8b094fddf 100644 --- a/desktop/app/src/init.tsx +++ b/desktop/app/src/init.tsx @@ -9,12 +9,11 @@ import {Provider} from 'react-redux'; import ReactDOM from 'react-dom'; -import {useState, useEffect} from 'react'; import ContextMenuProvider from './ui/components/ContextMenuProvider'; import GK from './fb-stubs/GK'; import {init as initLogger} from './fb-stubs/Logger'; -import App from './App'; +import App from './fb-stubs/App'; import setupPrefetcher from './fb-stubs/Prefetcher'; import {persistStore} from 'redux-persist'; import {Store} from './reducers/index'; @@ -22,9 +21,6 @@ import dispatcher from './dispatcher/index'; import TooltipProvider from './ui/components/TooltipProvider'; import config from './utils/processConfig'; import {initLauncherHooks} from './utils/launcher'; -import fbConfig from './fb-stubs/config'; -import {isFBEmployee} from './utils/fbEmployee'; -import WarningEmployee from './chrome/WarningEmployee'; import {setPersistor} from './utils/persistor'; import React from 'react'; import path from 'path'; @@ -59,38 +55,19 @@ enableMapSet(); GK.init(); -const AppFrame = () => { - const [warnEmployee, setWarnEmployee] = useState(false); - useEffect(() => { - if (fbConfig.warnFBEmployees) { - isFBEmployee().then((isEmployee) => { - setWarnEmployee(isEmployee); - }); - } - }, []); - - return ( - - - - - - {warnEmployee ? ( - { - setWarnEmployee(false); - }} - /> - ) : ( - - )} - - - - - - ); -}; +const AppFrame = () => ( + + + + + + + + + + + +); function setProcessState(store: Store) { const settings = store.getState().settingsState; @@ -116,7 +93,6 @@ function init() { initializeFlipperLibImplementation(store, logger); ReactDOM.render(, document.getElementById('root')); initLauncherHooks(config(), store); - const sessionId = store.getState().application.sessionId; registerRecordingHooks(store); enableConsoleHook(); window.flipperGlobalStoreDispatch = store.dispatch; diff --git a/desktop/app/src/reducers/settings.tsx b/desktop/app/src/reducers/settings.tsx index 516ad71e2..9b546d263 100644 --- a/desktop/app/src/reducers/settings.tsx +++ b/desktop/app/src/reducers/settings.tsx @@ -43,6 +43,7 @@ export type Settings = { openDevMenu: string; }; }; + enableSandy: boolean; }; export type Action = @@ -75,6 +76,7 @@ const initialState: Settings = { openDevMenu: 'Alt+Shift+D', }, }, + enableSandy: false, }; export default function reducer(