// @flow import React from 'react'; import Button from 'component/button'; import { Form, FormField } from 'component/common/form'; import { Modal } from 'modal/modal'; import Card from 'component/common/card'; import Tag from 'component/tag'; import MarkdownPreview from 'component/common/markdown-preview'; import { COPYRIGHT, OTHER } from 'constants/licenses'; import LbcSymbol from 'component/common/lbc-symbol'; type Props = { filePath: string | WebFile, isMarkdownPost: boolean, optimize: boolean, title: ?string, description: ?string, channel: ?string, bid: ?number, uri: ?string, contentIsFree: boolean, fee: { amount: string, currency: string, }, language: string, licenseType: string, otherLicenseDescription: ?string, licenseUrl: ?string, tags: Array, isVid: boolean, ffmpegStatus: any, previewResponse: PublishResponse, publish: (?string, ?boolean) => void, closeModal: () => void, enablePublishPreview: boolean, setEnablePublishPreview: (boolean) => void, isStillEditing: boolean, }; class ModalPublishPreview extends React.PureComponent { onConfirmed() { const { filePath, publish, closeModal } = this.props; // Publish for real: publish(this.resolveFilePathName(filePath), false); closeModal(); } resolveFilePathName(filePath: string | WebFile) { if (!filePath) { return '---'; } if (typeof filePath === 'string') { return filePath; } else { return filePath.name; } } createRow(label: string, value: any) { return ( {label} {value} ); } togglePreviewEnabled() { const { enablePublishPreview, setEnablePublishPreview } = this.props; setEnablePublishPreview(!enablePublishPreview); } render() { const { filePath, isMarkdownPost, optimize, title, description, channel, bid, uri, contentIsFree, fee, language, licenseType, otherLicenseDescription, licenseUrl, tags, isVid, ffmpegStatus = {}, previewResponse, closeModal, enablePublishPreview, setEnablePublishPreview, isStillEditing, } = this.props; const modalTitle = isStillEditing ? __('Confirm Edit') : __('Confirm Upload'); const confirmBtnText = isStillEditing ? __('Save') : __('Upload'); const txFee = previewResponse ? previewResponse['total_fee'] : null; const isOptimizeAvail = filePath && filePath !== '' && isVid && ffmpegStatus.available; const descriptionValue = description ? (
) : null; const licenseValue = licenseType === COPYRIGHT ? (

© {otherLicenseDescription}

) : licenseType === OTHER ? (

{otherLicenseDescription}
{licenseUrl}

) : (

{licenseType}

); const tagsValue = // Do nothing for onClick(). Setting to 'null' results in "View Tag" action -- we don't want to leave the modal. tags.map((tag) => {}} />); const depositValue = bid ? :

---

; let priceValue = __('Free'); if (!contentIsFree) { if (fee.currency === 'LBC') { priceValue = ; } else { priceValue = `${fee.amount} ${fee.currency}`; } } return (
this.onConfirmed()}>
{!isMarkdownPost && this.createRow(__('File'), this.resolveFilePathName(filePath))} {isOptimizeAvail && this.createRow(__('Transcode'), optimize ? __('Yes') : __('No'))} {this.createRow(__('Title'), title)} {this.createRow(__('Description'), descriptionValue)} {this.createRow(__('Channel'), channel)} {this.createRow(__('URL'), uri)} {this.createRow(__('Deposit'), depositValue)} {this.createRow(__('Price'), priceValue)} {this.createRow(__('Language'), language)} {this.createRow(__('License'), licenseValue)} {this.createRow(__('Tags'), tagsValue)}
{txFee && (
{__('Est. transaction fee:')}  
)} } actions={ <>

{__('Once the transaction is sent, it cannot be reversed.')}

setEnablePublishPreview(!enablePublishPreview)} /> } />
); } } export default ModalPublishPreview;