From ef1c3710401e4c09118dd20b364e120329cd5d69 Mon Sep 17 00:00:00 2001 From: Austin Akers Date: Mon, 16 Dec 2024 13:42:05 -0800 Subject: [PATCH 1/4] created auth layout for public auth routes --- src/components/auth/AuthLayout.jsx | 62 +++++++++++++++++++++++++ src/components/layouts/App.js | 73 ++++-------------------------- 2 files changed, 71 insertions(+), 64 deletions(-) create mode 100644 src/components/auth/AuthLayout.jsx diff --git a/src/components/auth/AuthLayout.jsx b/src/components/auth/AuthLayout.jsx new file mode 100644 index 000000000..ce8f0025f --- /dev/null +++ b/src/components/auth/AuthLayout.jsx @@ -0,0 +1,62 @@ +import { Col, Container, Row } from 'reactstrap'; + +function AuthLayout({ children }) { + return ( + + + +
+

HarperDB Studio

+ Manage all your HarperDB instances. +
    +
  • +

    Manage All Instances

    + Set access, cluster, monitor, and more. +
  • +
  • +

    Embedded API Server

    + HarperDB components give you unlimited application flexibility. +
  • +
  • +

    Fully Managed Cloud & 5G Instances

    + Go from zero to code in minutes. +
  • +
  • +

    Deploy Anywhere

    + +
  • +
+
+ + {children} +
+
+ ); +} + +export default AuthLayout; diff --git a/src/components/layouts/App.js b/src/components/layouts/App.js index 3125720cb..48aaa4a76 100644 --- a/src/components/layouts/App.js +++ b/src/components/layouts/App.js @@ -8,7 +8,6 @@ import useInterval from 'use-interval'; import { positions, useAlert } from 'react-alert'; import { ErrorBoundary } from 'react-error-boundary'; import queryString from 'query-string'; -import { Col, Container, Row } from 'reactstrap'; import appState from '../../functions/state/appState'; import usePersistedUser from '../../functions/state/persistedUser'; @@ -28,6 +27,7 @@ import init from '../../functions/app/init'; import refreshUser from '../../functions/app/refreshUser'; import changeFavIcon from '../../functions/app/changeFavIcon'; import getAkamaiRegions from '../../functions/api/lms/getAkamaiRegions'; +import AuthLayout from '../auth/AuthLayout'; const TopNav = lazy(() => import(/* webpackChunkName: "topnav" */ '../TopNav')); const SignUp = lazy(() => import(/* webpackChunkName: "signUp" */ '../auth/SignUp')); @@ -169,69 +169,14 @@ function App() {
}> - - - -
-

HarperDB Studio

- Manage all your HarperDB instances. -
    -
  • -

    Manage All Instances

    - Set access, cluster, monitor, and more. -
  • -
  • -

    Embedded API Server

    - - HarperDB components give you unlimited application flexibility. - -
  • -
  • -

    Fully Managed Cloud & 5G Instances

    - Go from zero to code in minutes. -
  • -
  • -

    Deploy Anywhere

    - -
  • -
-
- - - - } path="/" /> - : } path="/sign-up" /> - : } path="/reset-password" /> - } /> - - -
-
+ + + } path="/" /> + : } path="/sign-up" /> + : } path="/reset-password" /> + } /> + +
From e98f42d02ec845c9d3a347479e6254650dbef8e5 Mon Sep 17 00:00:00 2001 From: Austin Akers Date: Mon, 16 Dec 2024 14:02:05 -0800 Subject: [PATCH 2/4] added protected routes for dashboard routes --- src/components/layouts/App.js | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/src/components/layouts/App.js b/src/components/layouts/App.js index 48aaa4a76..391ab9c05 100644 --- a/src/components/layouts/App.js +++ b/src/components/layouts/App.js @@ -53,6 +53,13 @@ function ValidatedRoute(auth) { return ; } +function PrivateRoute(auth) { + if (auth.auth.user_id) { + return ; + } + return ; +} + function App() { const canonicalUrl = document.querySelector('link[rel="canonical"]'); const navigate = useNavigate(); @@ -152,15 +159,18 @@ function App() { > {/* can we put instance routes in here, each in a suspense tag (since they're lazily loaded) */} - : } path="/update-password" /> - : } path="/profile/*" /> - : }> - } path="/o/:customer_id/i/:compute_stack_id/*" /> - } path="/o/:customer_id/instances/:action?/:purchaseStep?" /> - } path="/o/:customer_id/*" /> + {/* create protected routes */} + }> + : } path="/update-password" /> + : } path="/profile/*" /> + : }> + } path="/o/:customer_id/i/:compute_stack_id/*" /> + } path="/o/:customer_id/instances/:action?/:purchaseStep?" /> + } path="/o/:customer_id/*" /> + + : } path="/:list?/:action?" /> + } /> - : } path="/:list?/:action?" /> - } /> From 063f1073df5a6f38615468dc953162ebea4a4a36 Mon Sep 17 00:00:00 2001 From: Austin Akers Date: Mon, 16 Dec 2024 21:37:16 -0800 Subject: [PATCH 3/4] simplified App.js layouts and routing --- src/components/auth/AuthLayout.jsx | 5 ++- src/components/layouts/App.js | 64 ++++++++++++------------------ 2 files changed, 29 insertions(+), 40 deletions(-) diff --git a/src/components/auth/AuthLayout.jsx b/src/components/auth/AuthLayout.jsx index ce8f0025f..5516514b2 100644 --- a/src/components/auth/AuthLayout.jsx +++ b/src/components/auth/AuthLayout.jsx @@ -1,3 +1,4 @@ +import { Outlet } from 'react-router'; import { Col, Container, Row } from 'reactstrap'; function AuthLayout({ children }) { @@ -53,7 +54,9 @@ function AuthLayout({ children }) { - {children} + + + ); diff --git a/src/components/layouts/App.js b/src/components/layouts/App.js index 391ab9c05..accded7e0 100644 --- a/src/components/layouts/App.js +++ b/src/components/layouts/App.js @@ -57,7 +57,7 @@ function PrivateRoute(auth) { if (auth.auth.user_id) { return ; } - return ; + return ; } function App() { @@ -145,51 +145,37 @@ function App() { {fetchingUser ? (
- +
- ) : loggedIn ? ( -
- - - - - } - > - {/* can we put instance routes in here, each in a suspense tag (since they're lazily loaded) */} + ) : ( +
+ + }> - {/* create protected routes */} - }> - : } path="/update-password" /> - : } path="/profile/*" /> - : }> - } path="/o/:customer_id/i/:compute_stack_id/*" /> - } path="/o/:customer_id/instances/:action?/:purchaseStep?" /> - } path="/o/:customer_id/*" /> + {loggedIn ? ( + <> + : } path="/update-password" /> + : } path="/profile/*" /> + : }> + } path="/o/:customer_id/i/:compute_stack_id/*" /> + } path="/o/:customer_id/instances/:action?/:purchaseStep?" /> + } path="/o/:customer_id/*" /> + + : } path="/:list?/:action?" /> + } /> + + ) : ( + }> + } path="/" /> + : } path="/sign-up" /> + : } path="/reset-password" /> + } /> - : } path="/:list?/:action?" /> - } /> - + )}
- ) : ( -
- - }> - - - } path="/" /> - : } path="/sign-up" /> - : } path="/reset-password" /> - } /> - - - - -
)}
From 5df7c0e37e3ed36cbc5ad9864f6d8dc5be5affea Mon Sep 17 00:00:00 2001 From: Austin Akers Date: Mon, 16 Dec 2024 21:38:37 -0800 Subject: [PATCH 4/4] removed dead code --- src/components/layouts/App.js | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/components/layouts/App.js b/src/components/layouts/App.js index accded7e0..749717fed 100644 --- a/src/components/layouts/App.js +++ b/src/components/layouts/App.js @@ -53,13 +53,6 @@ function ValidatedRoute(auth) { return ; } -function PrivateRoute(auth) { - if (auth.auth.user_id) { - return ; - } - return ; -} - function App() { const canonicalUrl = document.querySelector('link[rel="canonical"]'); const navigate = useNavigate();