import React from "react"; import { Button } from "../control/button"; import { Input } from "../control/input"; import { getIcon, getIconColor } from "../display/icon"; import { AuthPane } from "./auth_pane"; import { rootSize } from "../../config"; let styleInfoBar = { textAlign: "left", color: "#999", marginBottom: "1rem", margin: "auto" }; const styleContainer = { padding: "0.5rem", backgroundColor: "rgba(255, 255, 255, 0.5)" }; const styleLeft = { float: "left", width: "50%", heigth: "2rem" }; const styleRight = { float: "right", width: "50%", textAlign: "right", heigth: "2rem" }; const styleButtonLabel = { verticalAlign: "middle" }; const IconPlusCir = getIcon("pluscir"); const IconSearch = getIcon("search"); const clear =
; export class InfoBar extends React.PureComponent { constructor(props) { super(props); this.state = { filterFileName: "", fold: this.props.compact }; } onLogin = (serverAddr, adminId, adminPwd) => { this.props.onLogin(serverAddr, adminId, adminPwd); }; onLogout = serverAddr => { this.props.onLogout(serverAddr); }; onSearch = value => { // TODO: need debounce this.props.onSearch(value); this.setState({ filterFileName: value }); }; onAddLocalFiles = () => { return this.props.onAddLocalFiles().then(ok => { if (ok) { // TODO: need to add refresh this.props.onOk("Local files are added, please refresh."); } else { this.props.onError("Fail to add local files"); } }); }; onToggle = () => { this.setState({ fold: !this.state.fold }); }; render() { styleInfoBar = { ...styleInfoBar, width: this.props.width }; if (this.props.compact) { const IconMore = getIcon("bars"); const menuIcon = (
} />
); const menuList = !this.state.fold ? (
) : ( ); const menu = (
{menuIcon} {menuList}
); return (
{this.props.isLogin ? ( menu ) : ( )}
{this.props.children}
); } const visitorPane = ( ); const memberPane = (
} />
{clear}
); return (
{this.props.isLogin ? memberPane : visitorPane}
{this.props.children}
); } } InfoBar.defaultProps = { compact: false, width: "-1", isLogin: false, serverAddr: "", onLogin: () => console.error("undefined"), onLogout: () => console.error("undefined"), onAddLocalFiles: () => console.error("undefined"), onSearch: () => console.error("undefined"), onOk: () => console.error("undefined"), onError: () => console.error("undefined") };