diff --git a/src/shared/components/app/navbar.tsx b/src/shared/components/app/navbar.tsx index d92ec259..25c3a306 100644 --- a/src/shared/components/app/navbar.tsx +++ b/src/shared/components/app/navbar.tsx @@ -1,4 +1,4 @@ -import { Component, linkEvent } from "inferno"; +import { Component, createRef, linkEvent } from "inferno"; import { NavLink } from "inferno-router"; import { CommentResponse, @@ -39,14 +39,22 @@ interface NavbarProps { } interface NavbarState { - expanded: boolean; unreadInboxCount: number; unreadReportCount: number; unreadApplicationCount: number; - showDropdown: boolean; onSiteBanner?(url: string): any; } +function handleCollapseClick(i: Navbar) { + if (i.collapseButtonRef.current?.ariaExpanded === "true") { + i.collapseButtonRef.current?.click(); + } +} + +function handleLogOut() { + UserService.Instance.logout(); +} + export class Navbar extends Component { private wsSub: Subscription; private userSub: Subscription; @@ -57,10 +65,9 @@ export class Navbar extends Component { unreadInboxCount: 0, unreadReportCount: 0, unreadApplicationCount: 0, - expanded: false, - showDropdown: false, }; subscription: any; + collapseButtonRef = createRef(); constructor(props: any, context: any) { super(props, context); @@ -113,85 +120,228 @@ export class Navbar extends Component { this.unreadApplicationCountSub.unsubscribe(); } - render() { - return this.navbar(); - } - // TODO class active corresponding to current page - navbar() { - let siteView = this.props.siteRes?.site_view; - let person = UserService.Instance.myUserInfo?.local_user_view.person; + render() { + const siteView = this.props.siteRes?.site_view; + const person = UserService.Instance.myUserInfo?.local_user_view.person; return ( - ); @@ -464,23 +443,6 @@ export class Navbar extends Component { return amAdmin() || moderatesS; } - handleToggleExpandNavbar(i: Navbar) { - i.setState({ expanded: !i.state.expanded }); - } - - handleHideExpandNavbar(i: Navbar) { - i.setState({ expanded: false, showDropdown: false }); - } - - handleLogoutClick(i: Navbar) { - i.setState({ showDropdown: false, expanded: false }); - UserService.Instance.logout(); - } - - handleToggleDropdown(i: Navbar) { - i.setState({ showDropdown: !i.state.showDropdown }); - } - parseMessage(msg: any) { let op = wsUserOp(msg); console.log(msg);