2017-09-17 22:33:52 +02:00
|
|
|
import React from "react";
|
|
|
|
import ReactMarkdown from "react-markdown";
|
|
|
|
import lbry from "lbry.js";
|
|
|
|
import FileActions from "component/fileActions";
|
|
|
|
import Link from "component/link";
|
|
|
|
import DateTime from "component/dateTime";
|
|
|
|
|
2017-09-20 14:47:08 +02:00
|
|
|
const path = require("path");
|
|
|
|
|
2017-09-17 22:33:52 +02:00
|
|
|
class FileDetails extends React.PureComponent {
|
|
|
|
render() {
|
2017-09-20 14:47:08 +02:00
|
|
|
const {
|
|
|
|
claim,
|
|
|
|
contentType,
|
|
|
|
fileInfo,
|
|
|
|
metadata,
|
|
|
|
openFolder,
|
|
|
|
uri,
|
|
|
|
} = this.props;
|
2017-09-17 22:33:52 +02:00
|
|
|
|
|
|
|
if (!claim || !metadata) {
|
|
|
|
return (
|
|
|
|
<div className="card__content">
|
|
|
|
<span className="empty">{__("Empty claim or metadata info.")}</span>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
const { description, language, license } = metadata;
|
|
|
|
const { height } = claim;
|
|
|
|
const mediaType = lbry.getMediaType(contentType);
|
2017-09-23 06:22:55 +02:00
|
|
|
|
|
|
|
const downloadPath = fileInfo
|
|
|
|
? path.normalize(fileInfo.download_path)
|
2017-09-20 14:47:08 +02:00
|
|
|
: null;
|
2017-09-17 22:33:52 +02:00
|
|
|
|
2017-09-23 06:22:55 +02:00
|
|
|
const directory = downloadPath ? path.dirname(downloadPath) : null;
|
|
|
|
|
2017-09-17 22:33:52 +02:00
|
|
|
return (
|
|
|
|
<div>
|
|
|
|
<FileActions uri={uri} />
|
|
|
|
<div className="card__content card__subtext card__subtext--allow-newlines">
|
|
|
|
<ReactMarkdown
|
|
|
|
source={description || ""}
|
|
|
|
escapeHtml={true}
|
|
|
|
disallowedTypes={["Heading", "HtmlInline", "HtmlBlock"]}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
<div className="card__content">
|
|
|
|
<table className="table-standard table-stretch">
|
|
|
|
<tbody>
|
|
|
|
<tr>
|
|
|
|
<td>{__("Published on")}</td>
|
|
|
|
<td><DateTime block={height} /></td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td>{__("Content-Type")}</td><td>{mediaType}</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td>{__("Language")}</td><td>{language}</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td>{__("License")}</td><td>{license}</td>
|
|
|
|
</tr>
|
2017-09-20 14:47:08 +02:00
|
|
|
{directory &&
|
|
|
|
<tr>
|
|
|
|
<td>{__("Downloaded to")}</td>
|
|
|
|
<td>
|
2017-09-23 06:22:55 +02:00
|
|
|
<Link onClick={() => openFolder(downloadPath)}>
|
2017-09-20 14:47:08 +02:00
|
|
|
{directory}
|
|
|
|
</Link>
|
|
|
|
</td>
|
|
|
|
</tr>}
|
2017-09-17 22:33:52 +02:00
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
<p>
|
|
|
|
<Link
|
|
|
|
href={`https://lbry.io/dmca?claim_id=${claim.claim_id}`}
|
|
|
|
label={__("report")}
|
|
|
|
/>
|
|
|
|
</p>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default FileDetails;
|