2019-10-08 12:47:11 +07:00
|
|
|
import React, { useState } from 'react';
|
2019-02-03 17:23:33 +07:00
|
|
|
|
2019-10-08 12:47:11 +07:00
|
|
|
import Search from '../Search';
|
2019-02-03 17:23:33 +07:00
|
|
|
import { getRegistryURL } from '../../utils/url';
|
2019-10-06 22:17:36 +07:00
|
|
|
import Button from '../../muiComponents/Button';
|
2019-10-03 23:17:04 +07:00
|
|
|
|
2019-10-08 12:47:11 +07:00
|
|
|
import { NavBar, InnerNavBar, MobileNavBar, InnerMobileNavBar } from './styles';
|
|
|
|
import HeaderLeft from './HeaderLeft';
|
|
|
|
import HeaderRight from './HeaderRight';
|
|
|
|
import HeaderInfoDialog from './HeaderInfoDialog';
|
2019-02-03 17:23:33 +07:00
|
|
|
|
2019-06-20 19:37:28 +07:00
|
|
|
interface Props {
|
2019-06-26 06:10:15 +07:00
|
|
|
logo?: string;
|
2019-06-20 19:37:28 +07:00
|
|
|
username?: string;
|
|
|
|
onLogout: () => void;
|
|
|
|
onToggleLoginModal: () => void;
|
|
|
|
scope: string;
|
|
|
|
withoutSearch?: boolean;
|
|
|
|
}
|
|
|
|
|
2019-10-08 12:47:11 +07:00
|
|
|
/* eslint-disable react/jsx-max-depth */
|
|
|
|
/* eslint-disable react/jsx-no-bind*/
|
|
|
|
const Header: React.FC<Props> = ({ logo, withoutSearch, username, onLogout, onToggleLoginModal, scope }) => {
|
|
|
|
const [isInfoDialogOpen, setOpenInfoDialog] = useState();
|
|
|
|
const [showMobileNavBar, setShowMobileNavBar] = useState();
|
|
|
|
|
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<NavBar position="static">
|
|
|
|
<InnerNavBar>
|
|
|
|
<HeaderLeft logo={logo} />
|
|
|
|
<HeaderRight
|
|
|
|
onLogout={onLogout}
|
|
|
|
onOpenRegistryInfoDialog={() => setOpenInfoDialog(true)}
|
|
|
|
onToggleLogin={onToggleLoginModal}
|
|
|
|
onToggleMobileNav={() => setShowMobileNavBar(!showMobileNavBar)}
|
|
|
|
username={username}
|
|
|
|
withoutSearch={withoutSearch}
|
|
|
|
/>
|
|
|
|
</InnerNavBar>
|
|
|
|
<HeaderInfoDialog isOpen={isInfoDialogOpen} onCloseDialog={() => setOpenInfoDialog(false)} registryUrl={getRegistryURL()} scope={scope} />
|
|
|
|
</NavBar>
|
|
|
|
{showMobileNavBar && !withoutSearch && (
|
|
|
|
<MobileNavBar>
|
|
|
|
<InnerMobileNavBar>
|
2019-02-03 17:23:33 +07:00
|
|
|
<Search />
|
2019-10-08 12:47:11 +07:00
|
|
|
</InnerMobileNavBar>
|
|
|
|
<Button color="inherit">{'Cancel'}</Button>
|
|
|
|
</MobileNavBar>
|
|
|
|
)}
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
};
|
2019-02-03 17:23:33 +07:00
|
|
|
|
|
|
|
export default Header;
|