2020-02-19 07:31:40 +01:00
|
|
|
// @flow
|
|
|
|
import React from 'react';
|
|
|
|
import PrivacyAgreement from 'component/privacyAgreement';
|
2022-06-02 21:24:11 +02:00
|
|
|
import HostingSplash from 'component/hostingSplash';
|
|
|
|
import HostingSplashCustom from 'component/hostingSplashCustom';
|
2022-04-01 21:10:32 +02:00
|
|
|
import WelcomeSplash from 'component/welcomeSplash';
|
2020-02-19 07:31:40 +01:00
|
|
|
import Page from 'component/page';
|
2022-04-01 21:10:32 +02:00
|
|
|
import { useHistory } from 'react-router-dom';
|
|
|
|
|
|
|
|
const SPLASH_PAGE = 0;
|
|
|
|
const PRIVACY_PAGE = 1;
|
2022-06-02 21:24:11 +02:00
|
|
|
const HOSTING_PAGE = 2;
|
|
|
|
const HOSTING_ADVANCED = 3;
|
|
|
|
|
2022-04-01 21:10:32 +02:00
|
|
|
type DaemonStatus = {
|
|
|
|
disk_space: {
|
|
|
|
content_blobs_storage_used_mb: string,
|
|
|
|
published_blobs_storage_used_mb: string,
|
|
|
|
running: true,
|
|
|
|
seed_blobs_storage_used_mb: string,
|
|
|
|
total_used_mb: string,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
type DaemonSettings = {
|
|
|
|
download_dir: string,
|
|
|
|
share_usage_data: boolean,
|
|
|
|
max_connections_per_download?: number,
|
|
|
|
save_files: boolean,
|
|
|
|
save_blobs: boolean,
|
|
|
|
ffmpeg_path: string,
|
|
|
|
};
|
|
|
|
|
|
|
|
type Props = {
|
|
|
|
// --- select ---
|
|
|
|
daemonSettings: DaemonSettings,
|
|
|
|
daemonStatus: DaemonStatus,
|
|
|
|
// -- perform ---
|
|
|
|
updateWelcomeVersion: () => void,
|
|
|
|
};
|
|
|
|
export default function Welcome(props: Props) {
|
|
|
|
const { updateWelcomeVersion } = props;
|
|
|
|
// const { save_blobs: saveBlobs } = daemonSettings || {};
|
|
|
|
const [welcomePage, setWelcomePage] = React.useState(SPLASH_PAGE);
|
|
|
|
const { replace } = useHistory();
|
|
|
|
|
|
|
|
const handleNextPage = () => {
|
|
|
|
if (welcomePage === SPLASH_PAGE) {
|
|
|
|
setWelcomePage(PRIVACY_PAGE);
|
2022-06-02 21:24:11 +02:00
|
|
|
} else if (welcomePage === PRIVACY_PAGE) {
|
|
|
|
setWelcomePage(HOSTING_PAGE);
|
|
|
|
} else if (welcomePage === HOSTING_PAGE) {
|
|
|
|
setWelcomePage(HOSTING_ADVANCED);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
const handleGoBack = () => {
|
|
|
|
if (welcomePage >= 1) {
|
|
|
|
setWelcomePage(welcomePage - 1);
|
2022-04-01 21:10:32 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
const handleDone = () => {
|
|
|
|
updateWelcomeVersion();
|
|
|
|
replace('/');
|
|
|
|
};
|
2020-02-19 07:31:40 +01:00
|
|
|
|
|
|
|
return (
|
2020-08-21 17:49:13 +02:00
|
|
|
<Page noHeader noSideNavigation>
|
2022-04-01 21:10:32 +02:00
|
|
|
{welcomePage === SPLASH_PAGE && <WelcomeSplash handleNextPage={handleNextPage} />}
|
2022-06-02 21:24:11 +02:00
|
|
|
{welcomePage === PRIVACY_PAGE && <PrivacyAgreement handleNextPage={handleNextPage} />}
|
|
|
|
{welcomePage === HOSTING_PAGE && <HostingSplash handleNextPage={handleNextPage} handleDone={handleDone} />}
|
|
|
|
{welcomePage === HOSTING_ADVANCED && (
|
|
|
|
<HostingSplashCustom handleNextPage={handleDone} handleGoBack={handleGoBack} />
|
|
|
|
)}
|
2020-02-19 07:31:40 +01:00
|
|
|
</Page>
|
|
|
|
);
|
|
|
|
}
|