Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DDW-173] - Button should be disabled when there is nothing to submit #1998

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
fefef5e
[DDW-173] - Button should be disabled when there is nothing to submit
DeeJayElly Apr 23, 2020
62ecc5e
[DDW-173] - Button should be disabled when there is nothing to submit…
DeeJayElly Apr 23, 2020
24bd1ab
[DDW-173] - Button should be disabled when there is nothing to submit…
DeeJayElly Apr 27, 2020
7c1106c
[DDW-173] - Button should be disabled when there is nothing to submit…
DeeJayElly Apr 27, 2020
83ccc17
Merge branch 'develop' into fix/ddw-173-button-should-be-disabled-whe…
DeeJayElly Apr 28, 2020
a5d9ce0
[DDW-173] - Button should be disabled when there is nothing to submit…
DeeJayElly Apr 28, 2020
0c70b99
[DDW-173] - Button should be disabled when there is nothing to submit…
DeeJayElly Apr 28, 2020
5b5cdb2
[DDW-173] - Button should be disabled when there is nothing to submit…
DeeJayElly Apr 28, 2020
620e1fb
[DDW-173] - Button should be disabled when there is nothing to submit…
DeeJayElly Apr 28, 2020
2778ab0
[DDW-173] - Button should be disabled when there is nothing to submit…
DeeJayElly Apr 28, 2020
707aaed
[DDW-173] - Button should be disabled when there is nothing to submit…
DeeJayElly Apr 28, 2020
4be49c7
[DDW-173] - Button should be disabled when there is nothing to submit…
DeeJayElly Apr 28, 2020
06be63b
Merge branch 'develop' into fix/ddw-173-button-should-be-disabled-whe…
DeeJayElly Apr 29, 2020
2f5361c
[DDW-173] - Button should be disabled when there is nothing to submit…
DeeJayElly Apr 30, 2020
0b17cc6
Merge branch 'develop' into fix/ddw-173-button-should-be-disabled-whe…
DeeJayElly Apr 30, 2020
2904a05
Merge branch 'develop' into fix/ddw-173-button-should-be-disabled-whe…
DeeJayElly May 4, 2020
763d893
[DDW-173] - Button should be disabled when there is nothing to submit…
DeeJayElly May 4, 2020
caa176b
[DDW-173] - Button should be disabled when there is nothing to submit…
DeeJayElly May 4, 2020
ac7aca6
[DDW-173] - Button should be disabled when there is nothing to submit…
DeeJayElly May 4, 2020
35f50d5
[DDW-173] - Button should be disabled when there is nothing to submit…
DeeJayElly May 4, 2020
8ddb6a8
Merge branch 'develop' into fix/ddw-173-button-should-be-disabled-whe…
DeeJayElly May 4, 2020
f0fb759
[DDW-173] - Button should be disabled when there is nothing to submit…
DeeJayElly May 4, 2020
3ef812d
Merge remote-tracking branch 'origin/fix/ddw-173-button-should-be-dis…
DeeJayElly May 4, 2020
3e52057
Merge branch 'develop' into fix/ddw-173-button-should-be-disabled-whe…
DeeJayElly May 4, 2020
cd43d86
[DDW-173] - Button should be disabled when there is nothing to submit…
DeeJayElly May 4, 2020
27351de
Merge remote-tracking branch 'origin/fix/ddw-173-button-should-be-dis…
DeeJayElly May 4, 2020
78eba67
[DDW-173] - Button should be disabled when there is nothing to submit…
DeeJayElly May 4, 2020
8feb868
[DDW-173] - Button should be disabled when there is nothing to submit…
DeeJayElly May 4, 2020
6ac8133
[DDW-173] - Button should be disabled when there is nothing to submit…
DeeJayElly May 5, 2020
388e3cc
[DDW-173] - Button should be disabled when there is nothing to submit…
DeeJayElly May 6, 2020
b684267
[DDW-173] - Button should be disabled when there is nothing to submit…
DeeJayElly May 6, 2020
bf4515f
[DDW-173] - Button should be disabled when there is nothing to submit…
DeeJayElly May 6, 2020
2711b12
[DDW-173] - Button should be disabled when there is nothing to submit…
DeeJayElly May 6, 2020
cc3714e
[DDW-173] - Button should be disabled when there is nothing to submit…
DeeJayElly May 6, 2020
630abf9
Merge branch 'develop' into fix/ddw-173-button-should-be-disabled-whe…
DeeJayElly May 7, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Changelog

### Fixes

- Disabled button on forms when there is nothing to submit ([PR 1998](https://github.com/input-output-hk/daedalus/pull/1998))
- Fixed system locale detection ([PR 2009](https://github.com/input-output-hk/daedalus/pull/2009))

## 1.1.0-FC1
Expand Down
20 changes: 12 additions & 8 deletions source/renderer/app/components/wallet/WalletCreateDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,11 @@ export default class WalletCreateDialog extends Component<Props, State> {
validators: [
({ field, form }) => {
const repeatPasswordField = form.$('repeatPassword');
if (repeatPasswordField.value.length > 0) {
repeatPasswordField.validate({ showErrors: true });
}
const isRepeatPasswordFieldSet =
repeatPasswordField.value.length > 0;
repeatPasswordField.validate({
showErrors: isRepeatPasswordFieldSet,
});
return [
isValidSpendingPassword(field.value),
this.context.intl.formatMessage(
Expand All @@ -164,7 +166,6 @@ export default class WalletCreateDialog extends Component<Props, State> {
validators: [
({ field, form }) => {
const spendingPassword = form.$('spendingPassword').value;
if (spendingPassword.length === 0) return [true];
return [
isValidRepeatPassword(spendingPassword, field.value),
this.context.intl.formatMessage(
Expand Down Expand Up @@ -211,9 +212,16 @@ export default class WalletCreateDialog extends Component<Props, State> {
const { isSubmitting } = this.state;
const dialogClasses = classnames([styles.component, 'WalletCreateDialog']);

const walletNameField = form.$('walletName');
const spendingPasswordField = form.$('spendingPassword');
const repeatedPasswordField = form.$('repeatPassword');

const canSubmit = !isSubmitting && form.isValid;

const actions = [
{
className: isSubmitting ? styles.isSubmitting : null,
disabled: !canSubmit,
label: this.context.intl.formatMessage(
isIncentivizedTestnet
? messages.createPersonalWalletItn
Expand All @@ -224,10 +232,6 @@ export default class WalletCreateDialog extends Component<Props, State> {
},
];

const walletNameField = form.$('walletName');
const spendingPasswordField = form.$('spendingPassword');
const repeatedPasswordField = form.$('repeatPassword');

return (
<Dialog
className={dialogClasses}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,9 @@ export default class WalletReceiveRandom extends Component<Props, State> {
]);

const passwordField = form.$('spendingPassword');

const canSubmit = !isSubmitting && passwordField.value;

const generateAddressForm = (
<div className={generateAddressWrapperClasses}>
{walletHasPassword && (
Expand All @@ -217,6 +220,7 @@ export default class WalletReceiveRandom extends Component<Props, State> {

<Button
className={generateAddressButtonClasses}
disabled={!canSubmit}
label={intl.formatMessage(messages.generateNewAddressButtonLabel)}
skin={ButtonSkin}
onClick={this.submit}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,20 @@ export default class ChangeSpendingPasswordDialog extends Component<Props> {
messages.currentPasswordFieldPlaceholder
),
value: '',
validators: [
({ form }) => {
if (this.props.isSpendingPasswordSet) {
const currentPasswordField = form.$('currentPassword');
return [
currentPasswordField.value.length > 0,
this.context.intl.formatMessage(
globalMessages.invalidSpendingPassword
),
];
}
return [true];
},
],
},
spendingPassword: {
type: 'password',
Expand All @@ -127,9 +141,11 @@ export default class ChangeSpendingPasswordDialog extends Component<Props> {
validators: [
({ field, form }) => {
const repeatPasswordField = form.$('repeatPassword');
if (repeatPasswordField.value.length > 0) {
repeatPasswordField.validate({ showErrors: true });
}
const isRepeatPasswordFieldSet =
repeatPasswordField.value.length > 0;
repeatPasswordField.validate({
showErrors: isRepeatPasswordFieldSet,
});
return [
isValidSpendingPassword(field.value),
this.context.intl.formatMessage(
Expand All @@ -149,7 +165,6 @@ export default class ChangeSpendingPasswordDialog extends Component<Props> {
validators: [
({ field, form }) => {
const spendingPassword = form.$('spendingPassword').value;
if (spendingPassword.length === 0) return [true];
return [
isValidRepeatPassword(spendingPassword, field.value),
this.context.intl.formatMessage(
Expand All @@ -165,6 +180,7 @@ export default class ChangeSpendingPasswordDialog extends Component<Props> {
options: {
validateOnChange: true,
validationDebounceWait: FORM_VALIDATION_DEBOUNCE_WAIT,
showErrorsOnClear: true,
nikolaglumac marked this conversation as resolved.
Show resolved Hide resolved
},
}
);
Expand Down Expand Up @@ -214,19 +230,25 @@ export default class ChangeSpendingPasswordDialog extends Component<Props> {

const newPasswordClasses = classnames(['newPassword', styles.newPassword]);

const currentPasswordField = form.$('currentPassword');
const newPasswordField = form.$('spendingPassword');
const repeatedPasswordField = form.$('repeatPassword');

const canSubmit = !isSubmitting && form.isValid;

const currentPasswordError =
canSubmit && error && error.code === 'wrong_encryption_passphrase';
nikolaglumac marked this conversation as resolved.
Show resolved Hide resolved

const actions = [
{
className: confirmButtonClasses,
disabled: !canSubmit,
label: intl.formatMessage(globalMessages.save),
onClick: this.submit,
primary: true,
className: confirmButtonClasses,
},
];

const currentPasswordField = form.$('currentPassword');
const newPasswordField = form.$('spendingPassword');
const repeatedPasswordField = form.$('repeatPassword');

return (
<Dialog
title={intl.formatMessage(
Expand Down Expand Up @@ -255,7 +277,7 @@ export default class ChangeSpendingPasswordDialog extends Component<Props> {
this.handleDataChange('currentPasswordValue', value)
}
{...currentPasswordField.bind()}
error={currentPasswordField.error}
error={currentPasswordField.error || currentPasswordError}
nikolaglumac marked this conversation as resolved.
Show resolved Hide resolved
skin={InputSkin}
/>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,11 @@ export default class ConfigurationDialog extends Component<Props> {
validators: [
({ field, form }) => {
const repeatPasswordField = form.$('repeatPassword');
if (repeatPasswordField.value.length > 0) {
repeatPasswordField.validate({ showErrors: true });
}
const isRepeatPasswordFieldSet =
repeatPasswordField.value.length > 0;
repeatPasswordField.validate({
showErrors: isRepeatPasswordFieldSet,
});
return [
isValidSpendingPassword(field.value),
this.context.intl.formatMessage(
Expand All @@ -153,7 +155,6 @@ export default class ConfigurationDialog extends Component<Props> {
validators: [
({ field, form }) => {
const spendingPassword = form.$('spendingPassword').value;
if (spendingPassword.length === 0) return [true];
return [
isValidRepeatPassword(spendingPassword, field.value),
this.context.intl.formatMessage(
Expand Down Expand Up @@ -221,12 +222,15 @@ export default class ConfigurationDialog extends Component<Props> {
'repeatPassword',
]);

const canSubmit = !isSubmitting && form.isValid;

return (
<WalletRestoreDialog
stepNumber={2}
actions={[
{
className: isSubmitting ? styles.isSubmitting : null,
disabled: !canSubmit,
primary: true,
label: intl.formatMessage(messages.continueButtonLabel),
onClick: this.submit,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,19 @@ export default class MnemonicsDialog extends Component<Props> {
expectedWordCount,
} = this.props;
const recoveryPhraseField = this.form.$('recoveryPhrase');

const wordCount = mnemonics.length;
const isPhraseComplete = Array.isArray(expectedWordCount)
? expectedWordCount.includes(wordCount)
: wordCount === expectedWordCount;

return (
<WalletRestoreDialog
stepNumber={1}
actions={[
{
primary: true,
disabled: !isPhraseComplete,
label: intl.formatMessage(messages.continueButtonLabel),
onClick: this.submit,
},
Expand Down