2020-07-01 09:57:44 +03:00
|
|
|
import * as React from 'react';
|
|
|
|
import * as Actions from '~/common/actions';
|
|
|
|
import * as System from '~/components/system';
|
2020-04-09 00:29:13 +03:00
|
|
|
|
2020-07-01 09:57:44 +03:00
|
|
|
import { css } from '@emotion/react';
|
2020-04-09 00:29:13 +03:00
|
|
|
|
2020-07-01 09:57:44 +03:00
|
|
|
import ScenePage from '~/components/core/ScenePage';
|
2020-04-09 00:29:13 +03:00
|
|
|
|
|
|
|
const STYLES_GROUP = css`
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
justify-content: space-between;
|
|
|
|
`;
|
|
|
|
|
2020-06-04 09:26:20 +03:00
|
|
|
const STYLES_SUBGROUP = css`
|
|
|
|
padding-left: 24px;
|
|
|
|
`;
|
|
|
|
|
2020-04-09 00:29:13 +03:00
|
|
|
const STYLES_LEFT = css`
|
|
|
|
flex-shrink: 0;
|
|
|
|
padding: 12px 0 0 0;
|
|
|
|
min-width: 480px;
|
|
|
|
`;
|
|
|
|
|
|
|
|
const STYLES_RIGHT = css`
|
|
|
|
min-width: 10%;
|
|
|
|
padding-left: 48px;
|
2020-06-04 09:26:20 +03:00
|
|
|
padding-top: 24px;
|
2020-04-09 00:29:13 +03:00
|
|
|
width: 100%;
|
|
|
|
`;
|
|
|
|
|
|
|
|
export default class SceneSettings extends React.Component {
|
2020-07-01 09:57:44 +03:00
|
|
|
state = { ...this.props.viewer };
|
|
|
|
|
2020-06-08 09:45:53 +03:00
|
|
|
_deferredSave = null;
|
|
|
|
|
|
|
|
_handleSave = async () => {
|
2020-06-09 21:00:36 +03:00
|
|
|
await Actions.setDefaultConfig({
|
2020-06-08 09:45:53 +03:00
|
|
|
config: {
|
|
|
|
hot: {
|
2020-07-01 09:57:44 +03:00
|
|
|
enabled: this.state.settings_cold_enabled,
|
|
|
|
allowUnfreeze: this.state.settings_hot_allow_unfreeze,
|
2020-06-08 09:45:53 +03:00
|
|
|
ipfs: {
|
2020-07-01 09:57:44 +03:00
|
|
|
addTimeout: this.state.settings_hot_ipfs_add_timeout,
|
2020-06-08 09:45:53 +03:00
|
|
|
},
|
|
|
|
},
|
|
|
|
cold: {
|
2020-07-01 09:57:44 +03:00
|
|
|
enabled: this.state.settings_cold_enabled,
|
2020-06-08 09:45:53 +03:00
|
|
|
filecoin: {
|
2020-07-01 09:57:44 +03:00
|
|
|
addr: this.state.settings_cold_default_address,
|
|
|
|
dealMinDuration: this.state.settings_cold_default_duration,
|
|
|
|
repFactor: this.state.settings_cold_default_replication_factor,
|
|
|
|
excludedMinersList: this.state.settings_cold_default_excluded_miners,
|
|
|
|
trustedMinersList: this.state.settings_cold_default_trusted_miners,
|
|
|
|
maxPrice: this.state.settings_cold_default_max_price,
|
2020-06-08 09:45:53 +03:00
|
|
|
renew: {
|
2020-07-01 09:57:44 +03:00
|
|
|
enabled: this.state.settings_cold_default_auto_renew,
|
|
|
|
threshold: this.state.settings_cold_default_auto_renew_max_price,
|
2020-06-08 09:45:53 +03:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2020-04-09 00:29:13 +03:00
|
|
|
_handleChange = (e) => {
|
2020-07-01 09:57:44 +03:00
|
|
|
this.setState({ [e.target.name]: e.target.value });
|
2020-04-09 00:29:13 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
render() {
|
2020-06-04 09:26:20 +03:00
|
|
|
let addresses = {};
|
|
|
|
|
2020-07-01 09:57:44 +03:00
|
|
|
this.state.addresses.forEach((a) => {
|
2020-06-04 09:26:20 +03:00
|
|
|
addresses[a.address] = a;
|
|
|
|
});
|
|
|
|
|
2020-07-01 09:57:44 +03:00
|
|
|
const currentAddress = addresses[this.state.settings_cold_default_address];
|
2020-06-04 09:26:20 +03:00
|
|
|
|
2020-04-09 00:29:13 +03:00
|
|
|
return (
|
|
|
|
<ScenePage>
|
|
|
|
<System.H1>Settings</System.H1>
|
|
|
|
|
|
|
|
<System.H2 style={{ marginTop: 48 }}>Storage defaults</System.H2>
|
|
|
|
|
|
|
|
<div css={STYLES_GROUP} style={{ marginTop: 32 }}>
|
|
|
|
<div css={STYLES_LEFT}>
|
|
|
|
<System.DescriptionGroup
|
|
|
|
label="Automatically approve deals"
|
|
|
|
tooltip="When this is enabled you will skip the confirmation step, but if you do not have enough Filecoin you will receive a warning."
|
|
|
|
description="Enable this if every storage deal should be automatically approved to skip confirmation."
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
<div css={STYLES_RIGHT}>
|
|
|
|
<System.Toggle
|
|
|
|
name="settings_deals_auto_approve"
|
|
|
|
onChange={this._handleChange}
|
2020-07-01 09:57:44 +03:00
|
|
|
active={this.state.settings_deals_auto_approve}
|
2020-04-09 00:29:13 +03:00
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
2020-06-04 09:26:20 +03:00
|
|
|
<div css={STYLES_GROUP} style={{ marginTop: 32 }}>
|
|
|
|
<div css={STYLES_LEFT}>
|
|
|
|
<System.DescriptionGroup
|
|
|
|
label="Enable cold storage"
|
|
|
|
tooltip="Placeholder"
|
|
|
|
description="By enabling cold storage, every time you make a deal your data will be stored on the Filecoin Network."
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
<div css={STYLES_RIGHT}>
|
|
|
|
<System.Toggle
|
|
|
|
name="settings_cold_enabled"
|
|
|
|
onChange={this._handleChange}
|
2020-07-01 09:57:44 +03:00
|
|
|
active={this.state.settings_cold_enabled}
|
2020-06-04 09:26:20 +03:00
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
2020-07-01 09:57:44 +03:00
|
|
|
{this.state.settings_cold_enabled ? (
|
2020-06-04 09:26:20 +03:00
|
|
|
<div css={STYLES_SUBGROUP}>
|
|
|
|
<System.SelectMenu
|
|
|
|
containerStyle={{ marginTop: 24 }}
|
|
|
|
label="Default Filecoin address"
|
|
|
|
description="Default Filecoin address settings description."
|
|
|
|
tooltip="Placeholder."
|
|
|
|
name="settings_cold_default_address"
|
2020-07-01 09:57:44 +03:00
|
|
|
value={this.state.settings_cold_default_address}
|
2020-06-04 09:26:20 +03:00
|
|
|
category="address"
|
|
|
|
onChange={this._handleChange}
|
2020-07-01 09:57:44 +03:00
|
|
|
options={this.state.addresses}>
|
|
|
|
{currentAddress ? currentAddress.name : 'None'}
|
2020-06-04 09:26:20 +03:00
|
|
|
</System.SelectMenu>
|
|
|
|
|
|
|
|
<System.Input
|
|
|
|
containerStyle={{ marginTop: 24 }}
|
|
|
|
label="Default Filecoin deal duration"
|
2020-06-17 21:05:13 +03:00
|
|
|
description="Default Filecoin deal duration settings description. Current deal duration is in epochs but should change to months/weeks/days."
|
2020-06-04 09:26:20 +03:00
|
|
|
tooltip="Placeholder."
|
|
|
|
name="settings_cold_default_duration"
|
2020-06-09 21:00:36 +03:00
|
|
|
type="number"
|
2020-07-01 09:57:44 +03:00
|
|
|
value={this.state.settings_cold_default_duration}
|
2020-06-17 21:05:13 +03:00
|
|
|
placeholder="Type in epochs (~25 seconds)"
|
2020-06-04 09:26:20 +03:00
|
|
|
onChange={this._handleChange}
|
|
|
|
/>
|
|
|
|
|
|
|
|
<System.Input
|
|
|
|
containerStyle={{ marginTop: 24 }}
|
|
|
|
label="Default Filecoin replication factor"
|
|
|
|
description="Default Filecoin replication factor settings description."
|
|
|
|
tooltip="Placeholder."
|
|
|
|
name="settings_cold_default_replication_factor"
|
2020-07-01 09:57:44 +03:00
|
|
|
value={this.state.settings_cold_default_replication_factor}
|
2020-06-04 09:26:20 +03:00
|
|
|
placeholder="Type in amount of miners"
|
|
|
|
onChange={this._handleChange}
|
|
|
|
/>
|
|
|
|
|
|
|
|
<System.Input
|
|
|
|
containerStyle={{ marginTop: 24 }}
|
|
|
|
label="Max Filecoin price."
|
|
|
|
description="Set the maximum Filecoin price you're willing to pay."
|
|
|
|
tooltip="Placeholder."
|
|
|
|
name="settings_cold_default_max_price"
|
2020-07-01 09:57:44 +03:00
|
|
|
value={this.state.settings_cold_default_max_price}
|
2020-06-04 09:26:20 +03:00
|
|
|
placeholder="Type in amount of Filecoin"
|
|
|
|
onChange={this._handleChange}
|
|
|
|
/>
|
|
|
|
|
|
|
|
<System.CheckBox
|
|
|
|
style={{ marginTop: 48 }}
|
|
|
|
name="settings_cold_default_auto_renew"
|
2020-07-01 09:57:44 +03:00
|
|
|
value={this.state.settings_cold_default_auto_renew}
|
|
|
|
onChange={this._handleChange}>
|
2020-06-04 09:26:20 +03:00
|
|
|
Enable auto renew for Filecoin Network deals.
|
|
|
|
</System.CheckBox>
|
|
|
|
|
|
|
|
<System.Input
|
|
|
|
containerStyle={{ marginTop: 24 }}
|
|
|
|
label="Max Filecoin deal auto renew price."
|
|
|
|
description="Set the maximum Filecoin price you're willing to pay for auto renew."
|
|
|
|
tooltip="Placeholder."
|
|
|
|
name="settings_cold_default_auto_renew_max_price"
|
2020-07-01 09:57:44 +03:00
|
|
|
value={this.state.settings_cold_default_auto_renew_max_price}
|
2020-06-04 09:26:20 +03:00
|
|
|
placeholder="Type in amount of Filecoin"
|
|
|
|
onChange={this._handleChange}
|
|
|
|
/>
|
2020-07-01 09:57:44 +03:00
|
|
|
<div style={{ marginTop: 32 }}>
|
|
|
|
<System.ButtonPrimary onClick={this._handleSave}>Save</System.ButtonPrimary>
|
|
|
|
</div>
|
2020-06-04 09:26:20 +03:00
|
|
|
</div>
|
|
|
|
) : null}
|
|
|
|
|
|
|
|
<div css={STYLES_GROUP} style={{ marginTop: 32 }}>
|
|
|
|
<div css={STYLES_LEFT}>
|
|
|
|
<System.DescriptionGroup
|
|
|
|
label="Enable hot storage"
|
|
|
|
tooltip="Placeholder"
|
|
|
|
description="By enabling hot storage, every time you make a deal your data will be stored on IPFS."
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
<div css={STYLES_RIGHT}>
|
|
|
|
<System.Toggle
|
|
|
|
name="settings_hot_enabled"
|
|
|
|
onChange={this._handleChange}
|
2020-07-01 09:57:44 +03:00
|
|
|
active={this.state.settings_hot_enabled}
|
2020-06-04 09:26:20 +03:00
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
2020-07-01 09:57:44 +03:00
|
|
|
{this.state.settings_hot_enabled ? (
|
2020-06-04 09:26:20 +03:00
|
|
|
<div css={STYLES_SUBGROUP}>
|
|
|
|
<System.CheckBox
|
|
|
|
style={{ marginTop: 48 }}
|
|
|
|
name="settings_hot_allow_unfreeze"
|
2020-07-01 09:57:44 +03:00
|
|
|
value={this.state.settings_hot_allow_unfreeze}
|
|
|
|
onChange={this._handleChange}>
|
2020-06-04 09:26:20 +03:00
|
|
|
IPFS allow unfreeze setting description.
|
|
|
|
</System.CheckBox>
|
|
|
|
|
|
|
|
<System.Input
|
|
|
|
containerStyle={{ marginTop: 24 }}
|
|
|
|
label="Add timeout"
|
|
|
|
description="Add IPFS timeout setting description."
|
|
|
|
tooltip="Placeholder."
|
|
|
|
name="settings_hot_ipfs_add_timeout"
|
2020-07-01 09:57:44 +03:00
|
|
|
value={this.state.settings_hot_ipfs_add_timeout}
|
2020-06-04 09:26:20 +03:00
|
|
|
placeholder="Type in seconds"
|
|
|
|
onChange={this._handleChange}
|
|
|
|
/>
|
2020-07-01 09:57:44 +03:00
|
|
|
|
|
|
|
<div style={{ marginTop: 32 }}>
|
|
|
|
<System.ButtonPrimary onClick={this._handleSave}>Save</System.ButtonPrimary>
|
|
|
|
</div>
|
2020-06-04 09:26:20 +03:00
|
|
|
</div>
|
|
|
|
) : null}
|
|
|
|
</ScenePage>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|