{
- const { showMobileNavBar } = this.state;
- const { withoutSearch = false } = this.props;
- return (
-
-
-
- {this.renderLeftSide()}
- {this.renderRightSide()}
-
- {this.renderInfoDialog()}
-
- {showMobileNavBar && !withoutSearch && (
-
-
-
-
-
-
- )}
-
- );
- }
-
- /**
- * opens popover menu for logged in user.
- */
- public handleLoggedInMenu = (event: SyntheticEvent) => {
- this.setState({
- anchorEl: event.currentTarget,
- });
- };
-
- /**
- * closes popover menu for logged in user
- */
- public handleLoggedInMenuClose = () => {
- this.setState({
- anchorEl: null,
- });
- };
-
- /**
- * opens registry information dialog.
- */
- public handleOpenRegistryInfoDialog = () => {
- this.setState({
- openInfoDialog: true,
- });
- };
-
- /**
- * closes registry information dialog.
- */
- public handleCloseRegistryInfoDialog = () => {
- this.setState({
- openInfoDialog: false,
- });
- };
-
- /**
- * close/open popover menu for logged in users.
- */
- public handleToggleLogin = () => {
- const { onToggleLoginModal } = this.props;
- this.setState(
- {
- anchorEl: null,
- },
- onToggleLoginModal
- );
- };
-
- public handleToggleMNav = () => {
- const { showMobileNavBar } = this.state;
- this.setState({
- showMobileNavBar: !showMobileNavBar,
- });
- };
-
- public handleDismissMNav = () => {
- this.setState({
- showMobileNavBar: false,
- });
- };
-
- public renderLeftSide = () => {
- const { withoutSearch = false } = this.props;
- return (
-
-
- {this.renderLogo()}
-
- {!withoutSearch && (
-
+ return (
+ <>
+
+
+
+ setOpenInfoDialog(true)}
+ onToggleLogin={onToggleLoginModal}
+ onToggleMobileNav={() => setShowMobileNavBar(!showMobileNavBar)}
+ username={username}
+ withoutSearch={withoutSearch}
+ />
+
+ setOpenInfoDialog(false)} registryUrl={getRegistryURL()} scope={scope} />
+
+ {showMobileNavBar && !withoutSearch && (
+
+
-
- )}
-
- );
- };
-
- public renderLogo = () => {
- const { logo } = this.props;
-
- if (logo) {
- return ;
- } else {
- return ;
- }
- };
-
- public renderToolTipIcon = (title: string, type: ToolTipType) => {
- let content;
- switch (type) {
- case 'help':
- content = (
-
-
-
-
-
- );
- break;
- case 'info':
- content = (
-
- );
- break;
- case 'search':
- content = (
-
-
-
- );
- break;
- }
- return (
-
- {content}
-
- );
- };
-
- public renderRightSide = () => {
- const { username = '', withoutSearch = false } = this.props;
- return (
-
- {!withoutSearch && this.renderToolTipIcon('Search packages', 'search')}
- {this.renderToolTipIcon('Documentation', 'help')}
- {this.renderToolTipIcon('Registry Information', 'info')}
- {username ? (
- this.renderMenu()
- ) : (
-
- )}
-
- );
- };
-
- private renderGreetings = () => {
- const { username = '' } = this.props;
- return (
-
- {'Hi,'}
-
-
- );
- };
-
- /**
- * render popover menu
- */
- private renderMenu = () => {
- const { onLogout } = this.props;
- const { anchorEl } = this.state;
- const open = Boolean(anchorEl);
- return (
- <>
-
-
- >
- );
- };
-
- private renderInfoDialog = () => {
- const { scope } = this.props;
- const { openInfoDialog, registryUrl } = this.state;
- return (
-
-
-
- );
- };
-}
+
+
+
+ )}
+ >
+ );
+};
export default Header;
diff --git a/src/components/Header/HeaderGreetings.tsx b/src/components/Header/HeaderGreetings.tsx
new file mode 100644
index 0000000..4a76ae8
--- /dev/null
+++ b/src/components/Header/HeaderGreetings.tsx
@@ -0,0 +1,18 @@
+import React from 'react';
+
+import Label from '../Label';
+
+import { Greetings } from './styles';
+
+interface Props {
+ username: string;
+}
+
+const HeaderGreetings: React.FC = ({ username }) => (
+ <>
+ {'Hi,'}
+
+ >
+);
+
+export default HeaderGreetings;
diff --git a/src/components/Header/HeaderInfoDialog.tsx b/src/components/Header/HeaderInfoDialog.tsx
new file mode 100644
index 0000000..fb0af8f
--- /dev/null
+++ b/src/components/Header/HeaderInfoDialog.tsx
@@ -0,0 +1,19 @@
+import React from 'react';
+
+import RegistryInfoDialog from '../RegistryInfoDialog';
+import RegistryInfoContent from '../RegistryInfoContent';
+
+interface Props {
+ isOpen: boolean;
+ onCloseDialog: () => void;
+ registryUrl: string;
+ scope: string;
+}
+
+const HeaderInfoDialog: React.FC = ({ onCloseDialog, isOpen, registryUrl, scope }) => (
+
+
+
+);
+
+export default HeaderInfoDialog;
diff --git a/src/components/Header/HeaderLeft.tsx b/src/components/Header/HeaderLeft.tsx
new file mode 100644
index 0000000..1b92079
--- /dev/null
+++ b/src/components/Header/HeaderLeft.tsx
@@ -0,0 +1,32 @@
+import React from 'react';
+import { css } from 'emotion';
+import { Link } from 'react-router-dom';
+
+import Search from '../Search/';
+
+import HeaderLogo from './HeaderLogo';
+import { LeftSide, SearchWrapper } from './styles';
+
+interface Props {
+ withoutSearch?: boolean;
+ logo?: string;
+}
+
+const HeaderLeft: React.FC = ({ withoutSearch = false, logo }) => (
+
+
+
+
+ {!withoutSearch && (
+
+
+
+ )}
+
+);
+
+export default HeaderLeft;
diff --git a/src/components/Header/HeaderLogo.tsx b/src/components/Header/HeaderLogo.tsx
new file mode 100644
index 0000000..d2de7fe
--- /dev/null
+++ b/src/components/Header/HeaderLogo.tsx
@@ -0,0 +1,17 @@
+import React from 'react';
+
+import Logo from '../Logo';
+
+interface Props {
+ logo?: string;
+}
+
+const HeaderLogo: React.FC = ({ logo }) => {
+ if (logo) {
+ return ;
+ }
+
+ return ;
+};
+
+export default HeaderLogo;
diff --git a/src/components/Header/HeaderMenu.tsx b/src/components/Header/HeaderMenu.tsx
new file mode 100644
index 0000000..9b55224
--- /dev/null
+++ b/src/components/Header/HeaderMenu.tsx
@@ -0,0 +1,47 @@
+import React, { MouseEvent } from 'react';
+import IconButton from '@material-ui/core/IconButton';
+import MenuItem from '@material-ui/core/MenuItem';
+import Menu from '@material-ui/core/Menu';
+import AccountCircle from '@material-ui/icons/AccountCircle';
+
+import HeaderGreetings from './HeaderGreetings';
+
+interface Props {
+ username: string;
+ isMenuOpen: boolean;
+ anchorEl?: Element | ((element: Element) => Element) | null | undefined;
+ onLogout: () => void;
+ onLoggedInMenu: (event: MouseEvent) => void;
+ onLoggedInMenuClose: () => void;
+}
+
+/* eslint-disable react/jsx-max-depth */
+const HeaderMenu: React.FC = ({ onLogout, username, isMenuOpen = false, anchorEl, onLoggedInMenu, onLoggedInMenuClose }) => (
+ <>
+
+
+ >
+);
+
+export default HeaderMenu;
diff --git a/src/components/Header/HeaderRight.tsx b/src/components/Header/HeaderRight.tsx
new file mode 100644
index 0000000..238e713
--- /dev/null
+++ b/src/components/Header/HeaderRight.tsx
@@ -0,0 +1,70 @@
+import React, { useState, useEffect, MouseEvent } from 'react';
+import Button from '@material-ui/core/Button';
+
+import { RightSide } from './styles';
+import HeaderToolTip from './HeaderToolTip';
+import HeaderMenu from './HeaderMenu';
+
+interface Props {
+ withoutSearch?: boolean;
+ username?: string;
+ onToggleLogin: () => void;
+ onOpenRegistryInfoDialog: () => void;
+ onToggleMobileNav: () => void;
+ onLogout: () => void;
+}
+
+const HeaderRight: React.FC = ({ withoutSearch = false, username, onToggleLogin, onLogout, onToggleMobileNav, onOpenRegistryInfoDialog }) => {
+ const [anchorEl, setAnchorEl] = useState();
+ const [isMenuOpen, setIsMenuOpen] = useState();
+
+ useEffect(() => {
+ setIsMenuOpen(Boolean(anchorEl));
+ }, [anchorEl]);
+
+ /**
+ * opens popover menu for logged in user.
+ */
+ const handleLoggedInMenu = (event: MouseEvent) => {
+ setAnchorEl(event.currentTarget);
+ };
+
+ /**
+ * closes popover menu for logged in user
+ */
+ const handleLoggedInMenuClose = () => {
+ setAnchorEl(null);
+ };
+
+ /**
+ * close/open popover menu for logged in users.
+ */
+ const handleToggleLogin = () => {
+ setAnchorEl(null);
+ onToggleLogin();
+ };
+
+ return (
+
+ {!withoutSearch && }
+
+
+ {username ? (
+
+ ) : (
+
+ )}
+
+ );
+};
+
+export default HeaderRight;
diff --git a/src/components/Header/HeaderToolTip.tsx b/src/components/Header/HeaderToolTip.tsx
new file mode 100644
index 0000000..a0db053
--- /dev/null
+++ b/src/components/Header/HeaderToolTip.tsx
@@ -0,0 +1,18 @@
+import React from 'react';
+import Tooltip from '@material-ui/core/Tooltip';
+
+import HeaderToolTipIcon, { TooltipIconType } from './HeaderToolTipIcon';
+
+interface Props {
+ title: string;
+ tooltipIconType: TooltipIconType;
+ onClick?: () => void;
+}
+
+const HeaderToolTip: React.FC = ({ tooltipIconType, title, onClick }) => (
+
+
+
+);
+
+export default HeaderToolTip;
diff --git a/src/components/Header/HeaderToolTipIcon.tsx b/src/components/Header/HeaderToolTipIcon.tsx
new file mode 100644
index 0000000..501bb1b
--- /dev/null
+++ b/src/components/Header/HeaderToolTipIcon.tsx
@@ -0,0 +1,43 @@
+import React from 'react';
+import IconButton from '@material-ui/core/IconButton';
+import Info from '@material-ui/icons/Info';
+import Help from '@material-ui/icons/Help';
+import Search from '@material-ui/icons/Search';
+
+import { IconSearchButton, StyledExternalLink } from './styles';
+
+export type TooltipIconType = 'search' | 'help' | 'info';
+
+interface Props {
+ tooltipIconType: TooltipIconType;
+ onClick?: () => void;
+}
+
+const HeaderToolTipIcon: React.FC = ({ tooltipIconType, onClick }) => {
+ switch (tooltipIconType) {
+ case 'help':
+ return (
+
+
+
+
+
+ );
+ case 'info':
+ return (
+
+ );
+ case 'search':
+ return (
+
+
+
+ );
+ default:
+ return null;
+ }
+};
+
+export default HeaderToolTipIcon;
diff --git a/src/components/Header/__snapshots__/Header.test.tsx.snap b/src/components/Header/__snapshots__/Header.test.tsx.snap
index 0c3371b..a27a30f 100644
--- a/src/components/Header/__snapshots__/Header.test.tsx.snap
+++ b/src/components/Header/__snapshots__/Header.test.tsx.snap
@@ -1,5 +1,366 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
-exports[` component with logged in state should load the component in logged in state 1`] = `""`;
+exports[` component with logged in state should load the component in logged in state 1`] = `
+
+`;
-exports[` component with logged out state should load the component in logged out state 1`] = `""`;
+exports[` component with logged in state should load the component in logged out state 1`] = `
+
+`;
diff --git a/src/components/RegistryInfoDialog/RegistryInfoDialog.tsx b/src/components/RegistryInfoDialog/RegistryInfoDialog.tsx
index 403537d..d27a1f9 100644
--- a/src/components/RegistryInfoDialog/RegistryInfoDialog.tsx
+++ b/src/components/RegistryInfoDialog/RegistryInfoDialog.tsx
@@ -10,7 +10,7 @@ import { Props } from './types';
const LABEL = 'CLOSE';
const RegistryInfoDialog: React.FC = ({ open = false, children, onClose }) => (
-