Phyks (Lucas Verney)
fffe9c4cd3
Major code review, cleaning the code and adding a lot of comments. Also implements a separate store to keep entities with a reference count and garbage collection. This closes #15. Known issues at the moment are: * Webplayer is no longer working, it has to be refactored. * AlbumPage is to be implemented.
45 lines
1.2 KiB
JavaScript
45 lines
1.2 KiB
JavaScript
// NPM imports
|
|
import React, { Component, PropTypes } from "react";
|
|
import Immutable from "immutable";
|
|
|
|
// Local imports
|
|
import FilterablePaginatedGrid from "./elements/Grid";
|
|
import DismissibleAlert from "./elements/DismissibleAlert";
|
|
|
|
|
|
/**
|
|
* Paginated albums grid
|
|
*/
|
|
export default class Albums extends Component {
|
|
render () {
|
|
// Handle error
|
|
let error = null;
|
|
if (this.props.error) {
|
|
error = (<DismissibleAlert type="danger" text={this.props.error} />);
|
|
}
|
|
|
|
// Set grid props
|
|
const grid = {
|
|
isFetching: this.props.isFetching,
|
|
items: this.props.albums,
|
|
itemsType: "album",
|
|
itemsLabel: "app.common.album",
|
|
subItemsType: "tracks",
|
|
subItemsLabel: "app.common.track"
|
|
};
|
|
|
|
return (
|
|
<div>
|
|
{ error }
|
|
<FilterablePaginatedGrid grid={grid} pagination={this.props.pagination} />
|
|
</div>
|
|
);
|
|
}
|
|
}
|
|
Albums.propTypes = {
|
|
error: PropTypes.string,
|
|
isFetching: PropTypes.bool.isRequired,
|
|
albums: PropTypes.instanceOf(Immutable.List).isRequired,
|
|
pagination: PropTypes.object.isRequired,
|
|
};
|