lbry-desktop/src/renderer/component/fileDetails/view.jsx

82 lines
2.1 KiB
React
Raw Normal View History

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";
const path = require("path");
2017-09-17 22:33:52 +02:00
class FileDetails extends React.PureComponent {
render() {
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 mediaType = lbry.getMediaType(contentType);
2017-09-23 06:22:55 +02:00
const downloadPath = fileInfo
? path.normalize(fileInfo.download_path)
: null;
2017-09-17 22:33:52 +02:00
return (
<div>
2017-10-10 05:10:59 +02:00
<div className="divider__horizontal" />
2017-09-17 22:33:52 +02:00
<FileActions uri={uri} />
2017-10-10 05:10:59 +02:00
<div className="divider__horizontal" />
2017-09-17 22:33:52 +02:00
<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>
2017-11-24 15:31:05 +01:00
<td>{__("Content-Type")}</td>
<td>{mediaType}</td>
2017-09-17 22:33:52 +02:00
</tr>
<tr>
2017-11-24 15:31:05 +01:00
<td>{__("Language")}</td>
<td>{language}</td>
2017-09-17 22:33:52 +02:00
</tr>
<tr>
2017-11-24 15:31:05 +01:00
<td>{__("License")}</td>
<td>{license}</td>
2017-09-17 22:33:52 +02:00
</tr>
2017-11-24 15:31:05 +01:00
{downloadPath && (
<tr>
<td>{__("Downloaded to")}</td>
<td>
2017-09-23 06:22:55 +02:00
<Link onClick={() => openFolder(downloadPath)}>
2017-09-24 06:46:22 +02:00
{downloadPath}
</Link>
</td>
2017-11-24 15:31:05 +01:00
</tr>
)}
2017-09-17 22:33:52 +02:00
</tbody>
</table>
</div>
</div>
);
}
}
export default FileDetails;