add hosting to first run #7598
|
@ -1,5 +1,6 @@
|
|||
Missing i18n in several places Missing i18n in several places
|
||||
// @flow
|
||||
import * as React from 'react';
|
||||
import I18nMessage from 'component/i18nMessage';
|
||||
Missing i18n in several places Missing i18n in several places
|
||||
|
||||
type Props = {
|
||||
// --- select ---
|
||||
|
@ -18,7 +19,7 @@ function StorageViz(props: Props) {
|
|||
Missing i18n in several places Missing i18n in several places
Missing i18n in several places Missing i18n in several places
|
||||
return (
|
||||
<div className={'storage__wrapper'}>
|
||||
<div className={'storage__bar'}>
|
||||
<div className="help">Cannot get disk space information.</div>
|
||||
Missing i18n in several places Missing i18n in several places
|
||||
<div className="help">{__('Cannot get disk space information.')}</div>
|
||||
Missing i18n in several places Missing i18n in several places
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
@ -64,29 +65,57 @@ function StorageViz(props: Props) {
|
|||
Missing i18n in several places Missing i18n in several places
Missing i18n in several places Missing i18n in several places
|
||||
<div className={'storage__legend-item'}>
|
||||
<div className={'storage__legend-item-swatch storage__legend-item-swatch--private'} />
|
||||
<div className={'storage__legend-item-label'}>
|
||||
<label>Publishes</label>
|
||||
Missing i18n in several places Missing i18n in several places
|
||||
<label>{__('Publishes --[legend, storage category]--')}</label>
|
||||
Missing i18n in several places Missing i18n in several places
|
||||
<div className={'help'}>{`${getGB(privateBlobSpace)} GB`}</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className={'storage__legend-item'}>
|
||||
<div className={'storage__legend-item-swatch storage__legend-item-swatch--auto'} />
|
||||
<div className={'storage__legend-item-label'}>
|
||||
<label>Auto Hosting</label>
|
||||
Missing i18n in several places Missing i18n in several places
|
||||
<label>{__('Auto Hosting --[legend, storage category]--')}</label>
|
||||
Missing i18n in several places Missing i18n in several places
|
||||
<div className={'help'}>
|
||||
{autoHostingLimit === 0 ? __('Disabled') : `${getGB(autoBlobSpace)} of ${getGB(autoHostingLimit)} GB`}
|
||||
Missing i18n in several places Missing i18n in several places
|
||||
{autoHostingLimit === 0 ? (
|
||||
Missing i18n in several places Missing i18n in several places
|
||||
__('Disabled')
|
||||
Missing i18n in several places Missing i18n in several places
|
||||
) : (
|
||||
Missing i18n in several places Missing i18n in several places
|
||||
<I18nMessage
|
||||
Missing i18n in several places Missing i18n in several places
|
||||
tokens={{
|
||||
Missing i18n in several places Missing i18n in several places
|
||||
spaceUsed: getGB(autoBlobSpace),
|
||||
Missing i18n in several places Missing i18n in several places
|
||||
limit: getGB(autoHostingLimit),
|
||||
Missing i18n in several places Missing i18n in several places
|
||||
}}
|
||||
Missing i18n in several places Missing i18n in several places
|
||||
>
|
||||
Missing i18n in several places Missing i18n in several places
|
||||
%spaceUsed% of %limit% GB
|
||||
Missing i18n in several places Missing i18n in several places
|
||||
</I18nMessage>
|
||||
Missing i18n in several places Missing i18n in several places
|
||||
)}
|
||||
Missing i18n in several places Missing i18n in several places
|
||||
{
|
||||
Missing i18n in several places Missing i18n in several places
|
||||
<I18nMessage
|
||||
Missing i18n in several places Missing i18n in several places
|
||||
tokens={{
|
||||
Missing i18n in several places Missing i18n in several places
|
||||
spaceUsed: getGB(viewBlobSpace),
|
||||
Missing i18n in several places Missing i18n in several places
|
||||
limit: viewHostingLimit !== 0 ? getGB(viewHostingLimit) : getGB(viewFree),
|
||||
Missing i18n in several places Missing i18n in several places
|
||||
}}
|
||||
Missing i18n in several places Missing i18n in several places
|
||||
>
|
||||
Missing i18n in several places Missing i18n in several places
|
||||
%spaceUsed% of %limit% Free GB
|
||||
Missing i18n in several places Missing i18n in several places
|
||||
</I18nMessage>
|
||||
Missing i18n in several places Missing i18n in several places
|
||||
}
|
||||
Missing i18n in several places Missing i18n in several places
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className={'storage__legend-item'}>
|
||||
<div className={'storage__legend-item-swatch storage__legend-item-swatch--viewed'} />
|
||||
<div className={'storage__legend-item-label'}>
|
||||
<label>View Hosting</label>
|
||||
Missing i18n in several places Missing i18n in several places
|
||||
<label>{__('View Hosting --[legend, storage category]--')}</label>
|
||||
Missing i18n in several places Missing i18n in several places
|
||||
<div className={'help'}>
|
||||
{viewHostingLimit === 1
|
||||
Missing i18n in several places Missing i18n in several places
|
||||
? __('Disabled')
|
||||
Missing i18n in several places Missing i18n in several places
|
||||
: `${getGB(viewBlobSpace)} of ${
|
||||
Missing i18n in several places Missing i18n in several places
|
||||
viewHostingLimit !== 0 ? getGB(viewHostingLimit) : `${getGB(viewFree)} Free`
|
||||
Missing i18n in several places Missing i18n in several places
|
||||
} GB`}
|
||||
Missing i18n in several places Missing i18n in several places
|
||||
{viewHostingLimit === 1 ? (
|
||||
Missing i18n in several places Missing i18n in several places
|
||||
__('Disabled')
|
||||
Missing i18n in several places Missing i18n in several places
|
||||
) : (
|
||||
Missing i18n in several places Missing i18n in several places
|
||||
<I18nMessage
|
||||
Missing i18n in several places Missing i18n in several places
|
||||
tokens={{
|
||||
Missing i18n in several places Missing i18n in several places
|
||||
spaceUsed: getGB(viewBlobSpace),
|
||||
Missing i18n in several places Missing i18n in several places
|
||||
limit: viewHostingLimit !== 0 ? getGB(viewHostingLimit) : getGB(viewFree),
|
||||
Missing i18n in several places Missing i18n in several places
|
||||
}}
|
||||
Missing i18n in several places Missing i18n in several places
|
||||
>
|
||||
Missing i18n in several places Missing i18n in several places
|
||||
%spaceUsed% of %limit% Free GB
|
||||
Missing i18n in several places Missing i18n in several places
|
||||
</I18nMessage>
|
||||
Missing i18n in several places Missing i18n in several places
|
||||
)}
|
||||
Missing i18n in several places Missing i18n in several places
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -94,7 +123,7 @@ function StorageViz(props: Props) {
|
|||
Missing i18n in several places Missing i18n in several places
Missing i18n in several places Missing i18n in several places
|
||||
<div className={'storage__legend-item'}>
|
||||
<div className={'storage__legend-item-swatch storage__legend-item-swatch--free'} />
|
||||
<div className={'storage__legend-item-label'}>
|
||||
<label>Free</label>
|
||||
Missing i18n in several places Missing i18n in several places
|
||||
<label>{__('Free --[legend, unused disk space]--')}</label>
|
||||
Missing i18n in several places Missing i18n in several places
|
||||
<div className={'help'}>{`${getGB(unallocFree)} GB`}</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|||
Missing i18n in several places Missing i18n in several places
Missing i18n in several places Missing i18n in several places
|
|
@ -13,15 +13,11 @@ type Props = {
|
|||
unnecessary function unnecessary function
unnecessary function unnecessary function
|
||||
function HostingSplashCustom(props: Props) {
|
||||
const { handleNextPage, handleGoBack } = props;
|
||||
|
||||
function handleSubmit() {
|
||||
unnecessary function unnecessary function
|
||||
handleNextPage();
|
||||
unnecessary function unnecessary function
|
||||
}
|
||||
unnecessary function unnecessary function
|
||||
|
||||
unnecessary function unnecessary function
|
||||
return (
|
||||
<section className="main--contained">
|
||||
<div className={'first-run__wrapper'}>
|
||||
<SettingStorage isWelcome />
|
||||
<Form onSubmit={handleSubmit} className="section__body">
|
||||
unnecessary function unnecessary function
|
||||
<Form onSubmit={handleNextPage} className="section__body">
|
||||
unnecessary function unnecessary function
|
||||
<div className={'card__actions'}>
|
||||
<Button button="primary" label={__(`Let's go`)} type="submit" />
|
||||
<Button button="link" label={__(`Go back`)} onClick={handleGoBack} />
|
||||
|
|
|||
unnecessary function unnecessary function
unnecessary function unnecessary function
|
|
@ -53,7 +53,7 @@ export default function SettingStorage(props: Props) {
|
|||
make LBRY users happy make LBRY users happy
helping -> hosting (?) helping -> hosting (?)
slice -> portion drop "currently" slice -> portion
drop "currently"
make LBRY users happy make LBRY users happy
helping -> hosting (?) helping -> hosting (?)
slice -> portion drop "currently" slice -> portion
drop "currently"
|
||||
title={__('Enable Data Hosting')}
|
||||
subtitle={
|
||||
<React.Fragment>
|
||||
{__('Help improve the P2P data network (and make LBRY happy) by hosting data.')}{' '}
|
||||
make LBRY users happy make LBRY users happy
helping -> hosting (?) helping -> hosting (?)
slice -> portion drop "currently" slice -> portion
drop "currently"
|
||||
{__('Help improve the P2P data network (and make LBRY users happy) by hosting data.')}
|
||||
make LBRY users happy make LBRY users happy
helping -> hosting (?) helping -> hosting (?)
slice -> portion drop "currently" slice -> portion
drop "currently"
|
||||
</React.Fragment>
|
||||
}
|
||||
footer={<AppStorageViz />}
|
||||
|
@ -66,7 +66,7 @@ export default function SettingStorage(props: Props) {
|
|||
make LBRY users happy make LBRY users happy
helping -> hosting (?) helping -> hosting (?)
slice -> portion drop "currently" slice -> portion
drop "currently"
make LBRY users happy make LBRY users happy
helping -> hosting (?) helping -> hosting (?)
slice -> portion drop "currently" slice -> portion
drop "currently"
|
||||
disabled={!saveBlobs}
|
||||
subtitle={
|
||||
<React.Fragment>
|
||||
{__("View History Hosting lets you choose how much storage to use helping content you've consumed.")}{' '}
|
||||
make LBRY users happy make LBRY users happy
helping -> hosting (?) helping -> hosting (?)
slice -> portion drop "currently" slice -> portion
drop "currently"
|
||||
{__("View History Hosting lets you choose how much storage to use hosting content you've consumed.")}{' '}
|
||||
make LBRY users happy make LBRY users happy
helping -> hosting (?) helping -> hosting (?)
slice -> portion drop "currently" slice -> portion
drop "currently"
|
||||
<Button button="link" label={__('Learn more')} href="https://lbry.com/faq/host-content" />
|
||||
</React.Fragment>
|
||||
}
|
||||
|
@ -79,7 +79,7 @@ export default function SettingStorage(props: Props) {
|
|||
make LBRY users happy make LBRY users happy
helping -> hosting (?) helping -> hosting (?)
slice -> portion drop "currently" slice -> portion
drop "currently"
make LBRY users happy make LBRY users happy
helping -> hosting (?) helping -> hosting (?)
slice -> portion drop "currently" slice -> portion
drop "currently"
|
||||
disabled={!saveBlobs}
|
||||
subtitle={
|
||||
<React.Fragment>
|
||||
{__('Automatic Hosting downloads a small slice of content currently active on the network.')}{' '}
|
||||
make LBRY users happy make LBRY users happy
helping -> hosting (?) helping -> hosting (?)
slice -> portion drop "currently" slice -> portion
drop "currently"
|
||||
{__('Automatic Hosting downloads a small portion of content active on the network.')}{' '}
|
||||
make LBRY users happy make LBRY users happy
helping -> hosting (?) helping -> hosting (?)
slice -> portion drop "currently" slice -> portion
drop "currently"
|
||||
<Button button="link" label={__('Learn more')} href="https://lbry.com/faq/host-content" />
|
||||
</React.Fragment>
|
||||
}
|
||||
|
|
|||
make LBRY users happy make LBRY users happy
helping -> hosting (?) helping -> hosting (?)
slice -> portion drop "currently" slice -> portion
drop "currently"
make LBRY users happy make LBRY users happy
helping -> hosting (?) helping -> hosting (?)
slice -> portion drop "currently" slice -> portion
drop "currently"
|
|
@ -24,6 +24,10 @@ type Props = {
|
|||
what's 0.2? (I know, but variable would make this clearer) what's 0.2?
(I know, but variable would make this clearer)
if 0.01 is special value it probably merits abstraction if 0.01 is special value it probably merits abstraction
what's 0.2? (I know, but variable would make this clearer) what's 0.2?
(I know, but variable would make this clearer)
if 0.01 is special value it probably merits abstraction if 0.01 is special value it probably merits abstraction
|
||||
diskSpace: DiskSpace,
|
||||
};
|
||||
|
||||
const TWENTY_PERCENT = 0.2;
|
||||
what's 0.2? (I know, but variable would make this clearer) what's 0.2?
(I know, but variable would make this clearer)
if 0.01 is special value it probably merits abstraction if 0.01 is special value it probably merits abstraction
|
||||
const TEN_PERCENT = 0.1;
|
||||
what's 0.2? (I know, but variable would make this clearer) what's 0.2?
(I know, but variable would make this clearer)
if 0.01 is special value it probably merits abstraction if 0.01 is special value it probably merits abstraction
|
||||
const MINIMUM_VIEW_SETTING = '0.01';
|
||||
what's 0.2? (I know, but variable would make this clearer) what's 0.2?
(I know, but variable would make this clearer)
if 0.01 is special value it probably merits abstraction if 0.01 is special value it probably merits abstraction
|
||||
|
||||
what's 0.2? (I know, but variable would make this clearer) what's 0.2?
(I know, but variable would make this clearer)
if 0.01 is special value it probably merits abstraction if 0.01 is special value it probably merits abstraction
|
||||
function SettingViewHosting(props: Props) {
|
||||
const {
|
||||
diskSpace,
|
||||
|
@ -41,8 +45,8 @@ function SettingViewHosting(props: Props) {
|
|||
what's 0.2? (I know, but variable would make this clearer) what's 0.2?
(I know, but variable would make this clearer)
if 0.01 is special value it probably merits abstraction if 0.01 is special value it probably merits abstraction
what's 0.2? (I know, but variable would make this clearer) what's 0.2?
(I know, but variable would make this clearer)
if 0.01 is special value it probably merits abstraction if 0.01 is special value it probably merits abstraction
|
||||
const freeMB = diskSpace && Math.floor(Number(diskSpace.free) / 1024);
|
||||
const getGB = (val) => (Number(val) / 1024).toFixed(2);
|
||||
const recommendedSpace =
|
||||
freeMB > totalMB * 0.2 // plenty of space?
|
||||
what's 0.2? (I know, but variable would make this clearer) what's 0.2?
(I know, but variable would make this clearer)
if 0.01 is special value it probably merits abstraction if 0.01 is special value it probably merits abstraction
|
||||
? Math.ceil(Number(getGB(totalMB * 0.1))) // 10% of total
|
||||
what's 0.2? (I know, but variable would make this clearer) what's 0.2?
(I know, but variable would make this clearer)
if 0.01 is special value it probably merits abstraction if 0.01 is special value it probably merits abstraction
|
||||
freeMB > totalMB * TWENTY_PERCENT // plenty of space?
|
||||
what's 0.2? (I know, but variable would make this clearer) what's 0.2?
(I know, but variable would make this clearer)
if 0.01 is special value it probably merits abstraction if 0.01 is special value it probably merits abstraction
|
||||
? Math.ceil(Number(getGB(totalMB * TEN_PERCENT))) // 10% of total
|
||||
what's 0.2? (I know, but variable would make this clearer) what's 0.2?
(I know, but variable would make this clearer)
if 0.01 is special value it probably merits abstraction if 0.01 is special value it probably merits abstraction
|
||||
: Math.ceil(Number(getGB(viewBlobSpace))); // current amount to avoid deleting
|
||||
// daemon settings come in as 'number', but we manage them as 'String'.
|
||||
const [contentBlobSpaceLimitGB, setContentBlobSpaceLimit] = React.useState(
|
||||
|
@ -55,7 +59,7 @@ function SettingViewHosting(props: Props) {
|
|||
what's 0.2? (I know, but variable would make this clearer) what's 0.2?
(I know, but variable would make this clearer)
if 0.01 is special value it probably merits abstraction if 0.01 is special value it probably merits abstraction
what's 0.2? (I know, but variable would make this clearer) what's 0.2?
(I know, but variable would make this clearer)
if 0.01 is special value it probably merits abstraction if 0.01 is special value it probably merits abstraction
|
||||
if (gb === '') {
|
||||
setContentBlobSpaceLimit('');
|
||||
} else if (gb === '0') {
|
||||
setContentBlobSpaceLimit('0.01'); // setting 0 means unlimited.
|
||||
what's 0.2? (I know, but variable would make this clearer) what's 0.2?
(I know, but variable would make this clearer)
if 0.01 is special value it probably merits abstraction if 0.01 is special value it probably merits abstraction
|
||||
setContentBlobSpaceLimit(MINIMUM_VIEW_SETTING); // setting 0 means unlimited.
|
||||
what's 0.2? (I know, but variable would make this clearer) what's 0.2?
(I know, but variable would make this clearer)
if 0.01 is special value it probably merits abstraction if 0.01 is special value it probably merits abstraction
|
||||
} else {
|
||||
if (isTrulyANumber(Number(gb))) {
|
||||
setContentBlobSpaceLimit(gb);
|
||||
|
@ -69,7 +73,7 @@ function SettingViewHosting(props: Props) {
|
|||
what's 0.2? (I know, but variable would make this clearer) what's 0.2?
(I know, but variable would make this clearer)
if 0.01 is special value it probably merits abstraction if 0.01 is special value it probably merits abstraction
what's 0.2? (I know, but variable would make this clearer) what's 0.2?
(I know, but variable would make this clearer)
if 0.01 is special value it probably merits abstraction if 0.01 is special value it probably merits abstraction
|
||||
} else {
|
||||
await setDaemonSetting(
|
||||
DAEMON_SETTINGS.BLOB_STORAGE_LIMIT_MB,
|
||||
String(contentBlobSpaceLimitGB === '0.01' ? '1' : convertGbToMbStr(contentBlobSpaceLimitGB))
|
||||
what's 0.2? (I know, but variable would make this clearer) what's 0.2?
(I know, but variable would make this clearer)
if 0.01 is special value it probably merits abstraction if 0.01 is special value it probably merits abstraction
|
||||
contentBlobSpaceLimitGB === MINIMUM_VIEW_SETTING ? '1' : convertGbToMbStr(contentBlobSpaceLimitGB)
|
||||
what's 0.2? (I know, but variable would make this clearer) what's 0.2?
(I know, but variable would make this clearer)
if 0.01 is special value it probably merits abstraction if 0.01 is special value it probably merits abstraction
|
||||
);
|
||||
}
|
||||
await cleanBlobs();
|
||||
|
@ -152,7 +156,7 @@ function SettingViewHosting(props: Props) {
|
|||
what's 0.2? (I know, but variable would make this clearer) what's 0.2?
(I know, but variable would make this clearer)
if 0.01 is special value it probably merits abstraction if 0.01 is special value it probably merits abstraction
what's 0.2? (I know, but variable would make this clearer) what's 0.2?
(I know, but variable would make this clearer)
if 0.01 is special value it probably merits abstraction if 0.01 is special value it probably merits abstraction
|
||||
onWheel={(e) => e.preventDefault()}
|
||||
label={__(`View Hosting Limit (GB)`)}
|
||||
onChange={(e) => handleContentLimitChange(e.target.value)}
|
||||
value={Number(contentBlobSpaceLimitGB) <= Number('0.01') ? '0' : contentBlobSpaceLimitGB}
|
||||
what's 0.2? (I know, but variable would make this clearer) what's 0.2?
(I know, but variable would make this clearer)
if 0.01 is special value it probably merits abstraction if 0.01 is special value it probably merits abstraction
|
||||
value={Number(contentBlobSpaceLimitGB) <= Number(MINIMUM_VIEW_SETTING) ? '0' : contentBlobSpaceLimitGB}
|
||||
what's 0.2? (I know, but variable would make this clearer) what's 0.2?
(I know, but variable would make this clearer)
if 0.01 is special value it probably merits abstraction if 0.01 is special value it probably merits abstraction
|
||||
/>
|
||||
</div>
|
||||
</>
|
||||
|
|
|||
what's 0.2? (I know, but variable would make this clearer) what's 0.2?
(I know, but variable would make this clearer)
if 0.01 is special value it probably merits abstraction if 0.01 is special value it probably merits abstraction
what's 0.2? (I know, but variable would make this clearer) what's 0.2?
(I know, but variable would make this clearer)
if 0.01 is special value it probably merits abstraction if 0.01 is special value it probably merits abstraction
|
Missing i18n in several places