From a56dba63a2f7726c53723ff186c038a43f45ca15 Mon Sep 17 00:00:00 2001 From: Mike Stone Date: Fri, 3 Mar 2017 12:21:07 -0500 Subject: [PATCH] Get app to work in IE (#1344) * Use lodash for endsWith support * Fix IE Promise and Object.assign --- docs/third-party/licenses.md | 1 + frontend/redux/middlewares/auth.js | 4 ++-- frontend/redux/middlewares/redirect/index.js | 4 ++-- frontend/redux/store.js | 7 +++++++ package.json | 3 ++- yarn.lock | 10 +++++++--- 6 files changed, 21 insertions(+), 8 deletions(-) diff --git a/docs/third-party/licenses.md b/docs/third-party/licenses.md index 5f63580a..d716906d 100644 --- a/docs/third-party/licenses.md +++ b/docs/third-party/licenses.md @@ -287,6 +287,7 @@ Third-Party Licenses | [es5-ext](https://www.npmjs.com/package/es5-ext) | [MIT](https://opensource.org/licenses/MIT) | | [es6-iterator](https://www.npmjs.com/package/es6-iterator) | [MIT](https://opensource.org/licenses/MIT) | | [es6-map](https://www.npmjs.com/package/es6-map) | [MIT](https://opensource.org/licenses/MIT) | +| [es6-object-assign](https://www.npmjs.com/package/es6-object-assign) | [MIT](https://opensource.org/licenses/MIT) | | [es6-promise](https://www.npmjs.com/package/es6-promise) | [MIT](https://opensource.org/licenses/MIT) | | [es6-set](https://www.npmjs.com/package/es6-set) | [MIT](https://opensource.org/licenses/MIT) | | [es6-symbol](https://www.npmjs.com/package/es6-symbol) | [MIT](https://opensource.org/licenses/MIT) | diff --git a/frontend/redux/middlewares/auth.js b/frontend/redux/middlewares/auth.js index a2403ed4..ac176155 100644 --- a/frontend/redux/middlewares/auth.js +++ b/frontend/redux/middlewares/auth.js @@ -1,5 +1,5 @@ /* eslint-disable no-unused-vars */ -import { get } from 'lodash'; +import { endsWith, get } from 'lodash'; import { push } from 'react-router-redux'; import APP_CONSTANTS from 'app_constants'; @@ -12,7 +12,7 @@ const { HTTP_STATUS, PATHS } = APP_CONSTANTS; const authMiddleware = store => next => (action) => { const { type, payload } = action; - if (type.endsWith('FAILURE')) { + if (endsWith(type, 'FAILURE')) { if (get(payload, 'errors.http_status') === HTTP_STATUS.UNAUTHENTICATED) { store.dispatch(logoutSuccess); } diff --git a/frontend/redux/middlewares/redirect/index.js b/frontend/redux/middlewares/redirect/index.js index 7e620dcd..2d6a644e 100644 --- a/frontend/redux/middlewares/redirect/index.js +++ b/frontend/redux/middlewares/redirect/index.js @@ -1,5 +1,5 @@ /* eslint-disable no-unused-vars */ -import { get } from 'lodash'; +import { endsWith, get } from 'lodash'; import { push } from 'react-router-redux'; import APP_CONSTANTS from 'app_constants'; @@ -9,7 +9,7 @@ const { HTTP_STATUS, PATHS } = APP_CONSTANTS; const redirectMiddleware = store => next => (action) => { const { type, payload } = action; - if (type.endsWith('FAILURE')) { + if (endsWith(type, 'FAILURE')) { const httpStatus = get(payload, 'errors.http_status'); if (HTTP_STATUS.INTERNAL_ERROR.test(httpStatus)) { diff --git a/frontend/redux/store.js b/frontend/redux/store.js index 52d7c705..7bcb0080 100644 --- a/frontend/redux/store.js +++ b/frontend/redux/store.js @@ -1,3 +1,6 @@ +import Es6ObjectAssign from 'es6-object-assign'; +import Es6Promise from 'es6-promise'; + import { applyMiddleware, compose, createStore } from 'redux'; import { browserHistory } from 'react-router'; import { loadingBarMiddleware } from 'react-redux-loading-bar'; @@ -9,6 +12,10 @@ import nagMessageMiddleware from './middlewares/nag_message'; import redirectMiddleware from './middlewares/redirect'; import reducers from './reducers'; +// ie polyfills +Es6ObjectAssign.polyfill(); +Es6Promise.polyfill(); + const initialState = {}; const appliedMiddleware = applyMiddleware( diff --git a/package.json b/package.json index 3027632b..6e8947f1 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,8 @@ "css-loader": "^0.23.1", "cssrecipes-defaults": "^0.5.0", "enzyme": "^2.4.1", - "es6-promise": "^3.2.1", + "es6-object-assign": "^1.0.3", + "es6-promise": "^4.0.5", "expect": "^1.20.2", "expose-loader": "^0.7.1", "express": "^4.13.4", diff --git a/yarn.lock b/yarn.lock index 3235633a..0d995d0e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2002,9 +2002,13 @@ es6-map@^0.1.3: es6-symbol "~3.1.0" event-emitter "~0.3.4" -es6-promise@^3.2.1: - version "3.3.1" - resolved "https://registry.yarnpkg.com/es6-promise/-/es6-promise-3.3.1.tgz#a08cdde84ccdbf34d027a1451bc91d4bcd28a613" +es6-object-assign@^1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/es6-object-assign/-/es6-object-assign-1.0.3.tgz#40a192e0fda5ee44ee8cf6f5b5d9b47cd0f69b14" + +es6-promise@^4.0.5: + version "4.0.5" + resolved "https://registry.yarnpkg.com/es6-promise/-/es6-promise-4.0.5.tgz#7882f30adde5b240ccfa7f7d78c548330951ae42" es6-set@^0.1.4, es6-set@~0.1.3: version "0.1.4"