2018-03-26 23:32:43 +02:00
|
|
|
// @flow
|
2019-07-08 22:54:58 +02:00
|
|
|
import * as PAGES from 'constants/pages';
|
2020-06-19 22:18:12 +02:00
|
|
|
import * as ICONS from 'constants/icons';
|
2018-03-26 23:32:43 +02:00
|
|
|
import * as React from 'react';
|
2021-08-09 02:36:42 +02:00
|
|
|
import classnames from 'classnames';
|
2018-03-26 23:32:43 +02:00
|
|
|
import Button from 'component/button';
|
|
|
|
import Page from 'component/page';
|
2021-08-05 09:00:21 +02:00
|
|
|
import SettingAccount from 'component/settingAccount';
|
2021-08-05 11:18:16 +02:00
|
|
|
import SettingAppearance from 'component/settingAppearance';
|
2021-08-06 04:41:37 +02:00
|
|
|
import SettingContent from 'component/settingContent';
|
2021-08-05 10:41:45 +02:00
|
|
|
import SettingSystem from 'component/settingSystem';
|
2021-08-09 02:36:42 +02:00
|
|
|
import SettingUnauthenticated from 'component/settingUnauthenticated';
|
2020-11-10 06:21:04 +01:00
|
|
|
import Yrbl from 'component/yrbl';
|
2019-11-18 19:30:15 +01:00
|
|
|
|
2018-03-26 23:32:43 +02:00
|
|
|
type DaemonSettings = {
|
2019-02-12 18:26:50 +01:00
|
|
|
download_dir: string,
|
2018-03-26 23:32:43 +02:00
|
|
|
share_usage_data: boolean,
|
|
|
|
};
|
|
|
|
|
|
|
|
type Props = {
|
|
|
|
daemonSettings: DaemonSettings,
|
2019-11-22 22:13:00 +01:00
|
|
|
isAuthenticated: boolean,
|
2020-09-04 17:02:30 +02:00
|
|
|
enterSettings: () => void,
|
|
|
|
exitSettings: () => void,
|
2018-03-26 23:32:43 +02:00
|
|
|
};
|
|
|
|
|
2021-08-05 10:41:45 +02:00
|
|
|
class SettingsPage extends React.PureComponent<Props> {
|
2018-03-26 23:32:43 +02:00
|
|
|
componentDidMount() {
|
2021-08-05 09:00:21 +02:00
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
2021-08-08 10:26:43 +02:00
|
|
|
const { daemonSettings, isAuthenticated } = this.props;
|
2018-03-26 23:32:43 +02:00
|
|
|
const noDaemonSettings = !daemonSettings || Object.keys(daemonSettings).length === 0;
|
2019-02-12 18:26:50 +01:00
|
|
|
|
2021-08-09 03:08:36 +02:00
|
|
|
return (
|
2021-08-08 10:13:35 +02:00
|
|
|
<Page
|
|
|
|
noFooter
|
|
|
|
settingsPage
|
|
|
|
noSideNavigation
|
2021-08-19 03:36:43 +02:00
|
|
|
backout={{ title: __('Settings'), backLabel: __('Back') }}
|
2021-08-08 10:13:35 +02:00
|
|
|
className="card-stack"
|
|
|
|
>
|
2021-08-19 03:36:43 +02:00
|
|
|
{!isAuthenticated && IS_WEB && (
|
|
|
|
<>
|
|
|
|
<SettingUnauthenticated />
|
|
|
|
<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>
|
|
|
|
}
|
|
|
|
/>
|
2021-08-08 10:13:35 +02:00
|
|
|
</div>
|
2021-08-19 03:36:43 +02:00
|
|
|
</>
|
|
|
|
)}
|
|
|
|
|
|
|
|
{!IS_WEB && noDaemonSettings ? (
|
|
|
|
<section className="card card--section">
|
|
|
|
<div className="card__title card__title--deprecated">{__('Failed to load settings.')}</div>
|
|
|
|
</section>
|
|
|
|
) : (
|
|
|
|
<div className={classnames('card-stack', { 'card--disabled': IS_WEB && !isAuthenticated })}>
|
|
|
|
<SettingAppearance />
|
|
|
|
<SettingAccount />
|
|
|
|
<SettingContent />
|
|
|
|
<SettingSystem />
|
|
|
|
</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
|
|
|
|
2020-07-27 19:43:30 +02:00
|
|
|
export default SettingsPage;
|