2017-10-10 01:19:50 +02:00
|
|
|
import React from "react";
|
2017-10-12 06:25:53 +02:00
|
|
|
import CardMedia from "component/cardMedia";
|
2017-10-10 01:19:50 +02:00
|
|
|
import { TruncatedText, BusyMessage } from "component/common.js";
|
|
|
|
|
|
|
|
class ChannelTile extends React.PureComponent {
|
|
|
|
componentDidMount() {
|
2017-10-12 15:37:24 +02:00
|
|
|
const { uri, resolveUri } = this.props;
|
2017-10-10 01:19:50 +02:00
|
|
|
|
2017-10-12 15:37:24 +02:00
|
|
|
resolveUri(uri);
|
2017-10-10 01:19:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
componentWillReceiveProps(nextProps) {
|
2017-10-12 15:37:24 +02:00
|
|
|
const { uri, resolveUri } = this.props;
|
2017-10-10 01:19:50 +02:00
|
|
|
|
|
|
|
if (nextProps.uri != uri) {
|
2017-10-12 15:37:24 +02:00
|
|
|
resolveUri(uri);
|
2017-10-10 01:19:50 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
2017-10-12 15:37:24 +02:00
|
|
|
const { claim, navigate, isResolvingUri, totalItems, uri } = this.props;
|
2017-10-13 03:49:49 +02:00
|
|
|
const { name, claim_id } = claim;
|
2017-10-13 03:37:26 +02:00
|
|
|
|
2017-10-10 01:19:50 +02:00
|
|
|
let onClick = () => navigate("/show", { uri });
|
|
|
|
|
|
|
|
return (
|
|
|
|
<section className="file-tile card">
|
|
|
|
<div onClick={onClick} className="card__link">
|
2017-10-12 06:25:53 +02:00
|
|
|
<div className={"card__inner file-tile__row"}>
|
|
|
|
<CardMedia title={name} thumbnail={null} />
|
|
|
|
<div className="file-tile__content">
|
2017-10-13 03:37:26 +02:00
|
|
|
<div className="card__title-primary">
|
|
|
|
<h3>
|
|
|
|
<TruncatedText lines={1}>{claim.name}</TruncatedText>
|
|
|
|
</h3>
|
|
|
|
</div>
|
|
|
|
<div className="card__content card__subtext">
|
|
|
|
{isResolvingUri &&
|
|
|
|
<BusyMessage message={__("Resolving channel")} />}
|
|
|
|
{totalItems > 0 &&
|
|
|
|
<span>
|
|
|
|
This is a channel with {totalItems}{" "}
|
|
|
|
{totalItems === 1 ? " item" : " items"} inside of it.
|
|
|
|
</span>}
|
|
|
|
{!isResolvingUri &&
|
|
|
|
!totalItems &&
|
|
|
|
<span className="empty">This is an empty channel.</span>}
|
|
|
|
</div>
|
2017-10-10 01:19:50 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</section>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default ChannelTile;
|