2018-03-26 23:32:43 +02:00
|
|
|
// @flow
|
|
|
|
import * as React from 'react';
|
2018-06-10 23:57:46 +02:00
|
|
|
import MarkdownPreview from 'component/common/markdown-preview';
|
2018-03-26 23:32:43 +02:00
|
|
|
import Button from 'component/button';
|
|
|
|
import path from 'path';
|
2018-05-07 06:50:55 +02:00
|
|
|
import type { Claim } from 'types/claim';
|
2017-09-17 22:33:52 +02:00
|
|
|
|
2018-03-26 23:32:43 +02:00
|
|
|
type Props = {
|
2018-05-07 06:50:55 +02:00
|
|
|
claim: Claim,
|
2018-03-26 23:32:43 +02:00
|
|
|
fileInfo: {
|
|
|
|
download_path: string,
|
|
|
|
},
|
|
|
|
metadata: {
|
|
|
|
description: string,
|
|
|
|
language: string,
|
|
|
|
license: string,
|
|
|
|
},
|
|
|
|
openFolder: string => void,
|
|
|
|
contentType: string,
|
|
|
|
};
|
2017-09-20 14:47:08 +02:00
|
|
|
|
2018-03-26 23:32:43 +02:00
|
|
|
const FileDetails = (props: Props) => {
|
|
|
|
const { claim, contentType, fileInfo, metadata, openFolder } = props;
|
2017-09-17 22:33:52 +02:00
|
|
|
|
2018-03-26 23:32:43 +02:00
|
|
|
if (!claim || !metadata) {
|
|
|
|
return (
|
|
|
|
<div className="card__content">
|
|
|
|
<span className="empty">{__('Empty claim or metadata info.')}</span>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
2017-09-17 22:33:52 +02:00
|
|
|
|
2018-03-26 23:32:43 +02:00
|
|
|
const { description, language, license } = metadata;
|
2018-04-25 21:31:58 +02:00
|
|
|
|
2018-04-17 03:51:33 +02:00
|
|
|
const mediaType = contentType || 'unknown';
|
2018-03-26 23:32:43 +02:00
|
|
|
const downloadPath = fileInfo ? path.normalize(fileInfo.download_path) : null;
|
2017-09-17 22:33:52 +02:00
|
|
|
|
2018-03-26 23:32:43 +02:00
|
|
|
return (
|
|
|
|
<React.Fragment>
|
|
|
|
{description && (
|
|
|
|
<React.Fragment>
|
|
|
|
<div className="card__subtext-title">About</div>
|
|
|
|
<div className="card__subtext">
|
2018-06-10 23:57:46 +02:00
|
|
|
<MarkdownPreview content={description} promptLinks={true} />
|
2018-03-26 23:32:43 +02:00
|
|
|
</div>
|
|
|
|
</React.Fragment>
|
|
|
|
)}
|
|
|
|
<div className="card__subtext-title">Info</div>
|
|
|
|
<div className="card__subtext">
|
|
|
|
<div>
|
|
|
|
{__('Content-Type')}
|
|
|
|
{': '}
|
|
|
|
{mediaType}
|
|
|
|
</div>
|
|
|
|
<div>
|
|
|
|
{__('Language')}
|
|
|
|
{': '}
|
|
|
|
{language}
|
2017-09-17 22:33:52 +02:00
|
|
|
</div>
|
2018-03-26 23:32:43 +02:00
|
|
|
<div>
|
|
|
|
{__('License')}
|
|
|
|
{': '}
|
|
|
|
{license}
|
2017-09-17 22:33:52 +02:00
|
|
|
</div>
|
2018-03-26 23:32:43 +02:00
|
|
|
{downloadPath && (
|
|
|
|
<div>
|
|
|
|
{__('Downloaded to')}
|
|
|
|
{': '}
|
|
|
|
<Button button="link" onClick={() => openFolder(downloadPath)} label={downloadPath} />
|
|
|
|
</div>
|
|
|
|
)}
|
2017-09-17 22:33:52 +02:00
|
|
|
</div>
|
2018-03-26 23:32:43 +02:00
|
|
|
</React.Fragment>
|
|
|
|
);
|
|
|
|
};
|
2017-09-17 22:33:52 +02:00
|
|
|
|
|
|
|
export default FileDetails;
|