Skip to content
Open
Show file tree
Hide file tree
Changes from 46 commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
a66abd6
init PR
jjmccoy Sep 25, 2024
739d0f4
upgrade react router to v6.26.2
jjmccoy Sep 25, 2024
2c0ed05
update App.js routing syntax
jjmccoy Sep 26, 2024
293cc57
establish withRouter wrapper
jjmccoy Sep 26, 2024
53d8d78
replace switch with routes syntax
jjmccoy Sep 26, 2024
610f753
upgrade history dependency
jjmccoy Sep 27, 2024
5d44d14
correct root reference for router
jjmccoy Sep 27, 2024
3d1d72d
create search query params wrapper for React hook
jjmccoy Oct 4, 2024
34b8594
establish new queryparams and useselector hooks
jjmccoy Oct 7, 2024
e4ce414
rework nested routes with login and auth to react router v6
jjmccoy Oct 9, 2024
2eb453f
establish new UrlHelper HOC for query params
jjmccoy Oct 17, 2024
cc6b48d
fix router and location for auth to home page
jjmccoy Oct 17, 2024
f9cfced
consolidate HOC wrappers into one
jjmccoy Oct 17, 2024
271d4dc
parent pages params to state routed
jjmccoy Oct 18, 2024
a5e31c3
initial routing updates for child pages
jjmccoy Oct 22, 2024
e232f64
link parent and child page routes for top navigation
jjmccoy Oct 25, 2024
7a2b8f8
initial table config link and button params
jjmccoy Oct 31, 2024
689dffe
refactor SortableTable and select table-configs
jjmccoy Nov 1, 2024
aa7e3ed
more table routing for links and buttons
jjmccoy Nov 26, 2024
0ddab3f
addtl routing updates
jjmccoy Dec 4, 2024
c43285c
more routing updates and console error fixes
jjmccoy Dec 6, 2024
34f4bfa
Merge branch 'develop' into CUMULUS-3862
jjmccoy Dec 9, 2024
3010f1d
update changelog
jjmccoy Dec 9, 2024
77ce9ab
update packages with --legacy-peer-deps for react router work
jjmccoy Dec 9, 2024
1f39ea4
finalize routes
jjmccoy Dec 11, 2024
538f684
fix rendering issues
jjmccoy Dec 13, 2024
8d769d8
fix render routing for edit collection
jjmccoy Dec 18, 2024
df34d89
clean up notes and comment outs
jjmccoy Dec 19, 2024
212fe1d
fix code to show stats in sidebar
jjmccoy Dec 23, 2024
d0f7ef6
fix table.js re-rendering useEffect issues
jjmccoy Dec 30, 2024
d54710b
clean up code and update util file
jjmccoy Dec 30, 2024
2ecd9b6
Merge branch 'develop' into CUMULUS-3862
jjmccoy Dec 31, 2024
e12654d
--legacy-peer-deps for connected-react-router
jjmccoy Dec 31, 2024
bfeef94
apply createRoot import to index.js
jjmccoy Dec 31, 2024
8cd4e44
address unit test failures for updated components
jjmccoy Jan 2, 2025
fb84511
replace url-helper with withUrlHelper in components to use router hooks
jjmccoy Jan 2, 2025
27256e6
finalize withUrlHelper.js
jjmccoy Jan 2, 2025
e0458d1
unit test updates with react router hooks
jjmccoy Jan 6, 2025
fd274ac
update eslint for import circular dependency
jjmccoy Jan 6, 2025
7207573
add eslint directive to withUrlHelper
jjmccoy Jan 6, 2025
840f537
update changelog
jjmccoy Jan 6, 2025
28ebd1c
Merge branch 'develop' into CUMULUS-3862
jjmccoy Jan 23, 2025
57939ac
Merge branch 'develop' into CUMULUS-3862
jjmccoy Jan 23, 2025
904bdfb
fix main_page_spec test errors
jjmccoy Jan 28, 2025
e06c9f4
Merge branch 'develop' into CUMULUS-3862
jjmccoy Feb 6, 2025
adfe826
fix lint error
jjmccoy Feb 6, 2025
175ef09
pr feedback code cleanup
jjmccoy Feb 21, 2025
8a5dc12
pr feedback code update
jjmccoy Feb 28, 2025
12590a4
remove unnecessary code
jjmccoy Mar 26, 2025
1c7dfba
Merge branch 'develop' into CUMULUS-3862
Nnaga1 Apr 21, 2025
aadd37e
Merge branch 'develop' into CUMULUS-3862
Nnaga1 Apr 23, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,19 @@
"react/react-in-jsx-scope": 2,
"react-hooks/rules-of-hooks": "error",
"react-hooks/exhaustive-deps": "warn",
"eslint-comments/no-unused-disable": "warn",
"eslint-comments/no-unused-disable": "off",
"eslint-comments/disable-enable-pair": [
"error",
{ "allowWholeFile": true }
],
"import/no-extraneous-dependencies": "off",
"import/newline-after-import": "off",
"import/no-named-as-default": "off",
"import/no-cycle": ["error", {
"maxDepth": 10,
"ignoreExternal": true,
"allowUnsafeDynamicCyclicDependency": false
}],
"lodash/import-scope": ["error", "method"],
"lodash/prefer-constant": "off",
"lodash/prefer-lodash-method": "off",
Expand Down
16 changes: 7 additions & 9 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,11 @@ This version of the dashboard requires Cumulus API >= v19.2.0-alpha.1 (TBD API r

### Changed

- **CUMULUS-3862**
- Updated documentation to account for short term React upgrade version dependency issues that arise using npm.

- **GitHub Issue 1162**
- Added documentation for beginners starting from scratch.

### Changed

- **CUMULUS-3861**
- Updated React 17 to React 18
- Removed test script references to Enzyme and replaced them with React compliant testing components

### Changed

- **CUMULUS-3860/3870**
- Updated React and dependencies
- react 17.0.2 ⇒ 18.3.1
Expand All @@ -39,6 +30,13 @@ This version of the dashboard requires Cumulus API >= v19.2.0-alpha.1 (TBD API r
`@cumulus/[email protected]`
- Updated the integration tests to work with updated API
- Updated packages to address [CVE-2024-21538] (https://github.com/advisories/GHSA-3xgq-45jj-v275)
- **CUMULUS-3862**
- Updated React Router v5.2.0 to v6.26.2
- Updated routes and hooks for app navigation
- Established new router with withRouter.js HOC
- Established withUrlHelper.js HOC to later replace URL params utility
- Updated unit tests to accommodate component changes
- Updated documentation to account for short term React upgrade version dependency issues that arise using npm.
- **CUMULUS-3870**
- Remove launchpad security key information from cypress fixture for `valid-execution.json`
- Add placeholders for security information with `fakePassword` and `userName`
Expand Down
6 changes: 3 additions & 3 deletions app/src/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import ReactDOM from 'react-dom/client';
import { createRoot } from 'react-dom/client';

import './css/main.scss';
import './public/favicon.ico';
Expand All @@ -13,5 +13,5 @@ import App from './js/App';
axe.default(React, ReactDOM, 1000);
});
} */

ReactDOM.createRoot(document.getElementById('site-canvas')).render(<App />);
const root = createRoot(document.getElementById('app'));
root.render(<App />);
84 changes: 47 additions & 37 deletions app/src/js/App.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import React, { useState } from 'react';
import { Provider } from 'react-redux';
import { Route, Redirect, Switch } from 'react-router-dom';
import { ConnectedRouter } from 'connected-react-router';

import ourConfigureStore, { history } from './store/configureStore';
import { Provider, useSelector } from 'react-redux';
import {
Routes,
Route,
Navigate,
BrowserRouter,
} from 'react-router-dom';
import ourConfigureStore from './store/configureStore';

// Authorization & Error Handling
// import ErrorBoundary from './components/Errors/ErrorBoundary';
import ErrorBoundary from './components/Errors/ErrorBoundary';
import NotFound from './components/404';
import OAuth from './components/oauth';

Expand All @@ -27,44 +30,51 @@ import config from './config';

console.log('Environment', config.environment);

// Wrapper for Main component to include routing
const MainRoutes = () => (
<Main path='/'>
<Switch>
<Route exact path='/' component={Home} />
<Route path='/404' component={NotFound} />
<Route path='/collections' component={Collections} />
<Route path='/granules' component={Granules} />
<Route path='/pdrs' component={Pdrs} />
<Route path='/providers' component={Providers} />
<Route path='/workflows' component={Workflows} />
<Route path='/executions' component={Executions} />
<Route path='/operations' component={Operations} />
<Route path='/rules' component={Rules} />
<Route path='/reconciliation-reports' component={ReconciliationReports} />
</Switch>
</Main>
);
// Establish auth and login rules if user is or is not authenticated via Launchpad
const AuthenicatedRoute = () => {
const isAuthenticated = useSelector((state) => state.api.authenticated);
console.log('Authentication status:', isAuthenticated);
return isAuthenticated ? <Main /> : <Navigate to='auth' replace />;
};

const LoginRoute = () => {
const isAuthenticated = useSelector((state) => state.api.authenticated);
return isAuthenticated ? <Navigate to='/' replace /> : <OAuth />;
};

// generate the root App Component
// Routes for the Cumulus Dashboard app
const App = () => {
const [store] = useState(ourConfigureStore({}));
const isLoggedIn = () => store.getState().api.authenticated;

return (
// <ErrorBoundary> // Add after troublshooting other errors
// Routes
<div className="routes">
// Router with Store
<div className='routes'>
<ErrorBoundary>
<Provider store={store}>
<ConnectedRouter history={history}>
<Switch>
<Redirect exact from='/login' to='/auth' />
<Route path='/auth' render={() => (isLoggedIn() ? <Redirect to='/' /> : <OAuth />)} />
<Route path='/' render={() => (isLoggedIn() ? <MainRoutes /> : <Redirect to='/auth' />)} />
</Switch>
</ConnectedRouter>
<BrowserRouter>
<Routes>
<Route path={'/login'} element={<Navigate to='/auth' replace />} />
<Route path={'/auth'} element={<LoginRoute />} />
<Route element={<AuthenicatedRoute />}>
<Route path={'/'} index element={<Home />} />
<Route path={'/collections/*'} element={<Collections />} />
<Route path={'/providers/*'} element={<Providers />} />
<Route path={'/granules/*'} element={<Granules />} />
<Route path={'/workflows/*'} element={<Workflows />} />
<Route path={'/executions/*'} element={<Executions />} />
<Route path={'/operations/*'} element={<Operations />} />
<Route path={'/rules/*'} element={<Rules />} />
<Route path={'/pdrs/*'} element={<Pdrs />} />
<Route path={'/reconciliation-reports/*'} element={<ReconciliationReports />}/>
</Route>
<Route path={'/404'} element={<NotFound />} />
<Route path={'*'} element={<Navigate to='/404' replace />} />
<Route path={'*'} element={<Navigate to='/' replace />} />
</Routes>
</BrowserRouter>
</Provider>
</div>
</ErrorBoundary>
</div>
);
};

Expand Down
2 changes: 1 addition & 1 deletion app/src/js/actions/helpers.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable import/no-cycle */
import { get as getProperty } from 'object-path';
import _config from '../config';
import { filterQueryParams } from '../utils/url-helper';
import { filterQueryParams } from '../withUrlHelper';

export const formatError = (response = {}, body = {}) => {
let error = response
Expand Down
6 changes: 3 additions & 3 deletions app/src/js/actions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { getCollectionId, collectionNameVersion } from '../utils/format';
import { fetchCurrentTimeFilters } from '../utils/datepicker';
import log from '../utils/log';
import * as types from './types';
import { historyPushWithQueryParams } from '../utils/url-helper';
// import { historyPushWithQueryParams } from '../withUrlHelper';

const { CALL_API } = types;
const {
Expand Down Expand Up @@ -617,8 +617,8 @@ export const deleteToken = () => (dispatch, getState) => {
};

export const loginError = (error) => (dispatch) => dispatch(deleteToken())
.then(() => dispatch({ type: 'LOGIN_ERROR', error }))
.then(() => historyPushWithQueryParams('/auth'));
.then(() => dispatch({ type: 'LOGIN_ERROR', error }));
// .then(() => historyPushWithQueryParams('/auth')); -- handled in oauth component instead

export const getSchema = (type) => ({
[CALL_API]: {
Expand Down
2 changes: 1 addition & 1 deletion app/src/js/components/404.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import { connect } from 'react-redux';
import { withRouter } from 'react-router-dom';
import withRouter from '../withRouter';

const NotFound = () => (
<div className='page__404'>
Expand Down
4 changes: 2 additions & 2 deletions app/src/js/components/Add/add.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ import path from 'path';
import React, { useEffect, useState } from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import { withRouter } from 'react-router-dom';
import { get } from 'object-path';
import { getSchema } from '../../actions';
import Schema from '../FormSchema/schema';
import Loading from '../LoadingIndicator/loading-indicator';
import _config from '../../config';
import { strings } from '../locale';
import { window } from '../../utils/browser';
import { historyPushWithQueryParams } from '../../utils/url-helper';
import { historyPushWithQueryParams } from '../../withUrlHelper';
import withRouter from '../../withRouter';

const { updateDelay } = _config;

Expand Down
5 changes: 3 additions & 2 deletions app/src/js/components/AddRaw/add-raw.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import React, { useState, useEffect } from 'react';
import { connect } from 'react-redux';
import { withRouter } from 'react-router-dom';
// import { withRouter } from 'react-router-dom';
import PropTypes from 'prop-types';
import { get } from 'object-path';
import { displayCase } from '../../utils/format';
import _config from '../../config';

import TextArea from '../TextAreaForm/text-area';
import DefaultModal from '../Modal/modal';
import { historyPushWithQueryParams } from '../../utils/url-helper';
import { historyPushWithQueryParams } from '../../withUrlHelper';
import withRouter from '../../withRouter';

const { updateDelay } = _config;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useEffect, useState, useRef } from 'react';
import PropTypes from 'prop-types';
import { withRouter } from 'react-router';
// import { withRouter } from 'react-router';
import queue from 'stubborn-queue';
import {
CircularProgressbar,
Expand All @@ -13,6 +13,7 @@ import isArray from 'lodash/isArray';
import AsyncCommand from '../AsyncCommands/AsyncCommands';
import DefaultModal from '../Modal/modal';
import ErrorReport from '../Errors/report';
import withRouter from '../../withRouter';

const CONCURRENCY = 3;

Expand Down
35 changes: 20 additions & 15 deletions app/src/js/components/Breadcrumbs/Breadcrumbs.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
import React from 'react';
import PropTypes from 'prop-types';
import { Link, useLocation } from 'react-router-dom';
import { useSelector } from 'react-redux';
import { Breadcrumb } from 'react-bootstrap';
import { Link } from 'react-router-dom';
import { connect } from 'react-redux';
import { getPersistentQueryParams } from '../../utils/url-helper';
import PropTypes from 'prop-types';
import { withUrlHelper } from '../../withUrlHelper';

const Breadcrumbs = ({ config, locationQueryParams }) => (
const Breadcrumbs = ({ config, urlHelper }) => {
const location = useLocation();
const locationQueryParams = useSelector((state) => state.locationQueryParams);
const { getPersistentQueryParams } = urlHelper;

return (
<Breadcrumb>
{config.map((item, index) => {
const { href, label, active } = item || {};
Expand All @@ -17,24 +22,24 @@ const Breadcrumbs = ({ config, locationQueryParams }) => (
{active
? <span>{label}</span>
: <Link
to={(toLocation) => (
{
pathname: href,
search: locationQueryParams.search[href] || getPersistentQueryParams(toLocation)
})}>
to={{
pathname: href,
search: locationQueryParams.search[href] || getPersistentQueryParams(location)
}}>
{label}
</Link>}
</li>
);
})}
</Breadcrumb>
);
);
};

Breadcrumbs.propTypes = {
config: PropTypes.arrayOf(PropTypes.object),
locationQueryParams: PropTypes.object,
urlHelper: PropTypes.shape({
getPersistentQueryParams: PropTypes.func
}),
};

export default connect((state) => ({
locationQueryParams: state.locationQueryParams
}))(Breadcrumbs);
export default withUrlHelper(Breadcrumbs);
22 changes: 11 additions & 11 deletions app/src/js/components/Collections/add.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
import React, { useEffect, useState } from 'react';
import { useLocation } from 'react-router-dom';
import { useDispatch, useSelector } from 'react-redux';
import PropTypes from 'prop-types';
import { Helmet } from 'react-helmet';
import { connect } from 'react-redux';
import { withRouter } from 'react-router-dom';
import { createCollection, getSchema } from '../../actions';
import { getCollectionId, collectionHrefFromId } from '../../utils/format';
import { removeReadOnly } from '../FormSchema/schema';
import AddRaw from '../AddRaw/add-raw';
import withRouter from '../../withRouter';

const AddCollection = () => {
const dispatch = useDispatch();
const location = useLocation();

const collections = useSelector((state) => state.collections);
const schema = useSelector((state) => state.schema);

const AddCollection = ({ location = {}, collections, dispatch, schema }) => {
const [defaultValue, setDefaultValue] = useState({});
const { state: locationState } = location;
const { name, version } = locationState || {};
Expand Down Expand Up @@ -52,15 +59,8 @@ const AddCollection = ({ location = {}, collections, dispatch, schema }) => {
};

AddCollection.propTypes = {
location: PropTypes.object,
collections: PropTypes.object,
dispatch: PropTypes.func,
schema: PropTypes.object,
};

export default withRouter(
connect((state) => ({
collections: state.collections,
schema: state.schema,
}))(AddCollection)
);
export default withRouter(AddCollection);
2 changes: 1 addition & 1 deletion app/src/js/components/Collections/collection-header.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
lastUpdated,
collectionHrefFromNameVersion,
} from '../../utils/format';
import { getPersistentQueryParams } from '../../utils/url-helper';
import { getPersistentQueryParams } from '../../withUrlHelper';
import { strings } from '../locale';
import Breadcrumbs from '../Breadcrumbs/Breadcrumbs';

Expand Down
Loading