Refactor *DriverFields components
Reduce code duplication between PXEAndSSHDriverFields and
PXEAndSSHDriverFields by introducing a base component for them.
Change-Id: Idede394f7b6d5eeb1c49e9c2b0b8677f9c78c60c
(cherry picked from commit 84ea9df15d
)
This commit is contained in:
parent
11b7e072be
commit
3634cdb420
|
@ -0,0 +1,49 @@
|
|||
import ImmutablePropTypes from 'react-immutable-proptypes';
|
||||
import React from 'react';
|
||||
|
||||
import HorizontalInput from '../../ui/forms/HorizontalInput';
|
||||
import HorizontalTextarea from '../../ui/forms/HorizontalTextarea';
|
||||
|
||||
export default class DriverFields extends React.Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.ipValidator = {
|
||||
matchRegexp: new RegExp('^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9]' +
|
||||
'[0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$')
|
||||
};
|
||||
this.ipValidatorMessage = 'Please enter a valid IPv4 Address';
|
||||
|
||||
}
|
||||
render() {
|
||||
return (
|
||||
<div>
|
||||
<HorizontalInput name="pm_addr"
|
||||
title={this.props.addr_title}
|
||||
inputColumnClasses="col-sm-7"
|
||||
labelColumnClasses="col-sm-5"
|
||||
value={this.props.node.pm_addr}
|
||||
validations={this.ipValidator}
|
||||
validationError={this.ipValidatorMessage}
|
||||
required />
|
||||
<HorizontalInput name="pm_user"
|
||||
title={this.props.user_title}
|
||||
inputColumnClasses="col-sm-7"
|
||||
labelColumnClasses="col-sm-5"
|
||||
value={this.props.node.pm_user}
|
||||
required />
|
||||
<HorizontalTextarea name="pm_password"
|
||||
title={this.props.pwd_title}
|
||||
inputColumnClasses="col-sm-7"
|
||||
labelColumnClasses="col-sm-5"
|
||||
value={this.props.node.pm_password}
|
||||
required />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
DriverFields.propTypes = {
|
||||
addr_title: React.PropTypes.string.isRequired,
|
||||
node: ImmutablePropTypes.record.isRequired,
|
||||
pwd_title: React.PropTypes.string.isRequired,
|
||||
user_title: React.PropTypes.string.isRequired
|
||||
};
|
|
@ -1,46 +1,14 @@
|
|||
import ImmutablePropTypes from 'react-immutable-proptypes';
|
||||
import React from 'react';
|
||||
|
||||
import HorizontalInput from '../../ui/forms/HorizontalInput';
|
||||
import HorizontalTextarea from '../../ui/forms/HorizontalTextarea';
|
||||
import DriverFields from './DriverFields';
|
||||
|
||||
export default class PXEAndIPMIToolDriverFields extends React.Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.ipValidator = {
|
||||
matchRegexp: new RegExp('^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9]' +
|
||||
'[0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$')
|
||||
};
|
||||
this.ipValidatorMessage = 'Please enter a valid IPv4 Address';
|
||||
|
||||
}
|
||||
export default class PXEAndSSHDriverFields extends DriverFields {
|
||||
render() {
|
||||
return (
|
||||
<div>
|
||||
<HorizontalInput name="pm_addr"
|
||||
title="IPMI IP Address"
|
||||
inputColumnClasses="col-sm-7"
|
||||
labelColumnClasses="col-sm-5"
|
||||
value={this.props.node.pm_addr}
|
||||
validations={this.ipValidator}
|
||||
validationError={this.ipValidatorMessage}
|
||||
required />
|
||||
<HorizontalInput name="pm_user"
|
||||
title="IPMI Username"
|
||||
inputColumnClasses="col-sm-7"
|
||||
labelColumnClasses="col-sm-5"
|
||||
value={this.props.node.pm_user}
|
||||
required />
|
||||
<HorizontalTextarea name="pm_password"
|
||||
title="IPMI Password"
|
||||
inputColumnClasses="col-sm-7"
|
||||
labelColumnClasses="col-sm-5"
|
||||
value={this.props.node.pm_password}
|
||||
required />
|
||||
</div>
|
||||
<DriverFields {...this.props}
|
||||
addr_title="IPMI IP Address"
|
||||
user_title="IPMI Username"
|
||||
pwd_title="IPMI Password" />
|
||||
);
|
||||
}
|
||||
}
|
||||
PXEAndIPMIToolDriverFields.propTypes = {
|
||||
node: ImmutablePropTypes.record.isRequired
|
||||
};
|
||||
|
|
|
@ -1,46 +1,14 @@
|
|||
import ImmutablePropTypes from 'react-immutable-proptypes';
|
||||
import React from 'react';
|
||||
|
||||
import HorizontalInput from '../../ui/forms/HorizontalInput';
|
||||
import HorizontalTextarea from '../../ui/forms/HorizontalTextarea';
|
||||
import DriverFields from './DriverFields';
|
||||
|
||||
export default class PXEAndSSHDriverFields extends React.Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.ipValidator = {
|
||||
matchRegexp: new RegExp('^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9]' +
|
||||
'[0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$')
|
||||
};
|
||||
this.ipValidatorMessage = 'Please enter a valid IPv4 Address';
|
||||
|
||||
}
|
||||
export default class PXEAndSSHDriverFields extends DriverFields {
|
||||
render() {
|
||||
return (
|
||||
<div>
|
||||
<HorizontalInput name="pm_addr"
|
||||
title="SSH IP Address"
|
||||
inputColumnClasses="col-sm-7"
|
||||
labelColumnClasses="col-sm-5"
|
||||
value={this.props.node.pm_addr}
|
||||
validations={this.ipValidator}
|
||||
validationError={this.ipValidatorMessage}
|
||||
required />
|
||||
<HorizontalInput name="pm_user"
|
||||
title="SSH User"
|
||||
inputColumnClasses="col-sm-7"
|
||||
labelColumnClasses="col-sm-5"
|
||||
value={this.props.node.pm_user}
|
||||
required />
|
||||
<HorizontalTextarea name="pm_password"
|
||||
title="SSH Key"
|
||||
inputColumnClasses="col-sm-7"
|
||||
labelColumnClasses="col-sm-5"
|
||||
value={this.props.node.pm_password}
|
||||
required />
|
||||
</div>
|
||||
<DriverFields {...this.props}
|
||||
addr_title="SSH IP Address"
|
||||
user_title="SSH User"
|
||||
pwd_title="SSH Key" />
|
||||
);
|
||||
}
|
||||
}
|
||||
PXEAndSSHDriverFields.propTypes = {
|
||||
node: ImmutablePropTypes.record.isRequired
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue