2019-06-28 09:27:55 +02:00
|
|
|
// @flow
|
|
|
|
import React from 'react';
|
|
|
|
import classnames from 'classnames';
|
2019-09-27 20:56:15 +02:00
|
|
|
import usePersistedState from 'effects/use-persisted-state';
|
2019-06-28 09:27:55 +02:00
|
|
|
import { FormField } from 'component/common/form';
|
|
|
|
import Button from 'component/button';
|
|
|
|
import LicenseType from './license-type';
|
2019-09-27 20:56:15 +02:00
|
|
|
import Card from 'component/common/card';
|
2020-07-07 22:42:21 +02:00
|
|
|
// @if TARGET='app'
|
2020-07-13 16:03:00 +02:00
|
|
|
// import ErrorText from 'component/common/error-text';
|
|
|
|
// import { LbryFirst } from 'lbry-redux';
|
|
|
|
// import { ipcRenderer } from 'electron';
|
2020-07-07 22:42:21 +02:00
|
|
|
// @endif
|
2019-06-28 09:27:55 +02:00
|
|
|
|
|
|
|
type Props = {
|
2020-07-03 00:42:04 +02:00
|
|
|
user: ?User,
|
2019-06-28 09:27:55 +02:00
|
|
|
language: ?string,
|
|
|
|
name: ?string,
|
|
|
|
licenseType: ?string,
|
|
|
|
otherLicenseDescription: ?string,
|
|
|
|
licenseUrl: ?string,
|
|
|
|
disabled: boolean,
|
|
|
|
updatePublishForm: ({}) => void,
|
2020-07-03 00:42:04 +02:00
|
|
|
useLBRYUploader: boolean,
|
|
|
|
needsYTAuth: boolean,
|
|
|
|
fetchAccessToken: () => void,
|
|
|
|
accessToken: string,
|
2019-06-28 09:27:55 +02:00
|
|
|
};
|
|
|
|
|
2020-07-03 00:42:04 +02:00
|
|
|
function PublishAdditionalOptions(props: Props) {
|
|
|
|
const {
|
|
|
|
language,
|
|
|
|
name,
|
|
|
|
licenseType,
|
|
|
|
otherLicenseDescription,
|
|
|
|
licenseUrl,
|
|
|
|
updatePublishForm,
|
2020-07-13 16:03:00 +02:00
|
|
|
// user,
|
|
|
|
// useLBRYUploader,
|
|
|
|
// needsYTAuth,
|
|
|
|
// accessToken,
|
|
|
|
// fetchAccessToken,
|
2020-07-03 00:42:04 +02:00
|
|
|
} = props;
|
2019-06-28 09:27:55 +02:00
|
|
|
const [hideSection, setHideSection] = usePersistedState('publish-advanced-options', true);
|
2020-07-13 16:03:00 +02:00
|
|
|
// const [hasLaunchedLbryFirst, setHasLaunchedLbryFirst] = React.useState(false);
|
|
|
|
// const [ytError, setYtError] = React.useState(false);
|
|
|
|
// const isLBRYFirstUser = user && user.lbry_first_approved;
|
|
|
|
// const showLbryFirstCheckbox = !IS_WEB && isLBRYFirstUser && hasLaunchedLbryFirst;
|
2019-06-28 09:27:55 +02:00
|
|
|
|
|
|
|
function toggleHideSection() {
|
|
|
|
setHideSection(!hideSection);
|
|
|
|
}
|
2020-07-07 22:42:21 +02:00
|
|
|
|
2020-07-08 00:24:24 +02:00
|
|
|
// @if TARGET='app'
|
2020-07-13 16:03:00 +02:00
|
|
|
// function signup() {
|
|
|
|
// updatePublishForm({ ytSignupPending: true });
|
|
|
|
// LbryFirst.ytSignup()
|
|
|
|
// .then(response => {
|
|
|
|
// updatePublishForm({ needsYTAuth: false, ytSignupPending: false });
|
|
|
|
// })
|
|
|
|
// .catch(error => {
|
|
|
|
// updatePublishForm({ ytSignupPending: false });
|
|
|
|
// setYtError(true);
|
|
|
|
// console.error(error); // eslint-disable-line
|
|
|
|
// });
|
|
|
|
// }
|
2020-07-07 22:42:21 +02:00
|
|
|
|
2020-07-13 16:03:00 +02:00
|
|
|
// function unlink() {
|
|
|
|
// setYtError(false);
|
2020-07-08 00:24:24 +02:00
|
|
|
|
2020-07-13 16:03:00 +02:00
|
|
|
// LbryFirst.remove()
|
|
|
|
// .then(response => {
|
|
|
|
// updatePublishForm({ needsYTAuth: true });
|
|
|
|
// })
|
|
|
|
// .catch(error => {
|
|
|
|
// setYtError(true);
|
|
|
|
// console.error(error); // eslint-disable-line
|
|
|
|
// });
|
|
|
|
// }
|
2020-07-03 00:42:04 +02:00
|
|
|
|
2020-07-13 16:03:00 +02:00
|
|
|
// React.useEffect(() => {
|
|
|
|
// if (!accessToken) {
|
|
|
|
// fetchAccessToken();
|
|
|
|
// }
|
|
|
|
// }, [accessToken, fetchAccessToken]);
|
2020-07-08 00:24:24 +02:00
|
|
|
|
2020-07-13 16:03:00 +02:00
|
|
|
// React.useEffect(() => {
|
|
|
|
// if (isLBRYFirstUser && !hasLaunchedLbryFirst) {
|
|
|
|
// ipcRenderer.send('launch-lbry-first');
|
|
|
|
// ipcRenderer.on('lbry-first-launched', () => {
|
|
|
|
// setHasLaunchedLbryFirst(true);
|
|
|
|
// });
|
|
|
|
// }
|
|
|
|
// }, [isLBRYFirstUser, hasLaunchedLbryFirst, setHasLaunchedLbryFirst]);
|
2020-07-03 00:42:04 +02:00
|
|
|
|
2020-07-13 16:03:00 +02:00
|
|
|
// React.useEffect(() => {
|
|
|
|
// if (useLBRYUploader && isLBRYFirstUser && hasLaunchedLbryFirst && accessToken) {
|
|
|
|
// LbryFirst.hasYTAuth(accessToken)
|
|
|
|
// .then(response => {
|
|
|
|
// updatePublishForm({ needsYTAuth: !response.HasAuth });
|
|
|
|
// })
|
|
|
|
// .catch(error => {
|
|
|
|
// setYtError(true);
|
|
|
|
// console.error(error); // eslint-disable-line
|
|
|
|
// });
|
|
|
|
// }
|
|
|
|
// }, [updatePublishForm, useLBRYUploader, isLBRYFirstUser, hasLaunchedLbryFirst, accessToken]);
|
2020-07-08 00:24:24 +02:00
|
|
|
// @endif
|
2019-06-28 09:27:55 +02:00
|
|
|
|
|
|
|
return (
|
2019-09-27 20:56:15 +02:00
|
|
|
<Card
|
|
|
|
actions={
|
|
|
|
<React.Fragment>
|
|
|
|
{!hideSection && (
|
|
|
|
<div className={classnames({ 'card--disabled': !name })}>
|
2020-07-08 00:24:24 +02:00
|
|
|
{/* @if TARGET='app' */}
|
2020-07-13 16:03:00 +02:00
|
|
|
{/* {showLbryFirstCheckbox && (
|
2020-07-08 00:24:24 +02:00
|
|
|
<div className="section">
|
2020-07-07 22:42:21 +02:00
|
|
|
<>
|
|
|
|
<FormField
|
|
|
|
checked={useLBRYUploader}
|
|
|
|
type="checkbox"
|
|
|
|
name="use_lbry_uploader_checkbox"
|
|
|
|
onChange={event => updatePublishForm({ useLBRYUploader: !useLBRYUploader })}
|
|
|
|
label={
|
|
|
|
<React.Fragment>
|
|
|
|
{__('Automagically upload to your youtube channel.')}{' '}
|
|
|
|
<Button button="link" href="https://lbry.com/faq/lbry-uploader" label={__('Learn More')} />
|
|
|
|
</React.Fragment>
|
|
|
|
}
|
|
|
|
/>
|
|
|
|
{useLBRYUploader && (
|
|
|
|
<div className="section__actions">
|
|
|
|
{needsYTAuth ? (
|
|
|
|
<Button
|
|
|
|
button="primary"
|
|
|
|
onClick={signup}
|
2020-08-24 19:59:37 +02:00
|
|
|
label={__('Log In With YouTube')}
|
2020-07-07 22:42:21 +02:00
|
|
|
disabled={false}
|
|
|
|
/>
|
|
|
|
) : (
|
|
|
|
<Button button="alt" onClick={unlink} label={__('Unlink YouTube Channel')} disabled={false} />
|
|
|
|
)}
|
|
|
|
{ytError && <ErrorText>{__('There was an error with LBRY first publishing.')}</ErrorText>}
|
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
</>
|
2020-07-08 00:24:24 +02:00
|
|
|
</div>
|
2020-07-13 16:03:00 +02:00
|
|
|
)} */}
|
2020-07-08 00:24:24 +02:00
|
|
|
{/* @endif */}
|
2020-07-07 22:42:21 +02:00
|
|
|
<div className="section">
|
2020-07-03 00:42:04 +02:00
|
|
|
<FormField
|
2020-07-07 22:42:21 +02:00
|
|
|
label={__('Language')}
|
|
|
|
type="select"
|
|
|
|
name="content_language"
|
|
|
|
value={language}
|
|
|
|
onChange={event => updatePublishForm({ language: event.target.value })}
|
|
|
|
>
|
|
|
|
<option value="en">{__('English')}</option>
|
|
|
|
<option value="zh">{__('Chinese')}</option>
|
|
|
|
<option value="fr">{__('French')}</option>
|
|
|
|
<option value="de">{__('German')}</option>
|
|
|
|
<option value="jp">{__('Japanese')}</option>
|
|
|
|
<option value="ru">{__('Russian')}</option>
|
|
|
|
<option value="es">{__('Spanish')}</option>
|
|
|
|
<option value="id">{__('Indonesian')}</option>
|
|
|
|
<option value="fi">{__('Finnish')}</option>
|
|
|
|
<option value="kn">{__('Kannada')}</option>
|
|
|
|
<option value="it">{__('Italian')}</option>
|
|
|
|
<option value="nl">{__('Dutch')}</option>
|
|
|
|
<option value="tr">{__('Turkish')}</option>
|
|
|
|
<option value="pl">{__('Polish')}</option>
|
|
|
|
<option value="ms">{__('Malay')}</option>
|
|
|
|
<option value="pt">{__('Portuguese')}</option>
|
|
|
|
<option value="vi">{__('Vietnamese')}</option>
|
|
|
|
<option value="th">{__('Thai')}</option>
|
|
|
|
<option value="ar">{__('Arabic')}</option>
|
|
|
|
<option value="cs">{__('Czech')}</option>
|
|
|
|
<option value="hr">{__('Croatian')}</option>
|
|
|
|
<option value="km">{__('Khmer')}</option>
|
|
|
|
<option value="ko">{__('Korean')}</option>
|
|
|
|
<option value="no">{__('Norwegian')}</option>
|
|
|
|
<option value="ro">{__('Romanian')}</option>
|
|
|
|
<option value="hi">{__('Hindi')}</option>
|
|
|
|
<option value="el">{__('Greek')}</option>
|
2020-09-21 07:51:40 +02:00
|
|
|
<option value="fa">{__('Persian')}</option>
|
2020-07-07 22:42:21 +02:00
|
|
|
</FormField>
|
|
|
|
|
|
|
|
<LicenseType
|
|
|
|
licenseType={licenseType}
|
|
|
|
otherLicenseDescription={otherLicenseDescription}
|
|
|
|
licenseUrl={licenseUrl}
|
|
|
|
handleLicenseChange={(newLicenseType, newLicenseUrl) =>
|
|
|
|
updatePublishForm({
|
|
|
|
licenseType: newLicenseType,
|
|
|
|
licenseUrl: newLicenseUrl,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
handleLicenseDescriptionChange={event =>
|
|
|
|
updatePublishForm({
|
|
|
|
otherLicenseDescription: event.target.value,
|
|
|
|
})
|
2020-07-03 00:42:04 +02:00
|
|
|
}
|
2020-07-07 22:42:21 +02:00
|
|
|
handleLicenseUrlChange={event => updatePublishForm({ licenseUrl: event.target.value })}
|
2020-07-03 00:42:04 +02:00
|
|
|
/>
|
2020-07-07 22:42:21 +02:00
|
|
|
</div>
|
2019-09-27 20:56:15 +02:00
|
|
|
</div>
|
|
|
|
)}
|
2019-06-28 09:27:55 +02:00
|
|
|
|
2020-07-07 22:42:21 +02:00
|
|
|
<div className="section__actions">
|
2019-09-27 20:56:15 +02:00
|
|
|
<Button
|
|
|
|
label={hideSection ? __('Additional Options') : __('Hide')}
|
|
|
|
button="link"
|
|
|
|
onClick={toggleHideSection}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</React.Fragment>
|
|
|
|
}
|
|
|
|
/>
|
2019-06-28 09:27:55 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2020-07-03 00:42:04 +02:00
|
|
|
export default PublishAdditionalOptions;
|