diff --git a/.env.production b/.env.production index a6be6968..5950b945 100644 --- a/.env.production +++ b/.env.production @@ -1,6 +1,7 @@ -VITE_ALERT_EDITOR: false -VITE_FORMULA_EDITOR: true -VITE_INSTRUMENT_CHART: true -VITE_CROSS_SECTION: true -VITE_DEVELOPMENT_BANNER: false -VITE_API_URL: https://midas.sec.usace.army.mil/api +VITE_ALERT_EDITOR=false +VITE_FORMULA_EDITOR=true +VITE_INSTRUMENT_CHART=true +VITE_CROSS_SECTION=true +VITE_DEVELOPMENT_BANNER=false +VITE_API_URL=https://midas.sec.usace.army.mil/api +VITE_URL_BASE_PATH=/midas diff --git a/.env.test b/.env.test index bb89df14..0783a221 100644 --- a/.env.test +++ b/.env.test @@ -1,6 +1,7 @@ -VITE_ALERT_EDITOR: false -VITE_FORMULA_EDITOR: true -VITE_INSTRUMENT_CHART: true -VITE_CROSS_SECTION: true -VITE_DEVELOPMENT_BANNER: false -VITE_API_URL: https://midas-test.cwbi.us/api +VITE_ALERT_EDITOR=false +VITE_FORMULA_EDITOR=true +VITE_INSTRUMENT_CHART=true +VITE_CROSS_SECTION=true +VITE_DEVELOPMENT_BANNER=false +VITE_API_URL=https://midas-test.cwbi.us/api +VITE_URL_BASE_PATH=/midas diff --git a/.github/workflows/develop.yml b/.github/workflows/develop.yml index d4ac9a19..595b3ceb 100644 --- a/.github/workflows/develop.yml +++ b/.github/workflows/develop.yml @@ -18,6 +18,7 @@ jobs: VITE_CROSS_SECTION: true VITE_DEVELOPMENT_BANNER: true VITE_API_URL: https://develop-midas-api.rsgis.dev + VITE_URL_BASE_PATH: '' runs-on: ubuntu-latest strategy: matrix: diff --git a/.github/workflows/stable.yml b/.github/workflows/stable.yml index 87044126..9010805a 100644 --- a/.github/workflows/stable.yml +++ b/.github/workflows/stable.yml @@ -14,6 +14,7 @@ jobs: env: VITE_FORMULA_EDITOR: true VITE_API_URL: https://midas-api.rsgis.dev + VITE_URL_BASE_PATH: '' runs-on: ubuntu-latest strategy: matrix: diff --git a/src/app-bundles/collection-group-bundle.js b/src/app-bundles/collection-group-bundle.js index 60ff7d33..52f93b0c 100644 --- a/src/app-bundles/collection-group-bundle.js +++ b/src/app-bundles/collection-group-bundle.js @@ -20,11 +20,11 @@ export default createRestBundle({ urlParamSelectors: ['selectProjectsIdByRoute'], prefetch: (store) => { const hash = store.selectHash(); - const url = store.selectUrlObject(); + const pathname = store.selectRelativePathname(); const whiteList = ['dashboard']; return ( - whiteList.includes(hash) || url.pathname.includes('/collection-groups/') + whiteList.includes(hash) || pathname.includes('/collection-groups/') ); }, addons: { diff --git a/src/app-bundles/create-auth-bundle.js b/src/app-bundles/create-auth-bundle.js index 1d5ef0ae..870bc73a 100644 --- a/src/app-bundles/create-auth-bundle.js +++ b/src/app-bundles/create-auth-bundle.js @@ -89,7 +89,7 @@ const createAuthBundle = (opts) => { }); store.doRemoveProfile(); const redirect = store.selectAuthRedirectOnLogout(); - if (redirect) store.doUpdateUrl(redirect); + if (redirect) store.doUpdateRelativeUrl(redirect); } }, diff --git a/src/app-bundles/create-url-base-path-bundle.js b/src/app-bundles/create-url-base-path-bundle.js new file mode 100644 index 00000000..393d948a --- /dev/null +++ b/src/app-bundles/create-url-base-path-bundle.js @@ -0,0 +1,13 @@ +import { createSelector } from "redux-bundler"; + +export default ({ base }) => { + return { + name: 'urlBasePath', + + selectRelativePathname: createSelector('selectPathname', pathname => pathname.replace(base, '')), + + doUpdateRelativeUrl: (url, opts) => ({ store }) => { + store.doUpdateUrl(`${base}${url}`, opts) + }, + } +}; diff --git a/src/app-bundles/home-data-bundle.js b/src/app-bundles/home-data-bundle.js index b7a6ec8f..c90f0317 100644 --- a/src/app-bundles/home-data-bundle.js +++ b/src/app-bundles/home-data-bundle.js @@ -11,11 +11,7 @@ export default createRestBundle({ getTemplate: '/home', fetchActions: ['URL_UPDATED', 'AUTH_LOGGED_IN'], forceFetchActions: [], - prefetch: store => { - const url = store.selectUrlObject(); - - return url.pathname === '/'; - }, + prefetch: store => store.selectRelativePathname() === '/', addons: { selectHomeData: createSelector('selectHomeItems', (items) => { const data = items && items.length ? items[0] : null; diff --git a/src/app-bundles/inclinometer-measurements.js b/src/app-bundles/inclinometer-measurements.js index dce469fd..d41b1167 100644 --- a/src/app-bundles/inclinometer-measurements.js +++ b/src/app-bundles/inclinometer-measurements.js @@ -25,12 +25,12 @@ export default createRestBundle({ mergeItems: true, prefetch: (store) => { const hash = store.selectHash(); - const url = store.selectUrlObject(); + const pathname = store.selectRelativePathname(); const whitelist = []; const pathnameWhitelist = ['/instruments/', '/groups/', '/collection-groups/']; - return whitelist.includes(hash) || pathnameWhitelist.some(elem => url.pathname.includes(elem)); + return whitelist.includes(hash) || pathnameWhitelist.some(elem => pathname.includes(elem)); }, addons: { doFetchInclinometerMeasurementsByTimeseriesId: (timeseriesId) => ({ dispatch, apiGet }) => { diff --git a/src/app-bundles/index.js b/src/app-bundles/index.js index a953d183..a8fd5bf0 100644 --- a/src/app-bundles/index.js +++ b/src/app-bundles/index.js @@ -7,6 +7,7 @@ import { import createAuthBundle from './create-auth-bundle'; // Required change from @corpsmap/create-jwt-api-bundle; import createJwtApiBundle from './create-jwt-api-bundle'; +import createUrlBasePathBundle from './create-url-base-path-bundle'; import cache from '../common/helpers/cache'; import alertReadBundle from './alert-read-bundle'; @@ -108,6 +109,7 @@ export default composeBundles( cacheFn: cache.set, }), createUrlBundle(), + createUrlBasePathBundle({ base: import.meta.env.VITE_URL_BASE_PATH ?? '' }), alertReadBundle, alertSubscribeBundle, alertUnreadBundle, diff --git a/src/app-bundles/instrument-bundle.js b/src/app-bundles/instrument-bundle.js index 3bf8e324..8bc65700 100644 --- a/src/app-bundles/instrument-bundle.js +++ b/src/app-bundles/instrument-bundle.js @@ -31,7 +31,7 @@ export default createRestBundle({ urlParamSelectors: ['selectProjectsIdByRoute'], prefetch: (store) => { const hash = store.selectHash(); - const url = store.selectUrlObject(); + const pathname = store.selectRelativePathname(); const whiteList = [ 'dashboard', 'uploader', @@ -49,7 +49,7 @@ export default createRestBundle({ return ( whiteList.includes(hash) || - pathnameWhitelist.some((elem) => url.pathname.includes(elem)) + pathnameWhitelist.some((elem) => pathname.includes(elem)) ); }, addons: { diff --git a/src/app-bundles/instrument-group-bundle.js b/src/app-bundles/instrument-group-bundle.js index f94013e9..15b7d132 100644 --- a/src/app-bundles/instrument-group-bundle.js +++ b/src/app-bundles/instrument-group-bundle.js @@ -20,10 +20,10 @@ export default createRestBundle({ urlParamSelectors: ['selectProjectsIdByRoute'], prefetch: (store) => { const hash = store.selectHash(); - const url = store.selectUrlObject(); + const pathname = store.selectRelativePathname(); const whiteList = ['dashboard', 'explorer']; - return whiteList.includes(hash) || url.pathname.includes('/groups/'); + return whiteList.includes(hash) || pathname.includes('/groups/'); }, addons: { selectInstrumentGroupsIdByRoute: createSelector( diff --git a/src/app-bundles/profile-bundle.js b/src/app-bundles/profile-bundle.js index d080af75..06f12ca7 100644 --- a/src/app-bundles/profile-bundle.js +++ b/src/app-bundles/profile-bundle.js @@ -73,7 +73,7 @@ export default createRestBundle({ }), reactProfileExists: createSelector( 'selectAuthIsLoggedIn', - 'selectPathname', + 'selectRelativePathname', 'selectProfileIsLoading', 'selectProfileActive', (isLoggedIn, path, profileIsLoading, profile) => { @@ -81,7 +81,7 @@ export default createRestBundle({ if (!profile) { if (path !== '/signup') return { - actionCreator: 'doUpdateUrl', + actionCreator: 'doUpdateRelativeUrl', args: ['/signup'], }; } @@ -91,11 +91,11 @@ export default createRestBundle({ reactProfileCreatedRedirect: createSelector( 'selectProfileActive', 'selectAuthIsLoggedIn', - 'selectPathname', + 'selectRelativePathname', (profile, isLoggedIn, path) => { if (path === '/signup' && (profile || !isLoggedIn)) return { - actionCreator: 'doUpdateUrl', + actionCreator: 'doUpdateRelativeUrl', args: ['/'], }; } diff --git a/src/app-bundles/routes-bundle.js b/src/app-bundles/routes-bundle.js index 64dd96f5..d9650dc9 100644 --- a/src/app-bundles/routes-bundle.js +++ b/src/app-bundles/routes-bundle.js @@ -11,19 +11,21 @@ import Profile from '../app-pages/profile/userProfile'; import Project from '../app-pages/project'; import SignUp from '../app-pages/signup/signup'; +const base = import.meta.env.VITE_URL_BASE_PATH ?? '' + export default createRouteBundle( { - '': Home, - '/': Home, - '/help': Help, - '/logout': Logout, - '/signup': SignUp, - '/profile': Profile, - '/not-found': NotFound, - '/:projectSlug': Project, - '/:projectSlug/groups/:groupSlug': InstrumentGroup, - '/:projectSlug/instruments/:instrumentSlug': Instrument, - '/:projectSlug/collection-groups/:collectionGroupSlug': CollectionGroup, + [`${base}`]: Home, + [`${base}/`]: Home, + [`${base}/help`]: Help, + [`${base}/logout`]: Logout, + [`${base}/signup`]: SignUp, + [`${base}/profile`]: Profile, + [`${base}/not-found`]: NotFound, + [`${base}/:projectSlug`]: Project, + [`${base}/:projectSlug/groups/:groupSlug`]: InstrumentGroup, + [`${base}/:projectSlug/instruments/:instrumentSlug`]: Instrument, + [`${base}/:projectSlug/collection-groups/:collectionGroupSlug`]: CollectionGroup, '*': NotFound, } ); diff --git a/src/app-bundles/time-series-measurements-bundle.js b/src/app-bundles/time-series-measurements-bundle.js index cd1fb158..c4e60123 100644 --- a/src/app-bundles/time-series-measurements-bundle.js +++ b/src/app-bundles/time-series-measurements-bundle.js @@ -28,12 +28,12 @@ export default createRestBundle({ mergeItems: true, prefetch: (store) => { const hash = store.selectHash(); - const url = store.selectUrlObject(); + const pathname = store.selectRelativePathname(); const whitelist = []; const pathnameWhitelist = ['/instruments/', '/groups/', '/collection-groups/']; - return whitelist.includes(hash) || pathnameWhitelist.some(elem => url.pathname.includes(elem)); + return whitelist.includes(hash) || pathnameWhitelist.some(elem => pathname.includes(elem)); }, addons: { doTimeseriesMeasurementsFetchById: ({ diff --git a/src/app-components/navigation/navBar.jsx b/src/app-components/navigation/navBar.jsx index 88f5eb63..6cd0e0b7 100644 --- a/src/app-components/navigation/navBar.jsx +++ b/src/app-components/navigation/navBar.jsx @@ -27,12 +27,12 @@ const NavBar = connect( 'doAuthLogin', 'selectAuthIsLoggedIn', 'selectProjectsByRoute', - 'selectPathname', + 'selectRelativePathname', ({ doAuthLogin, authIsLoggedIn, projectsByRoute: project, - pathname, + relativePathname: pathname, }) => { const [hideBrand, setHideBrand] = useState(false); const [brand, setBrand] = useState(null); @@ -92,7 +92,7 @@ const NavBar = connect(
No alerts!
; return ( @@ -32,7 +32,7 @@ const buildAlertContent = (alerts = []) => { return (