-
Notifications
You must be signed in to change notification settings - Fork 43
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 #897 from mzazrivec/add_new_options_for_migration_…
…throttling Add new options for migration throttling (cherry picked from commit 5cee58d) https://bugzilla.redhat.com/show_bug.cgi?id=1693746
- Loading branch information
Showing
5 changed files
with
188 additions
and
12 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,3 +14,8 @@ | |
min-width: 150px; | ||
text-align: right; | ||
} | ||
|
||
.postfix-label { | ||
background-color: #fafafa; | ||
border-left-width: 0px; | ||
} |
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
71 changes: 71 additions & 0 deletions
71
app/javascript/react/screens/App/common/forms/TextInputWithCheckbox.js
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,71 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { Form } from 'patternfly-react'; | ||
|
||
class TextInputWithCheckbox extends React.Component { | ||
constructor(props) { | ||
super(props); | ||
this.state = { | ||
inputEnabled: props.inputEnabledFunction(props.input.value) | ||
}; | ||
} | ||
|
||
render() { | ||
const { | ||
id, | ||
label, | ||
input: { value, onChange }, | ||
postfix | ||
} = this.props; | ||
|
||
const onCheckboxChange = event => this.setState({ inputEnabled: event.target.checked }); | ||
|
||
return ( | ||
<Form.FormGroup> | ||
<Form.ControlLabel className="col-md-4"> | ||
<div className="checkbox-inline pull-left"> | ||
<label> | ||
<input | ||
type="checkbox" | ||
name={`${id}_checkbox`} | ||
id={`${id}_checkbox`} | ||
defaultChecked={this.state.inputEnabled} | ||
onChange={event => onCheckboxChange(event)} | ||
/> | ||
{label} | ||
</label> | ||
</div> | ||
</Form.ControlLabel> | ||
<div className="col-md-2"> | ||
<div className="input-group"> | ||
<input | ||
type="text" | ||
className="form-control" | ||
name={id} | ||
id={id} | ||
defaultValue={value} | ||
readOnly={!this.state.inputEnabled} | ||
onChange={event => onChange(event.target.value)} | ||
/> | ||
<div className="input-group-addon postfix-label">{postfix}</div> | ||
</div> | ||
</div> | ||
</Form.FormGroup> | ||
); | ||
} | ||
} | ||
|
||
TextInputWithCheckbox.propTypes = { | ||
id: PropTypes.string.isRequired, | ||
input: PropTypes.shape({ | ||
value: PropTypes.oneOfType([PropTypes.number, PropTypes.string]), | ||
onChange: PropTypes.func | ||
}), | ||
label: PropTypes.string.isRequired, | ||
postfix: PropTypes.string, | ||
inputEnabledFunction: PropTypes.func.isRequired | ||
}; | ||
|
||
TextInputWithCheckbox.normalizeStringToInt = str => (str && parseInt(str.replace(/\D/g, ''), 10)) || 0; | ||
|
||
export default TextInputWithCheckbox; |