From 22d23e7cbdb82537c6165da40284445283ba37f9 Mon Sep 17 00:00:00 2001 From: Becky Reamy Date: Thu, 1 Aug 2019 13:28:26 -0400 Subject: [PATCH 01/11] Increasing version number --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ce173c6..7615ab4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "libra-web", - "version": "0.1.0", + "version": "1.1.0", "private": true, "dependencies": { "axios": "^0.18.0", From b5a016cd4a73924cd9c47d1c5dea8947c0b48191 Mon Sep 17 00:00:00 2001 From: Zach Wright Date: Wed, 18 Sep 2019 12:49:25 -0400 Subject: [PATCH 02/11] KPMP-1300: Fix those package properties --- src/components/PackageDashboard/PackageTable.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/components/PackageDashboard/PackageTable.js b/src/components/PackageDashboard/PackageTable.js index 0a2e578..8b0e3bc 100644 --- a/src/components/PackageDashboard/PackageTable.js +++ b/src/components/PackageDashboard/PackageTable.js @@ -10,7 +10,7 @@ const SUBMITTER_LABEL = "Submitter"; const TIS_NAME_LABEL = "TIS Name"; const DATE_SUBMITTED_LABEL = "Date Submitted"; -const PACKAGE_ID = "packageId"; +const PACKAGE_ID = "_id"; const SUBMITTER_ID = "displayName"; const SUBMITTER_FIRST_NAME = "firstName"; const SUBMITTER_LAST_NAME = "lastName"; @@ -18,6 +18,7 @@ const PACKAGE_TYPE_ID = "packageType"; const TIS_NAME_ID = "tisName"; const DATE_SUBMITTED_ID = "createdAt"; const DATE_FORMAT = "YYYY-MM-DD, h:mm a z"; +const PACKAGE_INFO_PROPERTY = "packageInfo"; // package id, submitter, package type, tis name, date submitted class PackageTable extends Component { @@ -44,29 +45,29 @@ class PackageTable extends Component { { Header: PACKAGE_ID_LABEL, id: PACKAGE_ID, - accessor: (row) => row[PACKAGE_ID] + accessor: (row) => row[PACKAGE_INFO_PROPERTY][PACKAGE_ID] }, { Header: PACKAGE_TYPE_LABEL, id: PACKAGE_TYPE_ID, - accessor: (row) => row[PACKAGE_TYPE_ID] + accessor: (row) => row[PACKAGE_INFO_PROPERTY][PACKAGE_TYPE_ID] }, { Header: SUBMITTER_LABEL, id: SUBMITTER_ID, - accessor: (row) => row.submitter && row.submitter[SUBMITTER_ID] ? row.submitter[SUBMITTER_ID] : row.submitter[SUBMITTER_FIRST_NAME] + " " + row.submitter[SUBMITTER_LAST_NAME] + accessor: (row) => row[PACKAGE_INFO_PROPERTY].submitter && row[PACKAGE_INFO_PROPERTY].submitter[SUBMITTER_ID] ? row[PACKAGE_INFO_PROPERTY].submitter[SUBMITTER_ID] : row[PACKAGE_INFO_PROPERTY].submitter[SUBMITTER_FIRST_NAME] + " " + row[PACKAGE_INFO_PROPERTY].submitter[SUBMITTER_LAST_NAME] }, { Header: TIS_NAME_LABEL, id: TIS_NAME_ID, - accessor: (row) => row[TIS_NAME_ID] + accessor: (row) => row[PACKAGE_INFO_PROPERTY][TIS_NAME_ID] }, { Header: DATE_SUBMITTED_LABEL, id: DATE_SUBMITTED_ID, accessor: (row) => { - return new Moment(row[DATE_SUBMITTED_ID]) + return new Moment(row[PACKAGE_INFO_PROPERTY][DATE_SUBMITTED_ID]) .local() .format(DATE_FORMAT) } From b749b72fec38462bd38289a18de1b663bcd9dae1 Mon Sep 17 00:00:00 2001 From: Zach Wright Date: Wed, 18 Sep 2019 16:26:59 -0400 Subject: [PATCH 03/11] KPMP-1326: State column added --- src/components/PackageDashboard/PackageTable.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/components/PackageDashboard/PackageTable.js b/src/components/PackageDashboard/PackageTable.js index 8b0e3bc..dded4d2 100644 --- a/src/components/PackageDashboard/PackageTable.js +++ b/src/components/PackageDashboard/PackageTable.js @@ -9,6 +9,7 @@ const PACKAGE_TYPE_LABEL = "Package Type"; const SUBMITTER_LABEL = "Submitter"; const TIS_NAME_LABEL = "TIS Name"; const DATE_SUBMITTED_LABEL = "Date Submitted"; +const PACKAGE_STATE_LABEL = "Package State"; const PACKAGE_ID = "_id"; const SUBMITTER_ID = "displayName"; @@ -19,6 +20,7 @@ const TIS_NAME_ID = "tisName"; const DATE_SUBMITTED_ID = "createdAt"; const DATE_FORMAT = "YYYY-MM-DD, h:mm a z"; const PACKAGE_INFO_PROPERTY = "packageInfo"; +const PACKAGE_STATE_ID = "state"; // package id, submitter, package type, tis name, date submitted class PackageTable extends Component { @@ -71,6 +73,11 @@ class PackageTable extends Component { .local() .format(DATE_FORMAT) } + }, + { + Header: PACKAGE_STATE_LABEL, + id: PACKAGE_STATE_ID, + accessor: (row) => row.state && row.state[PACKAGE_STATE_ID] ? row.state[PACKAGE_STATE_ID] : "" } ]; } From 38102e33d3f62112992fa808b0383232802c734f Mon Sep 17 00:00:00 2001 From: Zach Wright Date: Thu, 19 Sep 2019 12:33:29 -0400 Subject: [PATCH 04/11] KPMP-1217: Update everything --- package.json | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/package.json b/package.json index 7615ab4..e7a70b9 100644 --- a/package.json +++ b/package.json @@ -3,26 +3,26 @@ "version": "1.1.0", "private": true, "dependencies": { - "axios": "^0.18.0", - "babel-polyfill": "^6.26.0", - "bootstrap-css-only": "^4.3.1", - "history": "^4.9.0", + "axios": "0.19.0", + "babel-polyfill": "6.26.0", + "bootstrap-css-only": "4.3.1", + "history": "4.10.1", "kpmp-custom-react-scripts": "1.1.2", - "moment": "^2.24.0", - "prop-types": "^15.7.2", - "react": "^16.8.6", - "react-dom": "^16.8.6", - "react-ga": "^2.5.7", - "react-redux": "^5.1.1", - "react-router-dom": "^5.0.0", - "react-table": "^6.10.0", - "reactstrap": "^7.1.0", - "redux": "^4.0.1", - "redux-thunk": "^2.3.0" + "moment": "2.24.0", + "prop-types": "15.7.2", + "react": "16.9.0", + "react-dom": "16.9.0", + "react-ga": "2.6.0", + "react-redux": "7.1.1", + "react-router-dom": "5.0.1", + "react-table": "6.10.3", + "reactstrap": "8.0.1", + "redux": "4.0.4", + "redux-thunk": "2.3.0" }, "devDependencies": { - "node-sass-chokidar": "^1.3.4", - "npm-run-all": "^4.1.5" + "node-sass-chokidar": "1.3.5", + "npm-run-all": "4.1.5" }, "scripts": { "start-js": "react-scripts start", From b443360eb93e908bc2c7e3ef964b5aaa86c076a4 Mon Sep 17 00:00:00 2001 From: Becky Reamy Date: Mon, 7 Oct 2019 12:54:09 -0400 Subject: [PATCH 05/11] KPMP-1338: Increased timeout on requests --- src/helpers/Api.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/helpers/Api.js b/src/helpers/Api.js index 61f6122..b16405b 100644 --- a/src/helpers/Api.js +++ b/src/helpers/Api.js @@ -5,7 +5,7 @@ export default class Api { constructor() { this.axios = axios.create({ - timeout: 10000, + timeout: 15000, }); } From 67dacebed8ebbc91bd160b66e56e3c968f15c128 Mon Sep 17 00:00:00 2001 From: Zach Wright Date: Thu, 10 Oct 2019 15:30:04 -0400 Subject: [PATCH 06/11] KPMP-1351: Lookup the state --- src/components/PackageDashboard/PackageTable.js | 3 ++- src/components/PackageDashboard/stateMap.js | 10 ++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 src/components/PackageDashboard/stateMap.js diff --git a/src/components/PackageDashboard/PackageTable.js b/src/components/PackageDashboard/PackageTable.js index dded4d2..66a0866 100644 --- a/src/components/PackageDashboard/PackageTable.js +++ b/src/components/PackageDashboard/PackageTable.js @@ -3,6 +3,7 @@ import ReactTable from 'react-table'; import ReactGA from 'react-ga'; import PropTypes from 'prop-types'; import Moment from 'moment'; +import stateMap from './stateMap'; const PACKAGE_ID_LABEL = "Package ID"; const PACKAGE_TYPE_LABEL = "Package Type"; @@ -77,7 +78,7 @@ class PackageTable extends Component { { Header: PACKAGE_STATE_LABEL, id: PACKAGE_STATE_ID, - accessor: (row) => row.state && row.state[PACKAGE_STATE_ID] ? row.state[PACKAGE_STATE_ID] : "" + accessor: (row) => row.state && row.state[PACKAGE_STATE_ID] ? stateMap.get(row.state[PACKAGE_STATE_ID]) : "" } ]; } diff --git a/src/components/PackageDashboard/stateMap.js b/src/components/PackageDashboard/stateMap.js new file mode 100644 index 0000000..2fa582c --- /dev/null +++ b/src/components/PackageDashboard/stateMap.js @@ -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; \ No newline at end of file From 36a5275beb5d679c5764ae6fa41cff19de19e01c Mon Sep 17 00:00:00 2001 From: Zach Wright Date: Thu, 10 Oct 2019 15:40:08 -0400 Subject: [PATCH 07/11] KPMP-1351: Lookup the state --- src/components/PackageDashboard/PackageTable.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/components/PackageDashboard/PackageTable.js b/src/components/PackageDashboard/PackageTable.js index 66a0866..966bd45 100644 --- a/src/components/PackageDashboard/PackageTable.js +++ b/src/components/PackageDashboard/PackageTable.js @@ -78,7 +78,12 @@ class PackageTable extends Component { { Header: PACKAGE_STATE_LABEL, id: PACKAGE_STATE_ID, - accessor: (row) => row.state && row.state[PACKAGE_STATE_ID] ? stateMap.get(row.state[PACKAGE_STATE_ID]) : "" + accessor: (row) => { + if (row.state && row.state[PACKAGE_STATE_ID]) { + return stateMap.has(row.state[PACKAGE_STATE_ID]) ? stateMap.get(row.state[PACKAGE_STATE_ID]) : row.state[PACKAGE_STATE_ID]; + } else + return "" + } } ]; } From 9fc61d5213e8392b461b1ef71371dfd209879c17 Mon Sep 17 00:00:00 2001 From: Zach Wright Date: Thu, 10 Oct 2019 15:50:40 -0400 Subject: [PATCH 08/11] KPMP-1351: No else --- src/components/PackageDashboard/PackageTable.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/PackageDashboard/PackageTable.js b/src/components/PackageDashboard/PackageTable.js index 966bd45..1d081b8 100644 --- a/src/components/PackageDashboard/PackageTable.js +++ b/src/components/PackageDashboard/PackageTable.js @@ -81,8 +81,8 @@ class PackageTable extends Component { accessor: (row) => { if (row.state && row.state[PACKAGE_STATE_ID]) { return stateMap.has(row.state[PACKAGE_STATE_ID]) ? stateMap.get(row.state[PACKAGE_STATE_ID]) : row.state[PACKAGE_STATE_ID]; - } else - return "" + } + return "" } } ]; From 381caafb6550666b9c1b44da387db6e9b0e88207 Mon Sep 17 00:00:00 2001 From: Becky Reamy Date: Fri, 11 Oct 2019 14:04:09 -0400 Subject: [PATCH 09/11] KPMP-1359: Add permission denied pages --- .gitignore | 1 + src/App.js | 9 ++-- src/actions/Error/errorActions.js | 57 ++++++++++++++---------- src/actions/Packages/packageActions.js | 4 +- src/components/Error/NotRegistered.js | 27 +++++++++++ src/components/Error/PermissionDenied.js | 27 +++++++++++ 6 files changed, 97 insertions(+), 28 deletions(-) create mode 100644 src/components/Error/NotRegistered.js create mode 100644 src/components/Error/PermissionDenied.js diff --git a/.gitignore b/.gitignore index b282ff0..9f12b39 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ build build/* node_modules node_modules/* +.project diff --git a/src/App.js b/src/App.js index e2c71df..ae2e820 100644 --- a/src/App.js +++ b/src/App.js @@ -13,6 +13,8 @@ import { Route, Switch, Router } from 'react-router-dom'; import ErrorBoundaryContainer from './components/Error/ErrorBoundaryContainer'; import Oops from './components/Error/Oops'; import PackageDashboardPageContainer from './components/PackageDashboard/PackageDashboardPageContainer'; +import PermissionDenied from './components/Error/PermissionDenied'; +import NotRegistered from './components/Error/NotRegistered'; const cacheStore = window.sessionStorage.getItem('redux-store'); const initialState = cacheStore ? JSON.parse(cacheStore) : loadedState; @@ -28,7 +30,6 @@ const saveState = () => { ); }; -// *** Get a new tracking Id and add it here *** // const GA_TRACKING_ID = 'UA-124331187-8'; if(process.env.NODE_ENV === 'production') { @@ -62,8 +63,10 @@ class App extends Component { - - + + + + diff --git a/src/actions/Error/errorActions.js b/src/actions/Error/errorActions.js index de2ddab..e0606ca 100644 --- a/src/actions/Error/errorActions.js +++ b/src/actions/Error/errorActions.js @@ -1,23 +1,34 @@ -//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) => { + if (!window.location.href.includes("/oops")) { + 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)); + }); + }; + } +} diff --git a/src/actions/Packages/packageActions.js b/src/actions/Packages/packageActions.js index 46c1ec3..950f16d 100644 --- a/src/actions/Packages/packageActions.js +++ b/src/actions/Packages/packageActions.js @@ -1,6 +1,6 @@ import actionNames from '../actionNames'; import Api from '../../helpers/Api'; -import { handleError } from '../Error/errorActions'; +import { sendMessageToBackend } from '../Error/errorActions'; const api = Api.getInstance(); @@ -11,7 +11,7 @@ export const getPackages = () => { dispatch(setPackages(res.data)); }) .catch(err => { - dispatch(handleError("Unable to connect to the Data Lake: " + err)); + dispatch(sendMessageToBackend(err)); }); }; } diff --git a/src/components/Error/NotRegistered.js b/src/components/Error/NotRegistered.js new file mode 100644 index 0000000..2693b5c --- /dev/null +++ b/src/components/Error/NotRegistered.js @@ -0,0 +1,27 @@ +import React, { Component } from 'react'; +import { Col, Row } from 'reactstrap'; + +class NotRegistered extends Component { + + render() { + return ( +
+ + + We're sorry. You are not authorized to access this application. + + + + +
+ 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:   + admin@kpmp.org +
+ +
+
+ ); + } +} + +export default NotRegistered; \ No newline at end of file diff --git a/src/components/Error/PermissionDenied.js b/src/components/Error/PermissionDenied.js new file mode 100644 index 0000000..ef0a20e --- /dev/null +++ b/src/components/Error/PermissionDenied.js @@ -0,0 +1,27 @@ +import React, { Component } from 'react'; +import { Col, Row } from 'reactstrap'; + +class PermissionDenied extends Component { + + render() { + return ( +
+ + + We're sorry. You are not authorized to access this application. + + + + +
+ Your account does not have permission to use this KPMP application. If you believe you received this page in error, please contact:   + admin@kpmp.org +
+ +
+
+ ); + } +} + +export default PermissionDenied; \ No newline at end of file From 7205c1305e24a9c8b33ce84d17c27a67df4db48d Mon Sep 17 00:00:00 2001 From: Becky Reamy Date: Tue, 15 Oct 2019 14:15:01 -0400 Subject: [PATCH 10/11] KPMP-1359: Prevent reloading of permission denied pages --- src/actions/Error/errorActions.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/actions/Error/errorActions.js b/src/actions/Error/errorActions.js index e0606ca..f2334a8 100644 --- a/src/actions/Error/errorActions.js +++ b/src/actions/Error/errorActions.js @@ -18,7 +18,8 @@ export const sendMessageToBackend = (error) => { if (error.response && error.response.status && error.response.status >= 400) { return (dispatch) => { - if (!window.location.href.includes("/oops")) { + let href = window.location.href; + if (!href.includes("/oops") && !href.includes("/permissionDenied") && !href.includes("/notRegistered")) { dispatch(handleError(error.response.status)); } } From ff79d77c4d4c63f919eb80309257892659513c8f Mon Sep 17 00:00:00 2001 From: Becky Reamy Date: Wed, 16 Oct 2019 10:37:05 -0400 Subject: [PATCH 11/11] KPMP-1284: Added the crossorigin use credentials on manifest.json to force app to check credentials --- public/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/index.html b/public/index.html index f642311..c099d65 100644 --- a/public/index.html +++ b/public/index.html @@ -12,7 +12,7 @@ manifest.json provides metadata used when your web app is added to the homescreen on Android. See https://developers.google.com/web/fundamentals/web-app-manifest/ --> - +