-
Notifications
You must be signed in to change notification settings - Fork 11
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 #132 from giranm/task/limit-incidents-queried
[Change Request] Limit incidents returned from large query
- Loading branch information
Showing
23 changed files
with
836 additions
and
94 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
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
79 changes: 79 additions & 0 deletions
79
src/components/ConfirmQueryModal/ConfirmQueryModalComponent.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,79 @@ | ||
import { | ||
connect, | ||
} from 'react-redux'; | ||
|
||
import { | ||
Modal, Button, | ||
} from 'react-bootstrap'; | ||
|
||
import { | ||
toggleDisplayConfirmQueryModal as toggleDisplayConfirmQueryModalConnected, | ||
confirmIncidentQuery as confirmIncidentQueryConnected, | ||
} from 'redux/query_settings/actions'; | ||
|
||
import { | ||
MAX_INCIDENTS_LIMIT, | ||
} from 'config/constants'; | ||
|
||
const ConfirmQueryModalComponent = ({ | ||
querySettings, | ||
toggleDisplayConfirmQueryModal, | ||
confirmIncidentQuery, | ||
}) => { | ||
const { | ||
displayConfirmQueryModal, totalIncidentsFromQuery, | ||
} = querySettings; | ||
|
||
const handleCancel = () => { | ||
confirmIncidentQuery(false); | ||
toggleDisplayConfirmQueryModal(); | ||
}; | ||
|
||
return ( | ||
<div className="confirm-query-modal-ctr"> | ||
<Modal show={displayConfirmQueryModal} onHide={handleCancel}> | ||
<Modal.Header closeButton> | ||
<Modal.Title>Max Incidents Limit Reached</Modal.Title> | ||
</Modal.Header> | ||
<Modal.Body> | ||
Current query parameters match | ||
{totalIncidentsFromQuery} | ||
incidents. | ||
<br /> | ||
Only the first | ||
{MAX_INCIDENTS_LIMIT} | ||
incidents will be retrieved. | ||
<br /> | ||
<br /> | ||
Continue? | ||
</Modal.Body> | ||
<Modal.Footer> | ||
<Button | ||
id="retrieve-incident-query-button" | ||
variant="primary" | ||
onClick={() => { | ||
confirmIncidentQuery(true); | ||
toggleDisplayConfirmQueryModal(); | ||
}} | ||
> | ||
Retrieve Incidents | ||
</Button> | ||
<Button id="cancel-incident-query-button" variant="danger" onClick={handleCancel}> | ||
Cancel | ||
</Button> | ||
</Modal.Footer> | ||
</Modal> | ||
</div> | ||
); | ||
}; | ||
|
||
const mapStateToProps = (state) => ({ | ||
querySettings: state.querySettings, | ||
}); | ||
|
||
const mapDispatchToProps = (dispatch) => ({ | ||
toggleDisplayConfirmQueryModal: () => dispatch(toggleDisplayConfirmQueryModalConnected()), | ||
confirmIncidentQuery: (confirm) => dispatch(confirmIncidentQueryConnected(confirm)), | ||
}); | ||
|
||
export default connect(mapStateToProps, mapDispatchToProps)(ConfirmQueryModalComponent); |
39 changes: 39 additions & 0 deletions
39
src/components/ConfirmQueryModal/ConfirmQueryModalComponent.test.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,39 @@ | ||
import { | ||
mockStore, componentWrapper, | ||
} from 'mocks/store.test'; | ||
|
||
import { | ||
MAX_INCIDENTS_LIMIT, | ||
} from 'config/constants'; | ||
|
||
import { | ||
generateRandomInteger, | ||
} from 'util/helpers'; | ||
|
||
import ConfirmQueryModalComponent from './ConfirmQueryModalComponent'; | ||
|
||
describe('ConfirmQueryModalComponent', () => { | ||
it('should render modal noting max incident limit has been reached', () => { | ||
const totalIncidentsFromQuery = generateRandomInteger( | ||
MAX_INCIDENTS_LIMIT + 1, | ||
MAX_INCIDENTS_LIMIT * 2, | ||
); | ||
const store = mockStore({ | ||
querySettings: { | ||
displayConfirmQueryModal: true, | ||
totalIncidentsFromQuery, | ||
}, | ||
}); | ||
|
||
const wrapper = componentWrapper(store, ConfirmQueryModalComponent); | ||
expect(wrapper.find('.modal-title').at(0).getDOMNode().textContent).toEqual( | ||
'Max Incidents Limit Reached', | ||
); | ||
expect(wrapper.find('.modal-body').at(0).getDOMNode().textContent).toEqual( | ||
[ | ||
`Current query parameters match\u00A0${totalIncidentsFromQuery}\u00A0incidents.`, | ||
`Only the first\u00A0${MAX_INCIDENTS_LIMIT}\u00A0incidents will be retrieved.Continue?`, | ||
].join(''), | ||
); | ||
}); | ||
}); |
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
Oops, something went wrong.