CreateImageWizard: add registration validation
If register now is selected, an activation key is required. If no activation key is entered the Next and Create buttons are disabled. Also, if the activation key is empty an error message will appear to prompt the user to enter an activation key. The subscription errors variable is removed in favor of declaring the error message directly in the registration step component. The validateSubscription function is removed in favor of validating the activation key field on change.
This commit is contained in:
parent
6d147c95fc
commit
f00cf08506
5 changed files with 54 additions and 53 deletions
|
|
@ -39,7 +39,6 @@ class CreateImageWizard extends Component {
|
|||
this.onClose = this.onClose.bind(this);
|
||||
this.validate = this.validate.bind(this);
|
||||
this.validateUploadAmazon = this.validateUploadAmazon.bind(this);
|
||||
this.validateSubscription = this.validateSubscription.bind(this);
|
||||
|
||||
this.state = {
|
||||
arch: 'x86_64',
|
||||
|
|
@ -83,13 +82,13 @@ class CreateImageWizard extends Component {
|
|||
uploadAWSErrors: {},
|
||||
uploadAzureErrors: {},
|
||||
uploadGoogleErrors: {},
|
||||
subscriptionErrors: {},
|
||||
packagesAvailableComponents: [],
|
||||
packagesSelectedComponents: [],
|
||||
packagesFilteredComponents: [],
|
||||
packagesSelectedNames: [],
|
||||
packagesSearchName: '',
|
||||
isSaveInProgress: false,
|
||||
isValidSubscription: true,
|
||||
onSaveError: null,
|
||||
};
|
||||
}
|
||||
|
|
@ -125,13 +124,6 @@ class CreateImageWizard extends Component {
|
|||
break;
|
||||
}
|
||||
});
|
||||
|
||||
/* subscription */
|
||||
if (this.state.subscribeNow) {
|
||||
this.validateSubscription();
|
||||
} else {
|
||||
this.setState({ subscriptionErrors: {}});
|
||||
}
|
||||
}
|
||||
|
||||
validateUploadAmazon() {
|
||||
|
|
@ -168,16 +160,6 @@ class CreateImageWizard extends Component {
|
|||
// TODO check oauth2 thing too here?
|
||||
}
|
||||
|
||||
validateSubscription() {
|
||||
let subscriptionErrors = {};
|
||||
if (!this.state.subscription['activation-key']) {
|
||||
subscriptionErrors['subscription-activation'] =
|
||||
{ label: 'Activation key', value: 'A value is required' };
|
||||
}
|
||||
|
||||
this.setState({ subscriptionErrors });
|
||||
}
|
||||
|
||||
setRelease(release) {
|
||||
this.setState({ release });
|
||||
}
|
||||
|
|
@ -233,11 +215,23 @@ class CreateImageWizard extends Component {
|
|||
}
|
||||
|
||||
setSubscribeNow(subscribeNow) {
|
||||
this.setState({ subscribeNow });
|
||||
// if subscribe now the subscription will be invalid, else the subscription is valid since none is required
|
||||
this.setState({
|
||||
subscription: {
|
||||
...this.state.subscription,
|
||||
'activation-key': null
|
||||
},
|
||||
subscribeNow,
|
||||
isValidSubscription: !subscribeNow
|
||||
});
|
||||
}
|
||||
|
||||
setSubscription(subscription) {
|
||||
this.setState({ subscription }, this.validate);
|
||||
if (subscription['activation-key']) {
|
||||
this.setState({ subscription, isValidSubscription: true });
|
||||
} else {
|
||||
this.setState({ subscription, isValidSubscription: false });
|
||||
}
|
||||
}
|
||||
|
||||
setPackagesSearchName(packagesSearchName) {
|
||||
|
|
@ -476,7 +470,7 @@ class CreateImageWizard extends Component {
|
|||
subscribeNow={ this.state.subscribeNow }
|
||||
setSubscription={ this.setSubscription }
|
||||
setSubscribeNow={ this.setSubscribeNow }
|
||||
errors={ this.state.subscriptionErrors } /> },
|
||||
isValidSubscription={ this.state.isValidSubscription } /> },
|
||||
{
|
||||
name: 'Packages',
|
||||
component: <WizardStepPackages
|
||||
|
|
@ -497,7 +491,7 @@ class CreateImageWizard extends Component {
|
|||
subscription={ this.state.subscription }
|
||||
subscribeNow={ this.state.subscribeNow }
|
||||
uploadAWSErrors={ this.state.uploadAWSErrors }
|
||||
subscriptionErrors={ this.state.subscriptionErrors } />,
|
||||
isValidSubscription={ this.state.isValidSubscription } />,
|
||||
nextButtonText: 'Create',
|
||||
}
|
||||
];
|
||||
|
|
@ -514,6 +508,7 @@ class CreateImageWizard extends Component {
|
|||
footer={ <ImageWizardFooter
|
||||
isValidUploadDestination={ isValidUploadDestination }
|
||||
isSaveInProgress={ this.state.isSaveInProgress }
|
||||
isValidSubscription={ this.state.isValidSubscription }
|
||||
error={ this.state.onSaveError } /> }
|
||||
isOpen />
|
||||
</React.Fragment>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue