forked from spiffe/tornjak
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
I have refactored the main user interface for Tornjak after addressing the issue of windows new line. Please test for functionality. Signed-off-by: Kai Chen <[email protected]>
- Loading branch information
1 parent
1bbbc34
commit 12e953d
Showing
29 changed files
with
647 additions
and
263 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import React from 'react'; | ||
import { Link } from 'react-router-dom'; | ||
import { ChevronDown } from '@carbon/icons-react'; | ||
|
||
interface NavDropdownProps { | ||
icon: React.ReactNode; | ||
title: string; | ||
link: string; | ||
isAdmin: boolean; | ||
withAuth: boolean; | ||
subLinks: Array<{ | ||
label: string; | ||
to: string; | ||
adminOnly?: boolean; | ||
}>; | ||
} | ||
|
||
interface NavDropdownState { | ||
isOpen: boolean; | ||
} | ||
|
||
class NavDropdown extends React.Component<NavDropdownProps, NavDropdownState> { | ||
constructor(props: NavDropdownProps) { | ||
super(props); | ||
this.state = { | ||
isOpen: false, | ||
}; | ||
} | ||
|
||
toggleDropdown = () => { | ||
this.setState((prevState) => ({ | ||
isOpen: !prevState.isOpen, | ||
})); | ||
}; | ||
|
||
render() { | ||
const { icon, title, link, isAdmin, withAuth, subLinks } = this.props; | ||
const { isOpen } = this.state; | ||
|
||
return ( | ||
<div> | ||
<div className="dropdown-header"> | ||
{icon} | ||
<Link to={link} className="dropbtn"> | ||
{title} | ||
</Link> | ||
<ChevronDown | ||
className="icon_spacing_drop" | ||
onClick={this.toggleDropdown} | ||
/> | ||
</div> | ||
{isOpen && ( | ||
<div className="dropdown-content"> | ||
{subLinks.map((subLink, index) => { | ||
if (subLink.adminOnly && !(isAdmin || !withAuth)) { | ||
return null; | ||
} | ||
return ( | ||
<Link key={index} to={subLink.to} className="nav-link"> | ||
{subLink.label} | ||
</Link> | ||
); | ||
})} | ||
</div> | ||
)} | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
export default NavDropdown; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.