ampache_react/app/components/Artists.jsx

48 lines
1.3 KiB
React
Raw Permalink Normal View History

// NPM imports
2016-07-07 23:23:18 +02:00
import React, { Component, PropTypes } from "react";
import Immutable from "immutable";
2016-07-07 23:23:18 +02:00
// Other components
2016-07-07 23:23:18 +02:00
import FilterablePaginatedGrid from "./elements/Grid";
import DismissibleAlert from "./elements/DismissibleAlert";
2016-07-07 23:23:18 +02:00
/**
* Paginated artists grid
*/
export default class Artists extends Component {
render() {
// Handle error
let error = null;
if (this.props.error) {
error = (<DismissibleAlert type="danger" text={this.props.error} />);
}
// Define grid props
const grid = {
isFetching: this.props.isFetching,
items: this.props.artists,
2016-08-02 13:07:12 +02:00
itemsType: "artist",
itemsLabel: "app.common.artist",
subItemsType: "albums",
subItemsLabel: "app.common.album",
buildLinkTo: (itemType, item) => {
2016-08-12 13:57:53 +02:00
return "/artist/" + item.get("id") + "-" + encodeURIComponent(item.get("name"));
},
};
2016-07-07 23:23:18 +02:00
return (
<div>
{ error }
<FilterablePaginatedGrid grid={grid} pagination={this.props.pagination} />
</div>
2016-07-07 23:23:18 +02:00
);
}
}
Artists.propTypes = {
error: PropTypes.string,
isFetching: PropTypes.bool.isRequired,
artists: PropTypes.instanceOf(Immutable.List).isRequired,
pagination: PropTypes.object.isRequired,
2016-07-07 23:23:18 +02:00
};