2017-12-21 22:08:54 +01:00
|
|
|
import React from 'react';
|
|
|
|
import { BusyMessage } from 'component/common';
|
|
|
|
import ChannelPage from 'page/channel';
|
|
|
|
import FilePage from 'page/file';
|
2017-05-05 08:13:06 +02:00
|
|
|
|
2018-01-09 02:15:44 +01:00
|
|
|
class ShowPage extends React.PureComponent {
|
2017-05-10 05:06:48 +02:00
|
|
|
componentWillMount() {
|
2017-10-12 16:05:18 +02:00
|
|
|
const { isResolvingUri, resolveUri, uri } = this.props;
|
2017-05-12 01:28:43 +02:00
|
|
|
|
2017-10-12 16:05:18 +02:00
|
|
|
if (!isResolvingUri) resolveUri(uri);
|
2017-05-12 01:28:43 +02:00
|
|
|
}
|
|
|
|
|
2018-01-09 02:15:44 +01:00
|
|
|
componentWillReceiveProps(nextProps) {
|
2017-10-12 16:05:18 +02:00
|
|
|
const { isResolvingUri, resolveUri, claim, uri } = nextProps;
|
2017-05-10 05:06:48 +02:00
|
|
|
|
2017-10-12 16:05:18 +02:00
|
|
|
if (!isResolvingUri && claim === undefined && uri) {
|
|
|
|
resolveUri(uri);
|
|
|
|
}
|
2017-05-10 05:06:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
2017-09-08 05:15:05 +02:00
|
|
|
const { claim, isResolvingUri, uri } = this.props;
|
2017-05-05 08:13:06 +02:00
|
|
|
|
2017-12-21 22:08:54 +01:00
|
|
|
let innerContent = '';
|
2017-05-05 08:13:06 +02:00
|
|
|
|
2017-07-06 09:47:02 +02:00
|
|
|
if ((isResolvingUri && !claim) || !claim) {
|
2017-06-06 23:19:12 +02:00
|
|
|
innerContent = (
|
|
|
|
<section className="card">
|
|
|
|
<div className="card__inner">
|
2017-11-24 15:31:05 +01:00
|
|
|
<div className="card__title-identity">
|
|
|
|
<h1>{uri}</h1>
|
|
|
|
</div>
|
2017-06-06 23:19:12 +02:00
|
|
|
</div>
|
|
|
|
<div className="card__content">
|
2017-12-21 22:08:54 +01:00
|
|
|
{isResolvingUri && <BusyMessage message={__('Loading magic decentralized data...')} />}
|
2017-06-06 23:19:12 +02:00
|
|
|
{claim === null &&
|
2017-11-24 15:31:05 +01:00
|
|
|
!isResolvingUri && (
|
2017-12-21 22:08:54 +01:00
|
|
|
<span className="empty">{__("There's nothing at this location.")}</span>
|
2017-11-24 15:31:05 +01:00
|
|
|
)}
|
2017-06-06 23:19:12 +02:00
|
|
|
</div>
|
|
|
|
</section>
|
|
|
|
);
|
2017-12-21 22:08:54 +01:00
|
|
|
} else if (claim && claim.name.length && claim.name[0] === '@') {
|
2017-06-06 23:19:12 +02:00
|
|
|
innerContent = <ChannelPage uri={uri} />;
|
|
|
|
} else if (claim) {
|
|
|
|
innerContent = <FilePage uri={uri} />;
|
2017-05-05 08:13:06 +02:00
|
|
|
}
|
|
|
|
|
2018-01-09 02:15:44 +01:00
|
|
|
return <main className="main--single-column">{innerContent}</main>;
|
2017-05-10 05:06:48 +02:00
|
|
|
}
|
2017-05-05 08:13:06 +02:00
|
|
|
}
|
|
|
|
|
2017-06-06 06:21:55 +02:00
|
|
|
export default ShowPage;
|