2019-06-28 09:27:55 +02:00
|
|
|
// @flow
|
|
|
|
import React from 'react';
|
|
|
|
import { regexInvalidURI } from 'lbry-redux';
|
|
|
|
import classnames from 'classnames';
|
|
|
|
import FileSelector from 'component/common/file-selector';
|
2019-07-17 05:23:45 +02:00
|
|
|
import Button from 'component/button';
|
2019-06-28 09:27:55 +02:00
|
|
|
|
|
|
|
type Props = {
|
|
|
|
name: ?string,
|
|
|
|
filePath: ?string,
|
|
|
|
isStillEditing: boolean,
|
|
|
|
balance: number,
|
|
|
|
updatePublishForm: ({}) => void,
|
|
|
|
};
|
|
|
|
|
|
|
|
function PublishFile(props: Props) {
|
|
|
|
const { name, balance, filePath, isStillEditing, updatePublishForm } = props;
|
|
|
|
|
|
|
|
function handleFileChange(filePath: string, fileName: string) {
|
|
|
|
const publishFormParams: { filePath: string, name?: string } = { filePath };
|
|
|
|
|
|
|
|
if (!name) {
|
|
|
|
const parsedFileName = fileName.replace(regexInvalidURI, '');
|
|
|
|
publishFormParams.name = parsedFileName.replace(' ', '-');
|
|
|
|
}
|
|
|
|
|
|
|
|
updatePublishForm(publishFormParams);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<section
|
|
|
|
className={classnames('card card--section', {
|
|
|
|
'card--disabled': balance === 0,
|
|
|
|
})}
|
|
|
|
>
|
2019-07-21 23:31:22 +02:00
|
|
|
<h2 className="card__title">{isStillEditing ? __('Edit') : __('Publish')}</h2>
|
|
|
|
{isStillEditing && <p className="card__subtitle">{__('You are currently editing a claim.')}</p>}
|
2019-06-28 09:27:55 +02:00
|
|
|
|
|
|
|
<div className="card__content">
|
|
|
|
<FileSelector currentPath={filePath} onFileChosen={handleFileChange} />
|
2019-07-17 05:23:45 +02:00
|
|
|
{!isStillEditing && (
|
|
|
|
<p className="help">
|
|
|
|
{__('For video content, use MP4s in H264/AAC format for best compatibility.')}{' '}
|
|
|
|
<Button button="link" label={__('Learn more')} href="https://lbry.com/faq/how-to-publish" />.
|
|
|
|
</p>
|
|
|
|
)}
|
2019-06-28 09:27:55 +02:00
|
|
|
{!!isStillEditing && name && (
|
|
|
|
<p className="help">
|
|
|
|
{/* @i18nfixme */}
|
|
|
|
{__("If you don't choose a file, the file from your existing claim")}
|
|
|
|
{` "${name}" `}
|
|
|
|
{__('will be used.')}
|
|
|
|
</p>
|
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
</section>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
export default PublishFile;
|