Migrate Sheet from js to ts

Summary: Migrated Sheet.js to Sheet.tsx

Reviewed By: passy

Differential Revision: D16735685

fbshipit-source-id: f910b38c9d0a8ac5d77203385599a03d0a4bc5bd
This commit is contained in:
Benjamin Elo
2019-08-12 05:49:44 -07:00
committed by Facebook Github Bot
parent 7fd7a26d7d
commit 4305aba816
2 changed files with 22 additions and 18 deletions

View File

@@ -18,7 +18,7 @@ import SignInSheet from './chrome/SignInSheet.tsx';
import ExportDataPluginSheet from './chrome/ExportDataPluginSheet.tsx'; import ExportDataPluginSheet from './chrome/ExportDataPluginSheet.tsx';
import ShareSheetExportFile from './chrome/ShareSheetExportFile.tsx'; import ShareSheetExportFile from './chrome/ShareSheetExportFile.tsx';
import PluginContainer from './PluginContainer.js'; import PluginContainer from './PluginContainer.js';
import Sheet from './chrome/Sheet.js'; import Sheet from './chrome/Sheet.tsx';
import {ipcRenderer, remote} from 'electron'; import {ipcRenderer, remote} from 'electron';
import PluginDebugger from './chrome/PluginDebugger.tsx'; import PluginDebugger from './chrome/PluginDebugger.tsx';
import { import {

View File

@@ -5,15 +5,16 @@
* @format * @format
*/ */
import {Component} from 'react'; import React, {Component} from 'react';
import {Transition} from 'react-transition-group'; import {Transition} from 'react-transition-group';
import {setActiveSheet} from '../reducers/application.tsx'; import {setActiveSheet} from '../reducers/application';
import {connect} from 'react-redux'; import {connect} from 'react-redux';
import {styled} from 'flipper'; import {styled} from 'flipper';
import {PLUGIN_SHEET_ELEMENT_ID} from '../ui/components/Sheet'; import {PLUGIN_SHEET_ELEMENT_ID} from '../ui/components/Sheet';
import {ACTIVE_SHEET_PLUGIN_SHEET} from '../reducers/application.tsx'; import {ACTIVE_SHEET_PLUGIN_SHEET} from '../reducers/application';
import {State as Store} from '../reducers';
import type {ActiveSheet} from '../reducers/application.tsx'; import {ActiveSheet} from '../reducers/application';
const DialogContainer = styled('div')(({state}) => ({ const DialogContainer = styled('div')(({state}) => ({
transform: `translate(-50%, ${ transform: `translate(-50%, ${
@@ -35,26 +36,29 @@ const DialogContainer = styled('div')(({state}) => ({
boxShadow: '0 5px 13px rgba(0, 0, 0, 0.2)', boxShadow: '0 5px 13px rgba(0, 0, 0, 0.2)',
})); }));
type OwnProps = {| type OwnProps = {
children: (onHide: () => mixed) => any, children: (onHide: () => any) => any;
|}; };
type Props = {| type StateFromProps = {
...OwnProps, activeSheet: ActiveSheet;
activeSheet: ActiveSheet, };
onHideSheet: () => void,
|};
type State = {| type DispatchFromProps = {
isVisible: boolean, onHideSheet: () => void;
|}; };
type State = {
isVisible: boolean;
};
type Props = OwnProps & StateFromProps & DispatchFromProps;
class Sheet extends Component<Props, State> { class Sheet extends Component<Props, State> {
state = { state = {
isVisible: Boolean(this.props.activeSheet), isVisible: Boolean(this.props.activeSheet),
}; };
static getDerivedStateFromProps(props: Props, state: State) { static getDerivedStateFromProps(props: Props) {
if (!props.activeSheet) { if (!props.activeSheet) {
return { return {
isVisible: true, isVisible: true,
@@ -110,7 +114,7 @@ class Sheet extends Component<Props, State> {
} }
} }
export default connect<Props, OwnProps, _, _, _, _>( export default connect<StateFromProps, DispatchFromProps, OwnProps, Store>(
({application: {activeSheet}}) => ({ ({application: {activeSheet}}) => ({
activeSheet, activeSheet,
}), }),