ampache_react/app/components/layouts/Sidebar.jsx

140 lines
8.8 KiB
React
Raw Normal View History

import React, { Component, PropTypes } from "react";
2016-07-07 23:23:18 +02:00
import { IndexLink, Link} from "react-router";
import { defineMessages, injectIntl, intlShape, FormattedMessage } from "react-intl";
2016-07-07 23:23:18 +02:00
import { messagesMap } from "../../utils";
import commonMessages from "../../locales/messagesDescriptors/common";
import messages from "../../locales/messagesDescriptors/layouts/Sidebar";
const sidebarLayoutMessages = defineMessages(messagesMap(Array.concat([], commonMessages, messages)));
export default class SidebarLayoutIntl extends Component {
2016-07-07 23:23:18 +02:00
render () {
const { formatMessage } = this.props.intl;
2016-07-26 21:01:27 +02:00
const isActive = {
discover: (this.props.location.pathname == "/discover") ? "active" : "",
browse: (this.props.location.pathname == "/browse") ? "active" : "",
artists: (this.props.location.pathname == "/artists") ? "active" : "",
albums: (this.props.location.pathname == "/albums") ? "active" : "",
songs: (this.props.location.pathname == "/songs") ? "active" : "",
search: (this.props.location.pathname == "/search") ? "active" : ""
};
2016-07-07 23:23:18 +02:00
return (
<div>
2016-07-26 21:01:27 +02:00
<div className="col-sm-1 col-md-2 sidebar hidden-xs">
<h1 className="text-center">
<IndexLink to="/">
<img alt="A" src="./app/assets/img/ampache-blue.png"/>
<span className="hidden-sm">mpache</span>
</IndexLink>
</h1>
<nav aria-label={formatMessage(sidebarLayoutMessages["app.sidebarLayout.mainNavigationMenu"])}>
2016-07-07 23:23:18 +02:00
<div className="navbar text-center icon-navbar">
<div className="container-fluid">
<ul className="nav navbar-nav icon-navbar-nav">
2016-07-26 13:21:37 +02:00
<li>
<Link to="/" title={formatMessage(sidebarLayoutMessages["app.sidebarLayout.home"])}>
2016-07-26 21:01:27 +02:00
<span className="glyphicon glyphicon-home" aria-hidden="true"></span>
<span className="sr-only">
<FormattedMessage {...sidebarLayoutMessages["app.sidebarLayout.home"]} />
</span>
2016-07-26 21:01:27 +02:00
</Link>
2016-07-07 23:23:18 +02:00
</li>
2016-07-26 13:21:37 +02:00
<li>
<Link to="/settings" title={formatMessage(sidebarLayoutMessages["app.sidebarLayout.settings"])}>
2016-07-26 21:01:27 +02:00
<span className="glyphicon glyphicon-wrench" aria-hidden="true"></span>
<span className="sr-only">
<FormattedMessage {...sidebarLayoutMessages["app.sidebarLayout.settings"]} />
</span>
2016-07-26 21:01:27 +02:00
</Link>
2016-07-07 23:23:18 +02:00
</li>
2016-07-26 13:21:37 +02:00
<li>
<Link to="/logout" title={formatMessage(sidebarLayoutMessages["app.sidebarLayout.logout"])}>
2016-07-26 21:01:27 +02:00
<span className="glyphicon glyphicon-off" aria-hidden="true"></span>
<span className="sr-only">
<FormattedMessage {...sidebarLayoutMessages["app.sidebarLayout.logout"]} />
</span>
2016-07-26 21:01:27 +02:00
</Link>
2016-07-07 23:23:18 +02:00
</li>
</ul>
</div>
</div>
<ul className="nav nav-sidebar">
<li>
<Link to="/discover" title={formatMessage(sidebarLayoutMessages["app.sidebarLayout.discover"])} className={isActive.discover}>
2016-07-07 23:23:18 +02:00
<span className="glyphicon glyphicon-globe" aria-hidden="true"></span>
<span className="hidden-sm">
&nbsp;<FormattedMessage {...sidebarLayoutMessages["app.sidebarLayout.discover"]} />
</span>
2016-07-07 23:23:18 +02:00
</Link>
</li>
<li>
<Link to="/browse" title={formatMessage(sidebarLayoutMessages["app.sidebarLayout.browse"])} className={isActive.browse}>
2016-07-07 23:23:18 +02:00
<span className="glyphicon glyphicon-headphones" aria-hidden="true"></span>
<span className="hidden-sm">
&nbsp;<FormattedMessage {...sidebarLayoutMessages["app.sidebarLayout.browse"]} />
</span>
2016-07-07 23:23:18 +02:00
</Link>
2016-07-26 21:01:27 +02:00
<ul className="nav nav-list text-center">
<li>
<Link to="/artists" title={formatMessage(sidebarLayoutMessages["app.sidebarLayout.browseArtists"])} className={isActive.artists}>
2016-07-26 21:01:27 +02:00
<span className="glyphicon glyphicon-user" aria-hidden="true"></span>
2016-07-29 00:50:08 +02:00
<span className="sr-only">
<FormattedMessage {...sidebarLayoutMessages["app.common.artist"]} values={{itemCount: 42}} />
</span>
<span className="hidden-sm">
&nbsp;<FormattedMessage {...sidebarLayoutMessages["app.common.artist"]} values={{itemCount: 42}} />
</span>
2016-07-26 21:01:27 +02:00
</Link>
</li>
<li>
<Link to="/albums" title={formatMessage(sidebarLayoutMessages["app.sidebarLayout.browseAlbums"])} className={isActive.albums}>
2016-07-26 21:01:27 +02:00
<span className="glyphicon glyphicon-cd" aria-hidden="true"></span>
2016-07-29 00:50:08 +02:00
<span className="sr-only"><FormattedMessage {...sidebarLayoutMessages["app.common.album"]} values={{itemCount: 42}} /></span>
<span className="hidden-sm">
&nbsp;<FormattedMessage {...sidebarLayoutMessages["app.common.album"]} values={{itemCount: 42}} />
</span>
2016-07-26 21:01:27 +02:00
</Link>
</li>
<li>
<Link to="/songs" title={formatMessage(sidebarLayoutMessages["app.sidebarLayout.browseSongs"])} className={isActive.songs}>
2016-07-26 21:01:27 +02:00
<span className="glyphicon glyphicon-music" aria-hidden="true"></span>
2016-07-29 00:50:08 +02:00
<span className="sr-only">
<FormattedMessage {...sidebarLayoutMessages["app.common.song"]} values={{itemCount: 42}} />
</span>
<span className="hidden-sm">
&nbsp;<FormattedMessage {...sidebarLayoutMessages["app.common.song"]} values={{itemCount: 42}} />
</span>
2016-07-26 21:01:27 +02:00
</Link>
</li>
2016-07-07 23:23:18 +02:00
</ul>
</li>
<li>
<Link to="/search" title={formatMessage(sidebarLayoutMessages["app.sidebarLayout.search"])} className={isActive.search}>
2016-07-07 23:23:18 +02:00
<span className="glyphicon glyphicon-search" aria-hidden="true"></span>
<span className="hidden-sm">
&nbsp;<FormattedMessage {...sidebarLayoutMessages["app.sidebarLayout.search"]} />
</span>
2016-07-07 23:23:18 +02:00
</Link>
</li>
</ul>
</nav>
</div>
2016-07-26 21:01:27 +02:00
<div className="col-sm-11 col-sm-offset-1 col-md-10 col-md-offset-2 main-panel">
2016-07-07 23:23:18 +02:00
{this.props.children}
</div>
</div>
);
}
}
SidebarLayoutIntl.propTypes = {
children: PropTypes.node,
intl: intlShape.isRequired
};
export let SidebarLayout = injectIntl(SidebarLayoutIntl);
export default SidebarLayout;