enables relevant settings blocks

This commit is contained in:
jessop 2019-08-22 17:14:51 -04:00 committed by Sean Yesmunt
parent 82d57eb574
commit a6d79160eb
2 changed files with 161 additions and 159 deletions

View file

@ -124,7 +124,7 @@
"husky": "^0.14.3", "husky": "^0.14.3",
"json-loader": "^0.5.4", "json-loader": "^0.5.4",
"lbry-format": "https://github.com/lbryio/lbry-format.git", "lbry-format": "https://github.com/lbryio/lbry-format.git",
"lbry-redux": "lbryio/lbry-redux#1af092ce2cb507d9a41711b864874c0bd76935ae", "lbry-redux": "lbryio/lbry-redux#f4413a8ab4928a9487274568bb72e440c45875be",
"lbryinc": "lbryio/lbryinc#1ce266b3c52654190b955e9c869b8e302aa5c585", "lbryinc": "lbryio/lbryinc#1ce266b3c52654190b955e9c869b8e302aa5c585",
"lint-staged": "^7.0.2", "lint-staged": "^7.0.2",
"localforage": "^1.7.1", "localforage": "^1.7.1",

View file

@ -2,12 +2,10 @@
import * as SETTINGS from 'constants/settings'; import * as SETTINGS from 'constants/settings';
import * as PAGES from 'constants/pages'; import * as PAGES from 'constants/pages';
import * as React from 'react'; import * as React from 'react';
import classnames from 'classnames';
import { FormField, FormFieldPrice, Form } from 'component/common/form'; import { FormField, FormFieldPrice, Form } from 'component/common/form';
import Button from 'component/button'; import Button from 'component/button';
import Page from 'component/page'; import Page from 'component/page';
import FileSelector from 'component/common/file-selector'; import FileSelector from 'component/common/file-selector';
import UnsupportedOnWeb from 'component/common/unsupported-on-web';
type Price = { type Price = {
currency: string, currency: string,
@ -210,59 +208,61 @@ class SettingsPage extends React.PureComponent<Props, State> {
return ( return (
<Page> <Page>
{IS_WEB && <UnsupportedOnWeb />} {noDaemonSettings && !IS_WEB ? (
{noDaemonSettings ? (
<section className="card card--section"> <section className="card card--section">
<div className="card__title">{__('Failed to load settings.')}</div> <div className="card__title">{__('Failed to load settings.')}</div>
</section> </section>
) : ( ) : (
<div className={classnames({ 'card--disabled': IS_WEB })}> <div>
<section className="card card--section"> {!IS_WEB && (
<h2 className="card__title">{__('Download Directory')}</h2> <section className="card card--section">
<h2 className="card__title">{__('Download Directory')}</h2>
<div className="card__content"> <div className="card__content">
<FileSelector <FileSelector
type="openDirectory" type="openDirectory"
currentPath={daemonSettings.download_dir} currentPath={daemonSettings.download_dir}
onFileChosen={(newDirectory: string) => { onFileChosen={(newDirectory: string) => {
setDaemonSetting('download_dir', newDirectory); setDaemonSetting('download_dir', newDirectory);
}} }}
/> />
<p className="help">{__('LBRY downloads will be saved here.')}</p> <p className="help">{__('LBRY downloads will be saved here.')}</p>
</div> </div>
</section> </section>
)}
<section className="card card--section"> {!IS_WEB && (
<h2 className="card__title">{__('Network and Data Settings')}</h2> <section className="card card--section">
<h2 className="card__title">{__('Network and Data Settings')}</h2>
<Form> <Form>
<FormField <FormField
type="checkbox" type="checkbox"
name="save_files" name="save_files"
onChange={() => setDaemonSetting('save_files', !daemonSettings.save_files)} onChange={() => setDaemonSetting('save_files', !daemonSettings.save_files)}
checked={daemonSettings.save_files} checked={daemonSettings.save_files}
label={__('Save all viewed content to your downloads directory')} label={__('Save all viewed content to your downloads directory')}
helper={__( helper={__(
'Paid content and some file types are saved by default. Changing this setting will not affect previously downloaded content.' 'Paid content and some file types are saved by default. Changing this setting will not affect previously downloaded content.'
)} )}
/> />
</Form> </Form>
<Form> <Form>
<FormField <FormField
type="checkbox" type="checkbox"
name="save_blobs" name="save_blobs"
onChange={() => setDaemonSetting('save_blobs', !daemonSettings.save_blobs)} onChange={() => setDaemonSetting('save_blobs', !daemonSettings.save_blobs)}
checked={daemonSettings.save_blobs} checked={daemonSettings.save_blobs}
label={__('Save hosting data to help the LBRY network')} label={__('Save hosting data to help the LBRY network')}
helper={ helper={
<React.Fragment> <React.Fragment>
{__("If disabled, LBRY will be very sad and you won't be helping improve the network.")}{' '} {__("If disabled, LBRY will be very sad and you won't be helping improve the network.")}{' '}
<Button button="link" label={__('Learn more')} href="https://lbry.com/faq/host-content" />. <Button button="link" label={__('Learn more')} href="https://lbry.com/faq/host-content" />.
</React.Fragment> </React.Fragment>
} }
/> />
</Form> </Form>
</section> </section>
)}
<section className="card card--section"> <section className="card card--section">
<header className="card__header"> <header className="card__header">
@ -389,20 +389,21 @@ class SettingsPage extends React.PureComponent<Props, State> {
<Button button="link" label={__('Manage')} navigate={`/$/${PAGES.BLOCKED}`} /> <Button button="link" label={__('Manage')} navigate={`/$/${PAGES.BLOCKED}`} />
</p> </p>
</section> </section>
{!IS_WEB && (
<section className="card card--section"> <section className="card card--section">
<h2 className="card__title">{__('Notifications')}</h2> <h2 className="card__title">{__('Notifications')}</h2>
<Form> <Form>
<FormField <FormField
type="checkbox" type="checkbox"
name="desktopNotification" name="desktopNotification"
onChange={() => setClientSetting(SETTINGS.OS_NOTIFICATIONS_ENABLED, !osNotificationsEnabled)} onChange={() => setClientSetting(SETTINGS.OS_NOTIFICATIONS_ENABLED, !osNotificationsEnabled)}
checked={osNotificationsEnabled} checked={osNotificationsEnabled}
label={__('Show Desktop Notifications')} label={__('Show Desktop Notifications')}
helper={__('Get notified when a publish is confirmed, or when new content is available to watch.')} helper={__('Get notified when a publish is confirmed, or when new content is available to watch.')}
/> />
</Form> </Form>
</section> </section>
)}
<section className="card card--section"> <section className="card card--section">
<h2 className="card__title">{__('Share Diagnostic Data')}</h2> <h2 className="card__title">{__('Share Diagnostic Data')}</h2>
@ -485,109 +486,110 @@ class SettingsPage extends React.PureComponent<Props, State> {
</fieldset-section> </fieldset-section>
</Form> </Form>
</section> </section>
{!IS_WEB && (
<section className="card card--section">
<h2 className="card__title">{__('Wallet Security')}</h2>
<section className="card card--section"> <Form>
<h2 className="card__title">{__('Wallet Security')}</h2>
<Form>
<FormField
type="checkbox"
name="encrypt_wallet"
onChange={() => this.onChangeEncryptWallet()}
checked={walletEncrypted}
label={__('Encrypt my wallet with a custom password')}
helper={
<React.Fragment>
{__('Secure your local wallet data with a custom password.')}{' '}
<strong>{__('Lost passwords cannot be recovered.')} </strong>
<Button button="link" label={__('Learn more')} href="https://lbry.com/faq/wallet-encryption" />.
</React.Fragment>
}
/>
<FormField
type="checkbox"
name="hide_balance"
onChange={() => setClientSetting(SETTINGS.HIDE_BALANCE, !hideBalance)}
checked={hideBalance}
label={__('Hide wallet balance in header')}
/>
</Form>
</section>
<section className="card card--section">
<h2 className="card__title">{__('Experimental Settings')}</h2>
<Form>
<FormField
type="checkbox"
name="support_option"
onChange={() => setClientSetting(SETTINGS.SUPPORT_OPTION, !supportOption)}
checked={supportOption}
label={__('Enable claim support')}
helper={
<React.Fragment>
{__('This will add a Support button along side tipping. Similar to tips, supports help ')}
<Button button="link" label={__(' discovery ')} href="https://lbry.com/faq/trending" />
{__(' but the LBC is returned to your wallet if revoked.')}
{__(' Both also help secure ')}
<Button button="link" label={__('vanity names')} href="https://lbry.com/faq/naming" />.
</React.Fragment>
}
/>
<FormField
type="checkbox"
name="auto_download"
onChange={() => setClientSetting(SETTINGS.AUTO_DOWNLOAD, !autoDownload)}
checked={autoDownload}
label={__('Automatically download new content from my subscriptions')}
helper={__(
"The latest file from each of your subscriptions will be downloaded for quick access as soon as it's published."
)}
/>
<FormField
name="language_select"
type="select"
label={__('Language')}
onChange={this.onLanguageChange}
value={currentLanguage}
helper={__(
'Multi-language support is brand new and incomplete. Switching your language may have unintended consequences.'
)}
>
{Object.keys(languages).map(language => (
<option key={language} value={language}>
{languages[language]}
</option>
))}
</FormField>
</Form>
<Form>
<fieldset-section>
<FormField <FormField
name="max_connections" type="checkbox"
type="select" name="encrypt_wallet"
label={__('Max Connections')} onChange={() => this.onChangeEncryptWallet()}
checked={walletEncrypted}
label={__('Encrypt my wallet with a custom password')}
helper={
<React.Fragment>
{__('Secure your local wallet data with a custom password.')}{' '}
<strong>{__('Lost passwords cannot be recovered.')} </strong>
<Button button="link" label={__('Learn more')} href="https://lbry.com/faq/wallet-encryption" />.
</React.Fragment>
}
/>
<FormField
type="checkbox"
name="hide_balance"
onChange={() => setClientSetting(SETTINGS.HIDE_BALANCE, !hideBalance)}
checked={hideBalance}
label={__('Hide wallet balance in header')}
/>
</Form>
</section>
)}
{!IS_WEB && (
<section className="card card--section">
<h2 className="card__title">{__('Experimental Settings')}</h2>
<Form>
<FormField
type="checkbox"
name="support_option"
onChange={() => setClientSetting(SETTINGS.SUPPORT_OPTION, !supportOption)}
checked={supportOption}
label={__('Enable claim support')}
helper={
<React.Fragment>
{__('This will add a Support button along side tipping. Similar to tips, supports help ')}
<Button button="link" label={__(' discovery ')} href="https://lbry.com/faq/trending" />
{__(' but the LBC is returned to your wallet if revoked.')}
{__(' Both also help secure ')}
<Button button="link" label={__('vanity names')} href="https://lbry.com/faq/naming" />.
</React.Fragment>
}
/>
<FormField
type="checkbox"
name="auto_download"
onChange={() => setClientSetting(SETTINGS.AUTO_DOWNLOAD, !autoDownload)}
checked={autoDownload}
label={__('Automatically download new content from my subscriptions')}
helper={__( helper={__(
'For users with good bandwidth, try a higher value to improve streaming and download speeds. Low bandwidth users may benefit from a lower setting. Default is 4.' "The latest file from each of your subscriptions will be downloaded for quick access as soon as it's published."
)}
/>
<FormField
name="language_select"
type="select"
label={__('Language')}
onChange={this.onLanguageChange}
value={currentLanguage}
helper={__(
'Multi-language support is brand new and incomplete. Switching your language may have unintended consequences.'
)} )}
min={1}
max={100}
onChange={this.onMaxConnectionsChange}
value={daemonSettings.max_connections_per_download}
> >
{connectionOptions.map(connectionOption => ( {Object.keys(languages).map(language => (
<option key={connectionOption} value={connectionOption}> <option key={language} value={language}>
{connectionOption} {languages[language]}
</option> </option>
))} ))}
</FormField> </FormField>
</fieldset-section> </Form>
</Form> <Form>
</section> <fieldset-section>
<FormField
name="max_connections"
type="select"
label={__('Max Connections')}
helper={__(
'For users with good bandwidth, try a higher value to improve streaming and download speeds. Low bandwidth users may benefit from a lower setting. Default is 4.'
)}
min={1}
max={100}
onChange={this.onMaxConnectionsChange}
value={daemonSettings.max_connections_per_download}
>
{connectionOptions.map(connectionOption => (
<option key={connectionOption} value={connectionOption}>
{connectionOption}
</option>
))}
</FormField>
</fieldset-section>
</Form>
</section>
)}
<section className="card card--section"> <section className="card card--section">
<h2 className="card__title">{__('Application Cache')}</h2> <h2 className="card__title">{__('Application Cache')}</h2>