fix: remove redundant helper and guide code from Header

This commit is contained in:
Oliver Eyton-Williams
2019-07-26 11:46:03 +02:00
committed by mrugesh
parent 8ae0044682
commit 67d49efd1e
3 changed files with 4 additions and 26 deletions

View File

@ -9,12 +9,11 @@ import { Link } from '../helpers';
import './header.css'; import './header.css';
const propTypes = { const propTypes = {
disableSettings: PropTypes.bool, disableSettings: PropTypes.bool
navigationMenu: PropTypes.element
}; };
function Header(props) { function Header(props) {
const { disableSettings, navigationMenu } = props; const { disableSettings } = props;
return ( return (
<header> <header>
<nav id='top-nav'> <nav id='top-nav'>
@ -22,11 +21,7 @@ function Header(props) {
<NavLogo /> <NavLogo />
</Link> </Link>
{disableSettings ? null : <SearchBar />} {disableSettings ? null : <SearchBar />}
{navigationMenu ? (
navigationMenu
) : (
<NavigationMenu disableSettings={disableSettings} /> <NavigationMenu disableSettings={disableSettings} />
)}
</nav> </nav>
</header> </header>
); );

View File

@ -67,7 +67,6 @@ const propTypes = {
isOnline: PropTypes.bool.isRequired, isOnline: PropTypes.bool.isRequired,
isSignedIn: PropTypes.bool, isSignedIn: PropTypes.bool,
landingPage: PropTypes.bool, landingPage: PropTypes.bool,
navigationMenu: PropTypes.element,
onlineStatusChange: PropTypes.func.isRequired, onlineStatusChange: PropTypes.func.isRequired,
pathname: PropTypes.string.isRequired, pathname: PropTypes.string.isRequired,
removeFlashMessage: PropTypes.func.isRequired, removeFlashMessage: PropTypes.func.isRequired,
@ -131,7 +130,6 @@ class DefaultLayout extends Component {
isOnline, isOnline,
isSignedIn, isSignedIn,
landingPage, landingPage,
navigationMenu,
removeFlashMessage, removeFlashMessage,
showFooter = true showFooter = true
} = this.props; } = this.props;
@ -151,10 +149,7 @@ class DefaultLayout extends Component {
<style>{fontawesome.dom.css()}</style> <style>{fontawesome.dom.css()}</style>
</Helmet> </Helmet>
<WithInstantSearch> <WithInstantSearch>
<Header <Header disableSettings={landingPage} />
disableSettings={landingPage}
navigationMenu={navigationMenu}
/>
<div <div
className={`default-layout ${landingPage ? 'landing-page' : ''}`} className={`default-layout ${landingPage ? 'landing-page' : ''}`}
> >

View File

@ -1,12 +0,0 @@
exports.getGithubPath = function getGithubPath(fileAbsolutePath) {
const { NODE_ENV: env } = process.env;
const guideType = env === 'production' ? 'guide' : 'mock-guide';
let githubFilePath =
'https://github.com/freeCodeCamp/freeCodeCamp/blob/master/CONTRIBUTING.md#research-write-and-update-our-guide-articles';
const pathIndex = fileAbsolutePath.indexOf(`/${guideType}`);
if (pathIndex > -1) {
const newPath = fileAbsolutePath.slice(pathIndex);
githubFilePath = `https://github.com/freeCodeCamp/freeCodeCamp/blob/master${newPath}`;
}
return githubFilePath;
};