add hosting to first run #7598
|
@ -13,6 +13,7 @@ type SetDaemonSettingArg = boolean | string | number;
|
|||
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
|
||||
|
||||
type Props = {
|
||||
// --- select ---
|
||||
viewBlobSpace: number,
|
||||
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
|
||||
viewHostingLimit: number,
|
||||
disabled?: boolean,
|
||||
isSetting: boolean,
|
||||
|
@ -20,14 +21,32 @@ 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
|
||||
setDaemonSetting: (string, ?SetDaemonSettingArg) => void,
|
||||
cleanBlobs: () => string,
|
||||
getDaemonStatus: () => void,
|
||||
diskSpace: DiskSpace,
|
||||
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 { viewHostingLimit, setDaemonSetting, cleanBlobs, getDaemonStatus, disabled, isSetting } = 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
|
||||
const {
|
||||
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,
|
||||
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
|
||||
viewHostingLimit,
|
||||
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
|
||||
viewBlobSpace,
|
||||
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
|
||||
setDaemonSetting,
|
||||
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
|
||||
cleanBlobs,
|
||||
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
|
||||
getDaemonStatus,
|
||||
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
|
||||
disabled,
|
||||
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
|
||||
isSetting,
|
||||
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
|
||||
} = 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
|
||||
|
||||
// best effort to recommend a hosting amount default for the user
|
||||
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 totalMB = diskSpace && Math.floor(Number(diskSpace.total) / 1024);
|
||||
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);
|
||||
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 getGB = (val) => (Number(val) / 1024).toFixed(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 recommendedSpace =
|
||||
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 * 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
|
||||
: Math.ceil(Number(getGB(viewBlobSpace))); // current amount to avoid deleting
|
||||
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
|
||||
// daemon settings come in as 'number', but we manage them as 'String'.
|
||||
const [contentBlobSpaceLimitGB, setContentBlobSpaceLimit] = React.useState(
|
||||
viewHostingLimit === 0 ? '0.01' : String(viewHostingLimit / 1024)
|
||||
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
|
||||
viewHostingLimit === 0 ? String(recommendedSpace) : String(viewHostingLimit / 1024)
|
||||
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 [unlimited, setUnlimited] = React.useState(viewHostingLimit === 0);
|
||||
|
|
|||
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
|
what's 0.2?
(I know, but variable would make this clearer)
if 0.01 is special value it probably merits abstraction