2019-06-28 09:27:55 +02:00
|
|
|
// @flow
|
2019-09-27 20:56:15 +02:00
|
|
|
import * as ICONS from 'constants/icons';
|
2019-06-28 09:27:55 +02:00
|
|
|
import React from 'react';
|
|
|
|
import { regexInvalidURI } from 'lbry-redux';
|
|
|
|
import FileSelector from 'component/common/file-selector';
|
2019-07-17 05:23:45 +02:00
|
|
|
import Button from 'component/button';
|
2019-09-27 20:56:15 +02:00
|
|
|
import Card from 'component/common/card';
|
2019-06-28 09:27:55 +02:00
|
|
|
|
|
|
|
type Props = {
|
|
|
|
name: ?string,
|
|
|
|
filePath: ?string,
|
|
|
|
isStillEditing: boolean,
|
|
|
|
balance: number,
|
|
|
|
updatePublishForm: ({}) => void,
|
2019-09-27 20:56:15 +02:00
|
|
|
disabled: boolean,
|
2019-06-28 09:27:55 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
function PublishFile(props: Props) {
|
2019-09-27 20:56:15 +02:00
|
|
|
const { name, balance, filePath, isStillEditing, updatePublishForm, disabled } = props;
|
2019-06-28 09:27:55 +02:00
|
|
|
|
|
|
|
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 (
|
2019-09-27 20:56:15 +02:00
|
|
|
<Card
|
|
|
|
icon={ICONS.PUBLISH}
|
2019-10-01 06:53:33 +02:00
|
|
|
disabled={disabled || balance === 0}
|
2019-09-27 20:56:15 +02:00
|
|
|
title={isStillEditing ? __('Edit') : __('Publish')}
|
2019-10-03 20:24:45 +02:00
|
|
|
subtitle={isStillEditing ? __('You are currently editing a claim.') : __('Jeremy please change this.')}
|
2019-09-27 20:56:15 +02:00
|
|
|
actions={
|
|
|
|
<React.Fragment>
|
|
|
|
<FileSelector currentPath={filePath} onFileChosen={handleFileChange} />
|
|
|
|
{!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>
|
|
|
|
)}
|
|
|
|
{!!isStillEditing && name && (
|
|
|
|
<p className="help">
|
|
|
|
{__("If you don't choose a file, the file from your existing claim %name% will be used", { name: name })}
|
|
|
|
</p>
|
|
|
|
)}
|
|
|
|
</React.Fragment>
|
|
|
|
}
|
|
|
|
/>
|
2019-06-28 09:27:55 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
export default PublishFile;
|