src/client/containers/editor.js
/*
* Copyright (C) 2016 Daniel Hsing
* 2016 Ben Ockmore
* 2016 Max Prettyjohns
* 2016 Sean Burke
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
import * as bootstrap from 'react-bootstrap';
import PropTypes from 'prop-types';
import React from 'react';
const {Col, Nav, Row} = bootstrap;
function EditorContainer(props) {
const {tabActive, editor, children, user} = props;
return (
<div>
<Row>
<Col lg={12}>
{editor.title ?
<div>
<a
href=" "
title={editor.title.description}
>
<h1>
{`${editor.title.title} ${editor.name}`}
</h1>
</a>
</div> :
<h1>
{editor.name}
</h1>
}
</Col>
</Row>
<Row>
<Col lg={12}>
<Nav variant="tabs">
<Nav.Item>
<Nav.Link
active={tabActive === 0}
href={`/editor/${editor.id}`}
>
Profile
</Nav.Link>
</Nav.Item>
<Nav.Item>
<Nav.Link
active={tabActive === 1}
href={`/editor/${editor.id}/revisions`}
>
Revisions
</Nav.Link>
</Nav.Item>
<Nav.Item>
<Nav.Link
active={tabActive === 2}
href={`/editor/${editor.id}/achievements`}
>
Achievements
</Nav.Link>
</Nav.Item>
<Nav.Item>
<Nav.Link
active={tabActive === 3}
href={`/editor/${editor.id}/collections`}
>
Collections
</Nav.Link>
</Nav.Item>
{
user && user.id === editor.id ?
(
<Nav.Item>
<Nav.Link
active={tabActive === 4}
href="/external-service"
>
External Services
</Nav.Link>
</Nav.Item>
) : null
}
</Nav>
</Col>
</Row>
{children}
</div>
);
}
EditorContainer.displayName = 'EditorContainer';
EditorContainer.propTypes = {
children: PropTypes.node.isRequired,
editor: PropTypes.shape({
id: PropTypes.number,
name: PropTypes.string,
title: PropTypes.object
}).isRequired,
tabActive: PropTypes.number.isRequired,
user: PropTypes.object
};
EditorContainer.defaultProps = {
user: null
};
export default EditorContainer;