From 935a76ab8dce7467ad68e4a6c890c254b386cfce Mon Sep 17 00:00:00 2001 From: James Kong Date: Fri, 18 Nov 2022 21:43:15 +0800 Subject: [PATCH] Display the Feeds Manager navigation link in mobile view drawer Adds the Feeds Manager navigation link to display in the Navigation Drawer when on mobile view --- .changeset/sweet-turkeys-mate.md | 5 + src/pages/Header.tsx | 161 ++++++++++++++++--------------- 2 files changed, 90 insertions(+), 76 deletions(-) create mode 100644 .changeset/sweet-turkeys-mate.md diff --git a/.changeset/sweet-turkeys-mate.md b/.changeset/sweet-turkeys-mate.md new file mode 100644 index 00000000..3bac4ade --- /dev/null +++ b/.changeset/sweet-turkeys-mate.md @@ -0,0 +1,5 @@ +--- +'@smartcontractkit/operator-ui': minor +--- + +Display the Feeds Manager navigation in the mobile navigation drawer diff --git a/src/pages/Header.tsx b/src/pages/Header.tsx index a6928659..483b6068 100644 --- a/src/pages/Header.tsx +++ b/src/pages/Header.tsx @@ -67,6 +67,7 @@ const drawerStyles = ({ palette, spacing }: Theme) => interface DrawerProps extends WithStyles { authenticated: boolean drawerOpen: boolean + isFeedsManagerFeatureEnabled: boolean toggleDrawer: () => void submitSignOut: () => void } @@ -78,6 +79,7 @@ const Drawer = withStyles(drawerStyles)( authenticated, classes, submitSignOut, + isFeedsManagerFeatureEnabled, }: DrawerProps) => { return ( ))} + {isFeedsManagerFeatureEnabled && ( + ( + + + + )} + className={classes.menuitem} + /> + )} + {authenticated && ( interface NavProps extends WithStyles { authenticated: boolean + isFeedsManagerFeatureEnabled: boolean } -const Nav = withStyles(navStyles)(({ authenticated, classes }: NavProps) => { - const { pathname } = useLocation() - const isFeedsManagerFeatureEnabled = useFeatureFlag(Feature.FeedsManager) +const Nav = withStyles(navStyles)( + ({ authenticated, classes, isFeedsManagerFeatureEnabled }: NavProps) => { + const { pathname } = useLocation() - return ( - - - {NAV_ITEMS.map(([navItemPath, text]) => ( - - - {text} - - - ))} - {/* Feeds Manager link hidden behind a feature flag. This is temporary until we + return ( + + + {NAV_ITEMS.map(([navItemPath, text]) => ( + + + {text} + + + ))} + {/* Feeds Manager link hidden behind a feature flag. This is temporary until we enable this for everyone */} - {isFeedsManagerFeatureEnabled && ( - - - Feeds Manager - - - )} - {authenticated && ( - <> + {isFeedsManagerFeatureEnabled && ( - - + + Feeds Manager + - - )} - - - ) -}) + )} + {authenticated && ( + <> + + + + + + )} + + + ) + }, +) const styles = ({ palette, spacing, zIndex }: Theme) => createStyles({ @@ -218,34 +234,21 @@ interface Props extends WithStyles { onResize: (width: number, height: number) => void } -interface State { - drawerOpen: boolean -} +const Header = withStyles(styles)( + ({ + authenticated, + classes, + fetchCount, + drawerContainer, + onResize, + submitSignOut, + }: Props) => { + const [drawerOpen, setDrawerOpen] = React.useState(false) + const isFeedsManagerFeatureEnabled = useFeatureFlag(Feature.FeedsManager) -class Header extends React.Component { - constructor(props: Props) { - super(props) - this.state = { - drawerOpen: false, + const toggleDrawer = () => { + setDrawerOpen(!drawerOpen) } - this.toggleDrawer = this.toggleDrawer.bind(this) - } - - toggleDrawer() { - this.setState({ - drawerOpen: !this.state.drawerOpen, - }) - } - - render() { - const { - authenticated, - classes, - fetchCount, - drawerContainer, - onResize, - submitSignOut, - } = this.props return ( @@ -270,13 +273,18 @@ class Header extends React.Component { -