-
Notifications
You must be signed in to change notification settings - Fork 0
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 #15 from KPMP/develop
Prepare for Oct. 2019 release
- Loading branch information
Showing
11 changed files
with
148 additions
and
54 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 |
---|---|---|
|
@@ -5,3 +5,4 @@ build | |
build/* | ||
node_modules | ||
node_modules/* | ||
.project |
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
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 |
---|---|---|
@@ -1,23 +1,35 @@ | ||
//import Api from '../../helpers/Api'; | ||
|
||
//const api = Api.getInstance(); | ||
|
||
export const handleError = () => { | ||
return dispatch => { | ||
window.location.href = '/oops'; | ||
}; | ||
}; | ||
|
||
export const sendMessageToBackend = error => { | ||
let errorMessage = { error: error.message, stackTrace: error.stack }; | ||
console.log(errorMessage); | ||
handleError(); | ||
|
||
// Uncomment this section once you have an api to send errors to | ||
// return (dispatch) => { | ||
// api.post('/api/v1/error', errorMessage) | ||
// .then(res=> { | ||
// dispatch(handleError()); | ||
// }); | ||
// }; | ||
}; | ||
import Api from '../../helpers/Api'; | ||
|
||
const api = Api.getInstance(); | ||
|
||
export const handleError = (statusCode) => { | ||
return (dispatch) => { | ||
if (statusCode === 404) { | ||
window.location.href = "/notRegistered"; | ||
} else if (statusCode === 403) { | ||
window.location.href = "/permissionDenied" | ||
} else { | ||
window.location.href = "/oops"; | ||
} | ||
} | ||
}; | ||
|
||
export const sendMessageToBackend = (error) => { | ||
|
||
if (error.response && error.response.status && error.response.status >= 400) { | ||
return (dispatch) => { | ||
let href = window.location.href; | ||
if (!href.includes("/oops") && !href.includes("/permissionDenied") && !href.includes("/notRegistered")) { | ||
dispatch(handleError(error.response.status)); | ||
} | ||
} | ||
} else { | ||
let errorMessage = { error: error.message , stackTrace: error.stack } | ||
return (dispatch) => { | ||
api.post('/api/v1/error', errorMessage) | ||
.then(res=> { | ||
dispatch(handleError(error.response.status)); | ||
}); | ||
}; | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import React, { Component } from 'react'; | ||
import { Col, Row } from 'reactstrap'; | ||
|
||
class NotRegistered extends Component { | ||
|
||
render() { | ||
return ( | ||
<article className="container justify-content-center pt-3"> | ||
<Row > | ||
<Col xs={12} className="error-header pb-3"> | ||
We're sorry. You are not authorized to access this application. | ||
</Col> | ||
</Row> | ||
<Row> | ||
<Col xs={12}> | ||
<div className="alert alert-danger"> | ||
You must be a registered user in order to use this KPMP application. If you would like to register or believe you received this page in error, please contact: | ||
<a href="mailto:[email protected]">[email protected]</a> | ||
</div> | ||
</Col> | ||
</Row> | ||
</article> | ||
); | ||
} | ||
} | ||
|
||
export default NotRegistered; |
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,27 @@ | ||
import React, { Component } from 'react'; | ||
import { Col, Row } from 'reactstrap'; | ||
|
||
class PermissionDenied extends Component { | ||
|
||
render() { | ||
return ( | ||
<article className="container justify-content-center pt-3"> | ||
<Row > | ||
<Col xs={12} className="error-header pb-3"> | ||
We're sorry. You are not authorized to access this application. | ||
</Col> | ||
</Row> | ||
<Row> | ||
<Col xs={12}> | ||
<div className="alert alert-danger"> | ||
Your account does not have permission to use this KPMP application. If you believe you received this page in error, please contact: | ||
<a href="mailto:[email protected]">[email protected]</a> | ||
</div> | ||
</Col> | ||
</Row> | ||
</article> | ||
); | ||
} | ||
} | ||
|
||
export default PermissionDenied; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
const stateMap = new Map( | ||
[ | ||
["METADATA_RECEIVED", "Waiting for files"], | ||
["UPLOAD_SUCCEEDED", "Ready for review"], | ||
["FILES_RECEIVED", "Finishing upload"], | ||
["UPLOAD_STARTED", "Upload started"] | ||
] | ||
); | ||
|
||
export default stateMap; |
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