-
Notifications
You must be signed in to change notification settings - Fork 164
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
510 additions
and
530 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
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
117 changes: 89 additions & 28 deletions
117
src/commons/navigationBar/subcomponents/GitHubAssessmentsNavigationBar.tsx
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 |
---|---|---|
@@ -1,42 +1,103 @@ | ||
import { Alignment, Classes, Icon, Navbar, NavbarGroup } from '@blueprintjs/core'; | ||
import { | ||
Alignment, | ||
Button, | ||
Classes, | ||
Icon, | ||
InputGroup, | ||
Menu, | ||
MenuItem, | ||
Navbar, | ||
NavbarGroup | ||
} from '@blueprintjs/core'; | ||
import { IconNames } from '@blueprintjs/icons'; | ||
import { Popover2 } from '@blueprintjs/popover2'; | ||
import { Octokit } from '@octokit/rest'; | ||
import classNames from 'classnames'; | ||
import * as React from 'react'; | ||
import { NavLink } from 'react-router-dom'; | ||
|
||
import { ControlBarGitHubLoginButton } from '../../controlBar/github/ControlBarGitHubLoginButton'; | ||
|
||
type OwnProps = { | ||
handleGitHubLogIn: any; | ||
handleGitHubLogOut: any; | ||
type GitHubAssessmentsNavigationBarProps = DispatchProps & StateProps; | ||
|
||
type DispatchProps = { | ||
handleGitHubLogIn: () => void; | ||
handleGitHubLogOut: () => void; | ||
}; | ||
|
||
type StateProps = { | ||
octokit: Octokit | undefined; | ||
courses: string[]; | ||
selectedCourse: string; | ||
setSelectedCourse: (course: string) => void; | ||
typeNames: string[]; | ||
}; | ||
|
||
/** | ||
* The white navbar for the website. Should only be displayed when using GitHub-hosted missions. | ||
* | ||
* @param props Component properties | ||
*/ | ||
const GitHubAssessmentsNavigationBar: React.FunctionComponent<OwnProps> = props => ( | ||
<Navbar className="NavigationBar secondary-navbar"> | ||
<NavbarGroup align={Alignment.LEFT}> | ||
<NavLink | ||
to={`/githubassessments/missions`} | ||
activeClassName={Classes.ACTIVE} | ||
className={classNames('NavigationBar__link', Classes.BUTTON, Classes.MINIMAL)} | ||
> | ||
<Icon icon={IconNames.FLAME} /> | ||
<div className="navbar-button-text hidden-xs hidden-sm">Missions</div> | ||
</NavLink> | ||
</NavbarGroup> | ||
|
||
<NavbarGroup align={Alignment.RIGHT}> | ||
<ControlBarGitHubLoginButton | ||
key="github" | ||
onClickLogIn={props.handleGitHubLogIn} | ||
onClickLogOut={props.handleGitHubLogOut} | ||
/> | ||
</NavbarGroup> | ||
</Navbar> | ||
); | ||
const GitHubAssessmentsNavigationBar: React.FC<GitHubAssessmentsNavigationBarProps> = props => { | ||
const handleClick = (e: any) => { | ||
handleChange(e); | ||
}; | ||
|
||
const handleChange = (e: any) => { | ||
props.setSelectedCourse(e.target.innerText); | ||
}; | ||
|
||
return ( | ||
<Navbar className="NavigationBar secondary-navbar"> | ||
<NavbarGroup align={Alignment.LEFT}> | ||
{props.typeNames.map(typeName => { | ||
return ( | ||
<NavLink | ||
key={typeName} | ||
exact={true} | ||
to={{ | ||
pathname: `${typeName}`, | ||
state: props.selectedCourse | ||
}} | ||
activeClassName={Classes.ACTIVE} | ||
className={classNames('NavigationBar__link', Classes.BUTTON, Classes.MINIMAL)} | ||
> | ||
<Icon icon={IconNames.FLAME} /> | ||
<div className="navbar-button-text hidden-xs hidden-sm">{typeName}</div> | ||
</NavLink> | ||
); | ||
})} | ||
</NavbarGroup> | ||
<NavbarGroup align={Alignment.RIGHT}> | ||
{props.octokit !== undefined && ( | ||
<InputGroup | ||
key="courseselect" | ||
disabled={true} | ||
leftElement={ | ||
<Popover2 | ||
content={ | ||
<Menu> | ||
{props.courses.map((course: string) => ( | ||
<MenuItem key={course} onClick={handleClick} text={course} /> | ||
))} | ||
</Menu> | ||
} | ||
placement={'bottom-end'} | ||
> | ||
<Button minimal={true} rightIcon="caret-down" /> | ||
</Popover2> | ||
} | ||
placeholder={'Select Course'} | ||
onChange={handleChange} | ||
value={props.selectedCourse} | ||
/> | ||
)} | ||
<ControlBarGitHubLoginButton | ||
key="loginlogout" | ||
onClickLogIn={props.handleGitHubLogIn} | ||
onClickLogOut={props.handleGitHubLogOut} | ||
/> | ||
</NavbarGroup> | ||
</Navbar> | ||
); | ||
}; | ||
|
||
export default GitHubAssessmentsNavigationBar; |
8 changes: 7 additions & 1 deletion
8
src/commons/navigationBar/subcomponents/__tests__/GitHubAssessmentsNavigationBar.tsx
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.