Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0d48fad
commit dd7410e
Showing
12 changed files
with
247 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
134 changes: 134 additions & 0 deletions
134
source/renderer/app/components/settings/categories/StakePoolsSettings.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
// @flow | ||
import React, { Component } from 'react'; | ||
import classnames from 'classnames'; | ||
import { Select } from 'react-polymorph/lib/components/Select'; | ||
import { SelectSkin } from 'react-polymorph/lib/skins/simple/SelectSkin'; | ||
import { Input } from 'react-polymorph/lib/components/Input'; | ||
import { InputSkin } from 'react-polymorph/lib/skins/simple/InputSkin'; | ||
import { observer } from 'mobx-react'; | ||
import { defineMessages, intlShape } from 'react-intl'; | ||
import { submitOnEnter } from '../../../utils/form'; | ||
import styles from './StakePoolsSettings.scss'; | ||
import { | ||
INTERNAL_SMASH_SERVERS, | ||
SMASH_SERVER_TYPES, | ||
} from '../../../config/stakingConfig'; | ||
import type { SmashServerType } from '../../../types/stakingTypes'; | ||
|
||
const messages = defineMessages({ | ||
smashSelectLabel: { | ||
id: 'settings.stakePools.smash.select.label', | ||
defaultMessage: '!!!Off-chain data server (SMASH)', | ||
description: | ||
'smashSelectLabel for the "Smash" selection on the Stake Pools settings page.', | ||
}, | ||
smashSelectCustomServer: { | ||
id: 'settings.stakePools.smash.select.placeholder', | ||
defaultMessage: '!!!Custom server', | ||
description: | ||
'smashSelectCustomServer option for the "Smash" selection on the Stake Pools settings page.', | ||
}, | ||
smashURLSelectLabel: { | ||
id: 'settings.stakePools.smashUrl.select.label', | ||
defaultMessage: '!!!SMASH server URL', | ||
description: | ||
'smashURLSelectLabel for the "Smash Custom Server" selection on the Stake Pools settings page.', | ||
}, | ||
smashUrlSelectPlaceholder: { | ||
id: 'settings.stakePools.smashUrl.select.placeholder', | ||
defaultMessage: '!!!Enter custom server', | ||
description: | ||
'smashUrlSelectPlaceholder for the "Smash Custom Server" selection on the Stake Pools settings page.', | ||
}, | ||
}); | ||
|
||
type Props = { | ||
smashServerType: string, | ||
smashServerUrl?: string, | ||
onSelectSmashServerType: Function, | ||
onSelectSmashServerUrl: Function, | ||
}; | ||
|
||
@observer | ||
export default class StakePoolsSettings extends Component<Props> { | ||
static contextTypes = { | ||
intl: intlShape.isRequired, | ||
}; | ||
|
||
componentWillUnmount() { | ||
const { | ||
smashServerType, | ||
smashServerUrl, | ||
onSelectSmashServerType, | ||
} = this.props; | ||
|
||
if (smashServerType === SMASH_SERVER_TYPES.CUSTOM && !smashServerUrl) { | ||
onSelectSmashServerType({ smashServerType: SMASH_SERVER_TYPES.IOHK }); | ||
} | ||
} | ||
|
||
handleSubmit = () => { | ||
console.log('handleSubmit'); | ||
// if (this.isConfirmDisabled()) { | ||
// return false; | ||
// } | ||
|
||
// return this.form.submit({ | ||
// onSuccess: (form) => { | ||
// const { onConfirm } = this.props; | ||
// const { passphrase } = form.values(); | ||
// onConfirm(passphrase); | ||
// }, | ||
// onError: () => null, | ||
// }); | ||
}; | ||
|
||
handleSubmitOnEnter = (event: KeyboardEvent) => | ||
submitOnEnter(this.handleSubmit, event); | ||
|
||
render() { | ||
const { | ||
smashServerType, | ||
smashServerUrl, | ||
onSelectSmashServerType, | ||
onSelectSmashServerUrl, | ||
} = this.props; | ||
const { intl } = this.context; | ||
|
||
const smashSelectOptions = [ | ||
...INTERNAL_SMASH_SERVERS.map(({ name: label, id: value }) => ({ | ||
label, | ||
value, | ||
})), | ||
{ | ||
label: intl.formatMessage(messages.smashSelectCustomServer), | ||
value: SMASH_SERVER_TYPES.CUSTOM, | ||
}, | ||
]; | ||
|
||
return ( | ||
<div className={styles.component}> | ||
<Select | ||
label={intl.formatMessage(messages.smashSelectLabel)} | ||
value={smashServerType} | ||
options={smashSelectOptions} | ||
onChange={(smashServerType: SmashServerType) => { | ||
onSelectSmashServerType({ smashServerType }); | ||
}} | ||
skin={SelectSkin} | ||
className={styles.select} | ||
optionHeight={50} | ||
/> | ||
{smashServerType === SMASH_SERVER_TYPES.CUSTOM && ( | ||
<Input | ||
value={smashServerUrl || ''} | ||
label={intl.formatMessage(messages.smashURLSelectLabel)} | ||
placeholder={intl.formatMessage(messages.smashUrlSelectPlaceholder)} | ||
skin={InputSkin} | ||
onKeyPress={this.handleSubmitOnEnter} | ||
/> | ||
)} | ||
</div> | ||
); | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
source/renderer/app/components/settings/categories/StakePoolsSettings.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
.component { | ||
:global { | ||
.SimpleFormField_root:not(:first-child) { | ||
margin-top: 20px; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
source/renderer/app/containers/settings/categories/StakePoolsSettingsPage.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// @flow | ||
import React, { Component } from 'react'; | ||
import { inject, observer } from 'mobx-react'; | ||
import StakePoolsSettings from '../../../components/settings/categories/StakePoolsSettings'; | ||
import type { InjectedProps } from '../../../types/injectedPropsType'; | ||
|
||
@inject('stores', 'actions') | ||
@observer | ||
export default class StakePoolsSettingsPage extends Component<InjectedProps> { | ||
static defaultProps = { actions: null, stores: null }; | ||
|
||
render() { | ||
const { stores, actions } = this.props; | ||
const { smashServerType, smashServerUrl } = stores.staking; | ||
const { selectSmashServerType, selectSmashServerUrl } = actions.staking; | ||
// If `smashServerType` is null, waits for it to be set | ||
if (!smashServerType) return false; | ||
return ( | ||
<StakePoolsSettings | ||
smashServerType={smashServerType} | ||
smashServerUrl={smashServerUrl} | ||
onSelectSmashServerType={selectSmashServerType.trigger} | ||
onSelectSmashServerUrl={selectSmashServerUrl.trigger} | ||
/> | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
// @flow | ||
|
||
export type RedeemItnRewardsStep = 'configuration' | 'confirmation' | 'result'; | ||
export type SmashServerType = 'iohk' | 'cardano' | 'custom'; |