lbry-desktop/ui/component/fileDetails/view.jsx

104 lines
3.1 KiB
React
Raw Normal View History

2018-03-26 23:32:43 +02:00
// @flow
2020-10-30 04:47:18 +01:00
import { SIMPLE_SITE } from 'config';
2020-10-23 00:11:22 +02:00
import React, { PureComponent } from 'react';
2018-03-26 23:32:43 +02:00
import Button from 'component/button';
2019-03-05 05:46:57 +01:00
import path from 'path';
2020-08-07 22:59:20 +02:00
import { formatBytes } from 'util/format-bytes';
2017-09-17 22:33:52 +02:00
2018-03-26 23:32:43 +02:00
type Props = {
2019-04-24 16:02:08 +02:00
claim: StreamClaim,
fileInfo: FileListItem,
metadata: StreamMetadata,
wip wip wip - everything but publish, autoplay, and styling collection publishing add channel to collection publish cleanup wip bump clear mass add after success move collection item management controls redirect replace to published collection id bump playlist selector on create bump use new collection add ui element bump wip gitignore add content json wip bump context add to playlist basic collections page style pass wip wip: edits, buttons, styles... change fileAuthor to claimAuthor update, pending bugfixes, delete modal progress, collection header, other bugfixes bump cleaning show page bugfix builtin collection headers no playlists, no grid title wip style tweaks use normal looking claim previews for collection tiles add collection changes style library previews collection menulist for delete/view on library delete modal works for unpublished rearrange collection publish tabs clean up collection publishing and items show on odysee begin collectoin edit header and css renaming better thumbnails bump fix collection publish redirect view collection in menu does something copy and thumbs list previews, pending, context menus, list page enter to add collection, lists page empty state playable lists only, delete feature, bump put fileListDownloaded back better collection titles improve collection claim details fix horiz more icon fix up channel page style, copy, bump refactor preview overlay properties, fix reposts showing as floppydisk add watch later toast, small overlay properties on wunderbar results, fix collection actions buttons bump cleanup cleaning, refactoring bump preview thumb styling, cleanup support discover page lists search sync, bump bump, fix sync more enforce builtin order for now new lists page empty state try to indicate unpublished edits in lists bump fix autoplay and linting consts, fix autoplay bugs fixes cleanup fix, bump lists experimental ui, fixes refactor listIndex out hack in collection fallback thumb bump
2021-02-06 08:03:51 +01:00
openFolder: (string) => void,
2018-03-26 23:32:43 +02:00
contentType: string,
2018-11-07 23:44:38 +01:00
user: ?any,
2018-03-26 23:32:43 +02:00
};
2018-11-07 23:44:38 +01:00
class FileDetails extends PureComponent<Props> {
render() {
2020-06-08 20:42:29 +02:00
const { claim, contentType, fileInfo, metadata, openFolder } = this.props;
2018-11-07 23:44:38 +01:00
if (!claim || !metadata) {
2019-07-21 23:31:22 +02:00
return <span className="empty">{__('Empty claim or metadata info.')}</span>;
2018-11-07 23:44:38 +01:00
}
const { languages, license } = metadata;
2017-09-17 22:33:52 +02:00
2018-11-07 23:44:38 +01:00
const mediaType = contentType || 'unknown';
const fileSize =
metadata.source && metadata.source.size
? formatBytes(metadata.source.size)
: fileInfo && fileInfo.download_path && formatBytes(fileInfo.written_bytes);
2019-05-07 23:38:29 +02:00
let downloadPath = fileInfo && fileInfo.download_path ? path.normalize(fileInfo.download_path) : null;
let downloadNote;
2019-10-13 19:41:51 +02:00
// If the path is blank, file is not available. Streamed files won't have any blobs saved
2019-08-02 08:28:14 +02:00
// Create path from name so the folder opens on click.
if (fileInfo && fileInfo.blobs_completed >= 1 && fileInfo.download_path === null) {
downloadPath = `${fileInfo.download_directory}/${fileInfo.file_name}`;
downloadNote = __('This file may have been streamed, moved or deleted');
}
2018-11-07 23:44:38 +01:00
return (
2020-10-30 04:47:18 +01:00
<>
<div className="media__details">
<span>{__('LBRY URL')}</span>
<span>{claim.canonical_url}</span>
</div>
<div className="media__details">
<span>{__('Claim ID')}</span>
<span>{claim.claim_id}</span>
</div>
2020-10-30 04:47:18 +01:00
{!SIMPLE_SITE && (
<>
{languages && (
<div className="media__details">
<span>{__('Languages')}</span>
<span>{languages.join(' ')}</span>
</div>
)}
wip wip wip - everything but publish, autoplay, and styling collection publishing add channel to collection publish cleanup wip bump clear mass add after success move collection item management controls redirect replace to published collection id bump playlist selector on create bump use new collection add ui element bump wip gitignore add content json wip bump context add to playlist basic collections page style pass wip wip: edits, buttons, styles... change fileAuthor to claimAuthor update, pending bugfixes, delete modal progress, collection header, other bugfixes bump cleaning show page bugfix builtin collection headers no playlists, no grid title wip style tweaks use normal looking claim previews for collection tiles add collection changes style library previews collection menulist for delete/view on library delete modal works for unpublished rearrange collection publish tabs clean up collection publishing and items show on odysee begin collectoin edit header and css renaming better thumbnails bump fix collection publish redirect view collection in menu does something copy and thumbs list previews, pending, context menus, list page enter to add collection, lists page empty state playable lists only, delete feature, bump put fileListDownloaded back better collection titles improve collection claim details fix horiz more icon fix up channel page style, copy, bump refactor preview overlay properties, fix reposts showing as floppydisk add watch later toast, small overlay properties on wunderbar results, fix collection actions buttons bump cleanup cleaning, refactoring bump preview thumb styling, cleanup support discover page lists search sync, bump bump, fix sync more enforce builtin order for now new lists page empty state try to indicate unpublished edits in lists bump fix autoplay and linting consts, fix autoplay bugs fixes cleanup fix, bump lists experimental ui, fixes refactor listIndex out hack in collection fallback thumb bump
2021-02-06 08:03:51 +01:00
{mediaType && (
2020-10-30 04:47:18 +01:00
<div className="media__details">
<span>{__('Media Type')}</span>
<span>{mediaType}</span>
</div>
)}
2020-10-30 04:47:18 +01:00
<div className="media__details">
<span>{__('License')}</span>
<span>{license}</span>
</div>
{downloadPath && (
<div className="media__details">
<span>{__('Downloaded to')}</span>
<span>
<Button
button="link"
className="button--download-link"
onClick={() => {
if (downloadPath) {
openFolder(downloadPath);
}
}}
label={downloadNote || downloadPath.replace(/(.{10})/g, '$1\u200b')}
/>
</span>
</div>
)}
</>
)}
{fileSize && (
<div className="media__details">
<span>{fileSize}</span>
</div>
)}
</>
2018-11-07 23:44:38 +01:00
);
}
}
2017-09-17 22:33:52 +02:00
export default FileDetails;