From 881584111ba708697d3e8de11ce9f0cd983dc72e Mon Sep 17 00:00:00 2001 From: Brett Sun Date: Mon, 20 Jun 2016 10:15:49 +0200 Subject: [PATCH] Replace AppConstant's baseUrl with appBasePath to be more inline with environment variable --- js/components/ascribe_routes/proxy_handler.js | 10 ++++------ js/constants/application_constants.js | 8 +++----- js/history.js | 4 +++- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/js/components/ascribe_routes/proxy_handler.js b/js/components/ascribe_routes/proxy_handler.js index fc0d7ffa..82ef6490 100644 --- a/js/components/ascribe_routes/proxy_handler.js +++ b/js/components/ascribe_routes/proxy_handler.js @@ -1,5 +1,3 @@ -'use strict'; - import React from 'react'; import UserStore from '../../stores/user_store'; @@ -10,7 +8,7 @@ import { currentUserShape, locationShape, routerShape, whitelabelShape } from '. import AppConstants from '../../constants/application_constants'; -const { bool, object } = React.PropTypes; +const { bool } = React.PropTypes; const WHEN_ENUM = ['loggedIn', 'loggedOut']; /** @@ -50,17 +48,17 @@ export function AuthRedirect({ to, when }) { return true; } else if (!exprToValidate && when === 'loggedOut' && redirectAuthenticated) { - /* + /** * redirectAuthenticated contains an arbitrary path * eg pieces/, editions/, collection, settings, ... * hence transitionTo cannot be used directly. * * While we're getting rid of `query.redirect` explicitly in the * above `else if` statement, here it's sufficient to just set the - * location to `${baseUrl}/${redirectAuthenticated}`, as this will + * location to `${appBasePath}/${redirectAuthenticated}`, as this will * get rid of queries as well. */ - window.location = `${AppConstants.baseUrl}/${redirectAuthenticated}`; + window.location = `${AppConstants.appBasePath}/${redirectAuthenticated}`; return true; } diff --git a/js/constants/application_constants.js b/js/constants/application_constants.js index 163c281b..4766f563 100644 --- a/js/constants/application_constants.js +++ b/js/constants/application_constants.js @@ -1,12 +1,10 @@ -'use strict'; - const apiEndpoint = process.env.API_URL; const serverUrl = process.env.SERVER_URL; -const baseUrl = process.env.APP_BASE_PATH; +const appBasePath = process.env.APP_BASE_PATH; const constants = { apiEndpoint, - baseUrl, + appBasePath, serverUrl, 'aclList': ['acl_coa', 'acl_consign', 'acl_delete', 'acl_download', 'acl_edit', 'acl_create_editions', 'acl_view_editions', 'acl_loan', 'acl_loan_request', 'acl_share', 'acl_transfer', 'acl_unconsign', 'acl_unshare', 'acl_view', @@ -98,7 +96,7 @@ const constants = { 'sdkUrl': 'https://code.jquery.com/jquery-2.1.4.min.js' }, 'audiojs': { - 'sdkUrl': baseUrl + '/static/third_party/audiojs/audio.min.js' + 'sdkUrl': `${appBasePath}/static/third_party/audiojs/audio.min.js` }, 'videojs': { 'sdkUrl': '//vjs.zencdn.net/4.12/video.js', diff --git a/js/history.js b/js/history.js index 84342656..c7192783 100644 --- a/js/history.js +++ b/js/history.js @@ -1,11 +1,13 @@ import useRouterHistory from 'react-router/es6/useRouterHistory'; +// History should be included by react-router +// eslint-disable-next-line import/no-extraneous-dependencies import createBrowserHistory from 'history/lib/createBrowserHistory'; import AppConstants from './constants/application_constants'; const history = useRouterHistory(createBrowserHistory)({ - basename: AppConstants.baseUrl + basename: AppConstants.appBasePath }); history.locationQueue = [];