lbry-desktop/ui/page/settings/view.jsx

194 lines
6.4 KiB
React
Raw Normal View History

2018-03-26 23:32:43 +02:00
// @flow
import * as PAGES from 'constants/pages';
import * as ICONS from 'constants/icons';
2018-03-26 23:32:43 +02:00
import * as React from 'react';
import { FormField } from 'component/common/form';
2018-03-26 23:32:43 +02:00
import Button from 'component/button';
import Page from 'component/page';
import SettingAccount from 'component/settingAccount';
import SettingAppearance from 'component/settingAppearance';
import SettingContent from 'component/settingContent';
import SettingSystem from 'component/settingSystem';
2018-03-26 23:32:43 +02:00
import FileSelector from 'component/common/file-selector';
2019-09-27 22:03:05 +02:00
import Card from 'component/common/card';
2020-11-10 06:21:04 +01:00
import classnames from 'classnames';
import Yrbl from 'component/yrbl';
2019-11-18 19:30:15 +01:00
2019-04-24 16:02:08 +02:00
type Price = {
2018-03-26 23:32:43 +02:00
currency: string,
amount: number,
};
type SetDaemonSettingArg = boolean | string | number;
2018-03-26 23:32:43 +02:00
type DaemonSettings = {
download_dir: string,
2018-03-26 23:32:43 +02:00
share_usage_data: boolean,
};
type Props = {
setDaemonSetting: (string, ?SetDaemonSettingArg) => void,
clearDaemonSetting: (string) => void,
toggle3PAnalytics: (boolean) => void,
2018-03-26 23:32:43 +02:00
daemonSettings: DaemonSettings,
allowAnalytics: boolean,
2019-11-22 22:13:00 +01:00
isAuthenticated: boolean,
2018-03-26 23:32:43 +02:00
instantPurchaseEnabled: boolean,
instantPurchaseMax: Price,
openModal: (string) => void,
2020-09-04 17:02:30 +02:00
enterSettings: () => void,
exitSettings: () => void,
2018-03-26 23:32:43 +02:00
};
class SettingsPage extends React.PureComponent<Props> {
2018-03-26 23:32:43 +02:00
componentDidMount() {
const { enterSettings } = this.props;
2020-09-04 17:02:30 +02:00
enterSettings();
}
componentWillUnmount() {
const { exitSettings } = this.props;
exitSettings();
2017-05-17 10:10:25 +02:00
}
setDaemonSetting(name: string, value: ?SetDaemonSettingArg): void {
2018-10-13 17:49:47 +02:00
this.props.setDaemonSetting(name, value);
}
clearDaemonSetting(name: string): void {
this.props.clearDaemonSetting(name);
}
2017-05-17 10:10:25 +02:00
render() {
2017-09-07 03:53:42 +02:00
const {
daemonSettings,
allowAnalytics,
2019-11-22 22:13:00 +01:00
isAuthenticated,
2019-10-15 06:20:12 +02:00
// autoDownload,
2019-02-13 17:27:20 +01:00
setDaemonSetting,
toggle3PAnalytics,
2017-09-07 03:53:42 +02:00
} = this.props;
2018-03-26 23:32:43 +02:00
const noDaemonSettings = !daemonSettings || Object.keys(daemonSettings).length === 0;
const newStyle = true;
return newStyle ? (
<Page noFooter noSideNavigation backout={{ title: __('Settings'), backLabel: __('Done') }} className="card-stack">
<SettingAppearance />
<SettingAccount />
<SettingContent />
<SettingSystem />
</Page>
) : (
<Page
noFooter
noSideNavigation
backout={{
title: __('Settings'),
backLabel: __('Done'),
}}
className="card-stack"
>
2020-11-10 06:21:04 +01:00
{!isAuthenticated && IS_WEB && (
<div className="main--empty">
<Yrbl
type="happy"
title={__('Sign up for full control')}
subtitle={__('Unlock new buttons that change things.')}
actions={
<div className="section__actions">
<Button button="primary" icon={ICONS.SIGN_UP} label={__('Sign Up')} navigate={`/$/${PAGES.AUTH}`} />
</div>
}
/>
</div>
)}
2019-08-26 20:32:45 +02:00
{!IS_WEB && noDaemonSettings ? (
2018-03-26 23:32:43 +02:00
<section className="card card--section">
Changed how 'Blocked channels' are displayed on settings and a small typo Problems solved (second attempt): A. Small typo for <div className="card__title card__t itle--deprecated"> (extra space in the word **t itle**) B. More details about problems with languages: 1. The word blocked has two forms in other languages (one for plural and one for singular) and therefore must be put together with channel and channels words. Currently it can be translated in only one form. 2. In the case there are no blocked channels there is no need to show the 0 value and is more elegant the message 'You do not have blocked channels' 3. The link to manage the channels should not be visible in the case that there is no channel blocked, because there is no channel that need to be managed. And about your statement: "Your change would make it harder for other languages to change this sentence." It's quite the opossite, it's very clear and easy. They just have to translate (with examples in Romanian): '%count% %channels%. ', (leave it as it is) 'You don't have' = 'Nu aveți' 'You have' = 'Aveți' 'blocked channel' = 'canal blocat' 'blocked channels' = 'canale blocat**e**' (see the change for plural forms for the word blocked, not only for channels word?) I hope this time I explained better the need for the changes. Thanks Messages displayed: Case with 0 blocked channels: You don't have blocked channels. (No Manage button displayed) Case with 1 blocked channel: You have 1 blocked channel. **Manage** (manage link) Case with 2 or more blocked channels: You have 2 blocked channels. **Manage** (manage link)
2020-05-18 23:17:26 +02:00
<div className="card__title card__title--deprecated">{__('Failed to load settings.')}</div>
2018-03-26 23:32:43 +02:00
</section>
) : (
2020-11-13 19:10:47 +01:00
<div className={classnames('card-stack', { 'card--disabled': IS_WEB && !isAuthenticated })}>
2019-10-23 20:59:33 +02:00
{/* @if TARGET='app' */}
2019-09-27 22:03:05 +02:00
<Card
2020-08-26 22:28:33 +02:00
title={__('Download directory')}
2019-09-27 22:03:05 +02:00
actions={
<React.Fragment>
<FileSelector
type="openDirectory"
currentPath={daemonSettings.download_dir}
onFileChosen={(newDirectory: WebFile) => {
setDaemonSetting('download_dir', newDirectory.path);
2019-09-27 22:03:05 +02:00
}}
/>
<p className="help">{__('LBRY downloads will be saved here.')}</p>
</React.Fragment>
}
/>
{/* @endif */}
2019-09-27 22:03:05 +02:00
{/* @if TARGET='app' */}
<Card
2020-08-26 22:28:33 +02:00
title={__('Share usage and diagnostic data')}
subtitle={
<React.Fragment>
{__(
`This is information like error logging, performance tracking, and usage statistics. It includes your IP address and basic system details, but no other identifying information (unless you sign in to lbry.tv)`
)}{' '}
<Button button="link" label={__('Learn more')} href="https://lbry.com/privacypolicy" />
</React.Fragment>
}
actions={
<>
<FormField
type="checkbox"
name="share_internal"
onChange={() => setDaemonSetting('share_usage_data', !daemonSettings.share_usage_data)}
checked={daemonSettings.share_usage_data}
label={<React.Fragment>{__('Allow the app to share data to LBRY.inc')}</React.Fragment>}
helper={
isAuthenticated
? __('Internal sharing is required while signed in.')
: __('Internal sharing is required to participate in rewards programs.')
}
disabled={isAuthenticated && daemonSettings.share_usage_data}
/>
<FormField
type="checkbox"
name="share_third_party"
onChange={(e) => toggle3PAnalytics(e.target.checked)}
checked={allowAnalytics}
label={__('Allow the app to access third party analytics platforms')}
helper={__('We use detailed analytics to improve all aspects of the LBRY experience.')}
/>
</>
}
/>
{/* @endif */}
2019-09-27 22:03:05 +02:00
{(isAuthenticated || !IS_WEB) && (
<>
<Card
2020-08-26 22:28:33 +02:00
title={__('Advanced settings')}
actions={
<div className="section__actions">
<Button
button="secondary"
label={__('Manage')}
icon={ICONS.SETTINGS}
navigate={`/$/${PAGES.SETTINGS_ADVANCED}`}
/>
</div>
}
/>
</>
)}
2019-03-18 06:06:41 +01:00
</div>
2018-03-26 23:32:43 +02:00
)}
</Page>
2016-04-10 02:00:56 +02:00
);
}
2017-05-17 10:10:25 +02:00
}
2016-11-22 21:19:08 +01:00
export default SettingsPage;