Skip to content
Open
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
35 changes: 21 additions & 14 deletions ui/perfherder/alerts/NotesModal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,45 @@ export default class NotesModal extends React.Component {
constructor(props) {
super(props);
this.state = {
inputValue: this.props.alertSummary.notes,
inputValue: this.props.alertSummary.notes || '',
};
}

updateInput = (event) => {
this.setState({ inputValue: event.target.value });
};

handleSubmit = (event) => {
event.preventDefault();

const { updateAndClose } = this.props;
const { inputValue } = this.state;

updateAndClose(
event,
{
notes: inputValue.length ? inputValue : null,
},
'showNotesModal',
);
};

render() {
const { showModal, toggle, alertSummary, updateAndClose } = this.props;
const { showModal, toggle, alertSummary } = this.props;
const { inputValue } = this.state;

return (
<Modal show={showModal} onHide={toggle}>
<Modal.Header closeButton>
<Modal.Title>Alert Notes</Modal.Title>
</Modal.Header>
<Form>
<Form onSubmit={this.handleSubmit}>
<Modal.Body>
<Form.Group>
<Form.Label htmlFor="editableNotes">Add or edit notes</Form.Label>
<Form.Control
value={inputValue || ''}
id="editableNotes"
value={inputValue}
onChange={this.updateInput}
name="editableNotes"
as="textarea"
Expand All @@ -40,16 +56,7 @@ export default class NotesModal extends React.Component {
<Modal.Footer>
<Button
variant="secondary"
onClick={(event) =>
updateAndClose(
event,
{
notes: inputValue.length ? inputValue : null,
},
'showNotesModal',
)
}
disabled={inputValue === alertSummary.notes}
disabled={inputValue === (alertSummary.notes || '')}
type="submit"
>
Save
Expand Down