Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Misc. small UI fixes #4657

Merged
merged 20 commits into from
Feb 24, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions js/src/modals/AddAddress/addAddress.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,10 @@ export default class AddAddress extends Component {
renderDialogActions () {
const { hasError } = this.store;

return ([
return [
<Button
icon={ <CancelIcon /> }
key='cancel'
label={
<FormattedMessage
id='addAddress.button.close'
Expand All @@ -80,6 +81,7 @@ export default class AddAddress extends Component {
<Button
disabled={ hasError }
icon={ <AddIcon /> }
key='save'
label={
<FormattedMessage
id='addAddress.button.add'
Expand All @@ -89,7 +91,7 @@ export default class AddAddress extends Component {
onClick={ this.onAdd }
ref='addButton'
/>
]);
];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Buttons miss the key prop. And while we're at it, we might want to get rid of every Cancel button for modals that use the Portal. There is already this big X button to cancel/close the modal/Portal.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not trying to fix the all button layouts here. Wait for modal updates round 2, 3, etc. (Need to work through one-by-one to see what works and what doesn't - help is appreciated there, it is a lot of ground to cover to say the least.)

Key is valuable though.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ummm... I actually fixed this in my modals update branch (along with a ton of others, we didn't seem to be as vigilant as we should have), however re-doing it here.

}

renderFields () {
Expand All @@ -99,6 +101,7 @@ export default class AddAddress extends Component {
<Form>
<InputAddress
allowCopy={ false }
autoFocus
disabled={ !!this.props.address }
error={ addressError }
hint={
Expand Down
1 change: 1 addition & 0 deletions js/src/modals/AddContract/addContract.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ class AddContract extends Component {
return (
<Form>
<InputAddress
autoFocus
error={ addressError }
hint={
<FormattedMessage
Expand Down
1 change: 1 addition & 0 deletions js/src/modals/CreateAccount/NewAccount/newAccount.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export default class CreateAccount extends Component {
return (
<Form>
<Input
autoFocus
error={ nameError }
hint={
<FormattedMessage
Expand Down
1 change: 1 addition & 0 deletions js/src/modals/CreateAccount/NewImport/newImport.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export default class NewImport extends Component {
return (
<Form>
<Input
autoFocus
error={ nameError }
hint={
<FormattedMessage
Expand Down
1 change: 1 addition & 0 deletions js/src/modals/CreateAccount/RawKey/rawKey.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export default class RawKey extends Component {
return (
<Form>
<Input
autoFocus
error={ rawKeyError }
hint={
<FormattedMessage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export default class RecoveryPhrase extends Component {
return (
<Form>
<Input
autoFocus
hint={
<FormattedMessage
id='createAccount.recoveryPhrase.phrase.hint'
Expand Down
1 change: 1 addition & 0 deletions js/src/modals/CreateAccount/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ export default class Store {
transaction(() => {
this.password = '';
this.passwordRepeat = '';
this.phrase = '';
this.nameError = null;
this.rawKeyError = null;
this.walletFileError = null;
Expand Down
40 changes: 21 additions & 19 deletions js/src/modals/CreateWallet/WalletDetails/walletDetails.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export default class WalletDetails extends Component {
return (
<Form>
<InputAddress
autoFocus
hint={
<FormattedMessage
id='createWallet.details.address.hint'
Expand Down Expand Up @@ -110,26 +111,8 @@ export default class WalletDetails extends Component {

return (
<Form>
<AddressSelect
accounts={ _accounts }
error={ errors.account }
hint={
<FormattedMessage
id='createWallet.details.ownerMulti.hint'
defaultMessage='the owner account for this contract'
/>
}
label={
<FormattedMessage
id='createWallet.details.ownerMulti.label'
defaultMessage='from account (contract owner)'
/>
}
value={ wallet.account }
onChange={ this.onAccoutChange }
/>

<Input
autoFocus
error={ errors.name }
hint={
<FormattedMessage
Expand Down Expand Up @@ -164,6 +147,25 @@ export default class WalletDetails extends Component {
onChange={ this.onDescriptionChange }
/>

<AddressSelect
accounts={ _accounts }
error={ errors.account }
hint={
<FormattedMessage
id='createWallet.details.ownerMulti.hint'
defaultMessage='the owner account for this contract'
/>
}
label={
<FormattedMessage
id='createWallet.details.ownerMulti.label'
defaultMessage='from account (contract owner)'
/>
}
value={ wallet.account }
onChange={ this.onAccoutChange }
/>

<TypedInput
accounts={ accounts }
label={
Expand Down
2 changes: 2 additions & 0 deletions js/src/modals/DeleteAccount/deleteAccount.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ class DeleteAccount extends Component {
</div>
<div className={ styles.password }>
<Input
autoFocus
hint={
<FormattedMessage
id='deleteAccount.password.hint'
Expand All @@ -98,6 +99,7 @@ class DeleteAccount extends Component {
/>
}
onChange={ this.onChangePassword }
onDefaultAction={ this.onDeleteConfirmed }
type='password'
value={ password }
/>
Expand Down
41 changes: 21 additions & 20 deletions js/src/modals/DeployContract/DetailsStep/detailsStep.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,27 +92,8 @@ export default class DetailsStep extends Component {

return (
<Form>
<AddressSelect
accounts={ accounts }
balances={ balances }
error={ fromAddressError }
hint={
<FormattedMessage
id='deployContract.details.address.hint'
defaultMessage='the owner account for this contract'
/>
}
label={
<FormattedMessage
id='deployContract.details.address.label'
defaultMessage='from account (contract owner)'
/>
}
onChange={ this.onFromAddressChange }
value={ fromAddress }
/>

<Input
autoFocus
error={ nameError }
hint={
<FormattedMessage
Expand Down Expand Up @@ -148,6 +129,26 @@ export default class DetailsStep extends Component {
value={ description }
/>

<AddressSelect
accounts={ accounts }
balances={ balances }
error={ fromAddressError }
hint={
<FormattedMessage
id='deployContract.details.address.hint'
defaultMessage='the owner account for this contract'
/>
}
label={
<FormattedMessage
id='deployContract.details.address.label'
defaultMessage='from account (contract owner)'
/>
}
onChange={ this.onFromAddressChange }
value={ fromAddress }
/>

{ this.renderContractSelect() }

<Input
Expand Down
1 change: 1 addition & 0 deletions js/src/modals/EditMeta/editMeta.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ class EditMeta extends Component {
>
<Form>
<Input
autoFocus
error={ nameError }
label={
<FormattedMessage
Expand Down
4 changes: 4 additions & 0 deletions js/src/modals/VaultUnlock/vaultUnlock.css
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
/* along with Parity. If not, see <http://www.gnu.org/licenses/>.
*/

.form {
margin-top: 0;
}

.passwordHint {
color: rgba(255, 255, 255, 0.5);
font-size: 0.75em;
Expand Down
49 changes: 26 additions & 23 deletions js/src/modals/VaultUnlock/vaultUnlock.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';

import { newError } from '~/redux/actions';
import { ConfirmDialog, Input, VaultCard } from '~/ui';
import { ConfirmDialog, Form, Input, VaultCard } from '~/ui';

import styles from './vaultUnlock.css';

Expand Down Expand Up @@ -64,28 +64,31 @@ class VaultUnlock extends Component {
withBorder
vault={ vault }
/>
<Input
hint={
<FormattedMessage
id='vaults.confirmOpen.password.hint'
defaultMessage='the password specified when creating the vault'
/>
}
label={
<FormattedMessage
id='vaults.confirmOpen.password.label'
defaultMessage='vault password'
/>
}
onChange={ this.onEditPassword }
onSubmit={ this.onExecute }
type='password'
value={ vaultPassword }
/>
<div className={ styles.passwordHint }>
{ vault.meta.passwordHint }
</div>
<br />
<Form className={ styles.form }>
<Input
autoFocus
hint={
<FormattedMessage
id='vaults.confirmOpen.password.hint'
defaultMessage='the password specified when creating the vault'
/>
}
label={
<FormattedMessage
id='vaults.confirmOpen.password.label'
defaultMessage='vault password'
/>
}
onChange={ this.onEditPassword }
onDefaultAction={ this.onExecute }
type='password'
value={ vaultPassword }
/>
<div className={ styles.passwordHint }>
{ vault.meta.passwordHint }
</div>
<br />
</Form>
</ConfirmDialog>
);
}
Expand Down
3 changes: 2 additions & 1 deletion js/src/modals/Verification/GatherData/gatherData.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,14 +232,15 @@ export default class GatherData extends Component {
renderFields () {
const { accountIsVerified, fields } = this.props;

const rendered = fields.map((field) => {
const rendered = fields.map((field, index) => {
const onChange = (_, v) => {
field.onChange(v);
};
const onSubmit = field.onChange;

return (
<Input
autoFocus={ index === 0 }
className={ styles.field }
key={ field.key }
label={ field.label }
Expand Down
1 change: 1 addition & 0 deletions js/src/modals/Verification/QueryCode/queryCode.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export default class QueryCode extends Component {
<Form>
<p>The verification code has been sent to { receiver }.</p>
<Input
autoFocus
label={
<FormattedMessage
id='verification.code.label'
Expand Down
1 change: 1 addition & 0 deletions js/src/modals/WalletSettings/walletSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ class WalletSettings extends Component {
</p>

<Input
autoFocus
hint='[ ... ]'
label={
<FormattedMessage
Expand Down
15 changes: 12 additions & 3 deletions js/src/ui/Form/Input/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export default class Input extends Component {
onBlur: PropTypes.func,
onChange: PropTypes.func,
onClick: PropTypes.func,
onDefaultAction: PropTypes.func,
onFocus: PropTypes.func,
onKeyDown: PropTypes.func,
onSubmit: PropTypes.func,
Expand Down Expand Up @@ -230,17 +231,25 @@ export default class Input extends Component {
const { value } = event.target;

if (event.which === 13) {
this.onSubmit(value);
this.onSubmit(value, true);
} else if (event.which === 27) {
// TODO ESC, revert to original
}

this.props.onKeyDown && this.props.onKeyDown(event);
}

onSubmit = (value) => {
onSubmit = (value, performDefault) => {
const { onDefaultAction, onSubmit } = this.props;

this.setValue(value, () => {
this.props.onSubmit && this.props.onSubmit(value);
if (onSubmit) {
onSubmit(value);
}

if (performDefault && onDefaultAction) {
onDefaultAction();
}
});
}

Expand Down
4 changes: 3 additions & 1 deletion js/src/ui/Form/InputAddress/inputAddress.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class InputAddress extends Component {
static propTypes = {
accountsInfo: PropTypes.object,
allowCopy: PropTypes.bool,
autoFocus: PropTypes.bool,
className: PropTypes.string,
disabled: PropTypes.bool,
error: PropTypes.string,
Expand All @@ -56,7 +57,7 @@ class InputAddress extends Component {
};

render () {
const { accountsInfo, allowCopy, className, disabled, error, focused, hint } = this.props;
const { accountsInfo, allowCopy, autoFocus, className, disabled, error, focused, hint } = this.props;
const { hideUnderline, label, onClick, onFocus, readOnly, small } = this.props;
const { tabIndex, text, tokens, value } = this.props;
const account = value && (accountsInfo[value] || tokens[value]);
Expand Down Expand Up @@ -85,6 +86,7 @@ class InputAddress extends Component {
<div className={ containerClasses.join(' ') }>
<Input
allowCopy={ allowCopy && ((disabled || readOnly) ? value : false) }
autoFocus={ autoFocus }
className={ classes.join(' ') }
disabled={ disabled }
error={ error }
Expand Down
Loading