ConnectionGate.tsx (707B)
1 import * as React from 'react'; 2 import { connect } from 'react-redux'; 3 import LoginForm from './login/LoginForm'; 4 import { StoreState } from '../store'; 5 6 interface Props { 7 connecting: boolean; 8 connected: boolean; 9 onConnect: (hostname: string, password: string, ssl: boolean) => void; 10 children: React.ReactNode; 11 } 12 13 class ConnectionGate extends React.Component<Props> { 14 render() { 15 const { connecting, connected, children, onConnect } = this.props; 16 if (connected) { 17 return children; 18 } else { 19 return <LoginForm connecting={connecting} onConnect={onConnect} />; 20 } 21 } 22 } 23 24 export default connect((state: StoreState) => ({ 25 connected: state.app.connected 26 }))(ConnectionGate);