diff --git a/src/components/auth-block.js b/src/components/auth-block.js index 7c28ce7f..6c598213 100644 --- a/src/components/auth-block.js +++ b/src/components/auth-block.js @@ -30,10 +30,15 @@ const AuthBlock = ({ current_user, is_logged_in }) => { if (is_logged_in) { const logoutUrl = '/api/v1/logout'; + let user = {}; + if (current_user) { + user = current_user.user; + } + return (
- + Profile settings
diff --git a/src/components/bookmarks/bookmark.js b/src/components/bookmarks/bookmark.js new file mode 100644 index 00000000..f744736a --- /dev/null +++ b/src/components/bookmarks/bookmark.js @@ -0,0 +1,64 @@ +/* + This file is a part of libertysoil.org website + Copyright (C) 2016 Loki Education (Social Enterprise) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 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 Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . +*/ +import React, { PropTypes } from 'react'; + +import NavigationItem from '../navigation-item'; +import Icon from '../icon'; + +/** + * An example of bookmark object + { + className: 'navigation-item--color_blue', + to: '/bookmark-url', + title: 'Bookmark Example', + icon: { icon: 'public' } + } +**/ + +export default class Bookmark extends React.Component { + static propTypes = { + i: PropTypes.number, + onSettingsClick: PropTypes.func, + title: PropTypes.string + }; + + static defaultProps = { + onSettingsClick: () => {} + }; + + handleSettingsClick = (e) => { + const { i, onSettingsClick } = this.props; + + e.preventDefault(); + onSettingsClick(i); + }; + + render() { + const { title, ...props } = this.props; + + return ( + } + theme="2.0" + {...props} + > + {title} + + ); + } +} diff --git a/src/components/v2/bookmarks.js b/src/components/bookmarks/bookmarks.js similarity index 52% rename from src/components/v2/bookmarks.js rename to src/components/bookmarks/bookmarks.js index fe08ef29..f4f2073b 100644 --- a/src/components/v2/bookmarks.js +++ b/src/components/bookmarks/bookmarks.js @@ -16,13 +16,13 @@ along with this program. If not, see . */ import React, { PropTypes } from 'react'; +import { isNull } from 'lodash'; -// v1 +import Bookmark from './bookmark'; import Navigation from '../navigation'; -import NavigationItem from '../navigation-item'; -import Icon from '../icon'; +import BookmarkSettingsModal from './settings-modal'; -class Bookmarks extends React.Component { +export default class Bookmarks extends React.Component { static propTypes = { bookmarks: PropTypes.arrayOf(PropTypes.shape({})) }; @@ -31,46 +31,54 @@ class Bookmarks extends React.Component { super(props); this.state = { - showSettings: false + activeSettings: null }; } - handleSettingsClick = (e) => { - const { showSettings } = this.state; + handleSettingsClick = (i) => { + this.setState({ activeSettings: i }); + }; - console.log(e); - this.setState({ showSettings: !showSettings }); + handleModalClose = () => { + this.setState({ activeSettings: null }); + }; + + renderModal = () => { + const i = this.state.activeSettings; + if (isNull(i)) { + return false; + } + + const current = this.props.bookmarks[i]; + return ( + + ); }; render() { const { bookmarks } = this.props; + if (!bookmarks) { + return