-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #756 from hubiinetwork/feature/1.1.0
1.1.0-beta.1
- Loading branch information
Showing
35 changed files
with
2,257 additions
and
198 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
import * as React from 'react'; | ||
import { Form, Icon } from 'antd'; | ||
import PropTypes from 'prop-types'; | ||
import { injectIntl } from 'react-intl'; | ||
import { | ||
Text, | ||
Wrapper, | ||
WrapperIcon, | ||
StyledButton, | ||
ParentDiv, | ||
} from './style'; | ||
import { ModalFormLabel, ModalFormInput, ModalFormItem } from '../ui/Modal'; | ||
/** | ||
* Modal component for editing a wallet. | ||
*/ | ||
|
||
export class EditWalletModal extends React.Component { | ||
constructor(props) { | ||
super(props); | ||
this.handleEdit = this.handleEdit.bind(this); | ||
} | ||
|
||
|
||
handleEdit(e) { | ||
const { onEdit } = this.props; | ||
e.preventDefault(); | ||
this.props.form.validateFields((err, value) => { | ||
if (!err) { | ||
onEdit({ name: value.name.trim() }); | ||
} | ||
}); | ||
} | ||
|
||
|
||
render() { | ||
const { getFieldDecorator } = this.props.form; | ||
const { intl } = this.props; | ||
const { formatMessage } = intl; | ||
return ( | ||
<Wrapper> | ||
<WrapperIcon> | ||
<Icon type="info-circle-o" /> | ||
<Text> | ||
{formatMessage({ id: 'edit_wallet' })} | ||
</Text> | ||
</WrapperIcon> | ||
<Form layout="vertical" onSubmit={this.handleEdit}> | ||
<ModalFormItem label={<ModalFormLabel>{formatMessage({ id: 'name' })}</ModalFormLabel>}> | ||
{getFieldDecorator('name', { | ||
rules: [ | ||
{ | ||
message: formatMessage({ id: 'enter_wallet_name' }), | ||
required: true, | ||
}, | ||
{ | ||
max: 25, | ||
message: formatMessage({ id: 'wallet_name_max25_error' }), | ||
}, | ||
], | ||
initialValue: this.props.initialName, | ||
})(<ModalFormInput placeholder="Wallet name" />)} | ||
</ModalFormItem> | ||
<ParentDiv> | ||
<StyledButton | ||
type="primary" | ||
htmlType="submit" | ||
id="button" | ||
> | ||
{formatMessage({ id: 'confirm' })} | ||
</StyledButton> | ||
<StyledButton | ||
type="default" | ||
onClick={this.props.onCancel} | ||
id="cancel" | ||
style={{ marginLeft: '2rem' }} | ||
> | ||
{formatMessage({ id: 'cancel' })} | ||
</StyledButton> | ||
</ParentDiv> | ||
</Form> | ||
</Wrapper> | ||
); | ||
} | ||
} | ||
|
||
EditWalletModal.defaultProps = { | ||
initialName: '', | ||
}; | ||
|
||
EditWalletModal.propTypes = { | ||
initialName: PropTypes.string, | ||
onEdit: PropTypes.func, | ||
onCancel: PropTypes.func, | ||
form: PropTypes.object, | ||
intl: PropTypes.object.isRequired, | ||
}; | ||
|
||
export default Form.create()(injectIntl(EditWalletModal)); | ||
|
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,44 @@ | ||
import styled from 'styled-components'; | ||
import Button from 'components/ui/Button'; | ||
|
||
export const WrapperIcon = styled.div` | ||
display: flex; | ||
color: ${({ theme }) => theme.palette.secondary1}; | ||
font-size: 80%; | ||
max-width: 70%; | ||
margin-top: 2.86rem; | ||
i { | ||
font-size: 1.71rem; | ||
} | ||
`; | ||
export const Text = styled.div` | ||
padding-left: 0.5rem; | ||
`; | ||
export const Wrapper = styled.div` | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
.ant-form-item-required:before { | ||
display: none; | ||
} | ||
.ant-form-vertical { | ||
display: flex; | ||
width: 70%; | ||
flex-direction: column; | ||
} | ||
.ant-form-vertical .ant-form-item { | ||
padding-bottom: 0rem; | ||
} | ||
.ant-form-item { | ||
margin-bottom: 0rem; | ||
} | ||
`; | ||
export const StyledButton = styled(Button)` | ||
min-width: 11.43rem; | ||
`; | ||
|
||
export const ParentDiv = styled.div` | ||
margin-top: 1.43rem; | ||
display: flex; | ||
justify-content: center; | ||
`; |
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
Oops, something went wrong.