|
| 1 | +import React from 'react'; |
| 2 | +import PropTypes from 'prop-types'; |
| 3 | +import { connect } from 'react-redux'; |
| 4 | +import { |
| 5 | + Button, |
| 6 | + Modal, |
| 7 | + ModalHeader, |
| 8 | + ModalBody, |
| 9 | + ModalFooter, |
| 10 | + Input, |
| 11 | + Label, |
| 12 | +} from 'reactstrap'; |
| 13 | + |
| 14 | +import { parseSummary } from '../helpers/bug'; |
| 15 | +import { notify } from '../job-view/redux/stores/notifications'; |
| 16 | + |
| 17 | +export class InternalIssueFilerClass extends React.Component { |
| 18 | + constructor(props) { |
| 19 | + super(props); |
| 20 | + |
| 21 | + const { suggestion, jobGroupName } = props; |
| 22 | + |
| 23 | + const parsedSummary = parseSummary(suggestion); |
| 24 | + let summaryString = parsedSummary[0].join(' | '); |
| 25 | + if (jobGroupName.toLowerCase().includes('reftest')) { |
| 26 | + const re = /layout\/reftests\//gi; |
| 27 | + summaryString = summaryString.replace(re, ''); |
| 28 | + } |
| 29 | + |
| 30 | + this.state = { |
| 31 | + summary: `Intermittent ${summaryString}`, |
| 32 | + }; |
| 33 | + } |
| 34 | + |
| 35 | + submitInternalIssue = async () => { |
| 36 | + const { summary } = this.state; |
| 37 | + const { notify } = this.props; |
| 38 | + |
| 39 | + notify(summary, 'danger'); |
| 40 | + }; |
| 41 | + |
| 42 | + render() { |
| 43 | + const { isOpen, toggle } = this.props; |
| 44 | + const { summary } = this.state; |
| 45 | + |
| 46 | + return ( |
| 47 | + <div> |
| 48 | + <Modal isOpen={isOpen} toggle={toggle} size="lg"> |
| 49 | + <ModalHeader toggle={toggle}> |
| 50 | + Intermittent Internal Issue Filer |
| 51 | + </ModalHeader> |
| 52 | + <ModalBody> |
| 53 | + <form className="d-flex flex-column"> |
| 54 | + <Label for="summary">Summary:</Label> |
| 55 | + <div className="d-flex"> |
| 56 | + <Input |
| 57 | + id="summary" |
| 58 | + className="flex-grow-1" |
| 59 | + type="text" |
| 60 | + placeholder="Intermittent..." |
| 61 | + pattern=".{0,255}" |
| 62 | + default={summary} |
| 63 | + /> |
| 64 | + </div> |
| 65 | + </form> |
| 66 | + </ModalBody> |
| 67 | + <ModalFooter> |
| 68 | + <Button color="secondary" onClick={this.submitFiler}> |
| 69 | + Submit Internal Issue |
| 70 | + </Button>{' '} |
| 71 | + <Button color="secondary" onClick={toggle}> |
| 72 | + Cancel |
| 73 | + </Button> |
| 74 | + </ModalFooter> |
| 75 | + </Modal> |
| 76 | + </div> |
| 77 | + ); |
| 78 | + } |
| 79 | +} |
| 80 | + |
| 81 | +InternalIssueFilerClass.propTypes = { |
| 82 | + isOpen: PropTypes.bool.isRequired, |
| 83 | + toggle: PropTypes.func.isRequired, |
| 84 | + suggestion: PropTypes.shape({}).isRequired, |
| 85 | + jobGroupName: PropTypes.string.isRequired, |
| 86 | + notify: PropTypes.func.isRequired, |
| 87 | +}; |
| 88 | + |
| 89 | +export default connect(null, { notify })(InternalIssueFilerClass); |
0 commit comments