Skip to content

Commit

Permalink
refactor: custom post loading and add AppAuthenticatedPage (#3632)
Browse files Browse the repository at this point in the history
* Added post loading hook to appInitPage

* Removed custom post loading

* Changed custom post loading to cusotm post auth

* Adds AppAuthenticatedPage

* Uses AppAuthenticatedPage inside protected route
  • Loading branch information
lucaseduoli authored Aug 30, 2024
1 parent 387ea32 commit 3bef9aa
Show file tree
Hide file tree
Showing 3 changed files with 107 additions and 72 deletions.
16 changes: 16 additions & 0 deletions src/frontend/src/customization/hooks/use-custom-post-auth.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { UseRequestProcessor } from "@/controllers/API/services/request-processor";
import { useQueryFunctionType } from "@/types/api";

export const useCustomPostAuth: useQueryFunctionType<undefined, null> = (
options,
) => {
const { query } = UseRequestProcessor();

const getPostAuthFn = async () => {
return null;
};

const queryResult = query(["usePostAuth"], getPostAuthFn, options);

return queryResult;
};
8 changes: 8 additions & 0 deletions src/frontend/src/pages/AppAuthenticatedPage/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { useCustomPostAuth } from "@/customization/hooks/use-custom-post-auth";
import { Outlet } from "react-router-dom";

export function AppAuthenticatedPage() {
useCustomPostAuth();

return <Outlet />;
}
155 changes: 83 additions & 72 deletions src/frontend/src/routes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import ContextWrapper from "./contexts";
import { CustomNavigate } from "./customization/components/custom-navigate";
import { BASENAME } from "./customization/config-constants";
import { ENABLE_CUSTOM_PARAM } from "./customization/feature-flags";
import { AppAuthenticatedPage } from "./pages/AppAuthenticatedPage";
import { AppInitPage } from "./pages/AppInitPage";
import { AppWrapperPage } from "./pages/AppWrapperPage";
import { DashboardWrapperPage } from "./pages/DashboardWrapperPage";
Expand Down Expand Up @@ -57,102 +58,112 @@ const router = createBrowserRouter(
</ProtectedRoute>
}
>
<Route path="" element={<DashboardWrapperPage />}>
<Route path="" element={<HomePage />}>
<Route index element={<CustomNavigate replace to={"all"} />} />
<Route
path="flows/"
element={<MyCollectionComponent key="flows" type="flow" />}
>
<Route path="" element={<AppAuthenticatedPage />}>
<Route path="" element={<DashboardWrapperPage />}>
<Route path="" element={<HomePage />}>
<Route
path="folder/:folderId"
element={<MyCollectionComponent key="flows" type="flow" />}
index
element={<CustomNavigate replace to={"all"} />}
/>
</Route>
<Route
path="components/"
element={
<MyCollectionComponent key="components" type="component" />
}
>
<Route
path="folder/:folderId"
path="flows/"
element={<MyCollectionComponent key="flows" type="flow" />}
>
<Route
path="folder/:folderId"
element={
<MyCollectionComponent key="flows" type="flow" />
}
/>
</Route>
<Route
path="components/"
element={
<MyCollectionComponent
key="components"
type="component"
/>
}
/>
</Route>
<Route
path="all/"
element={<MyCollectionComponent key="all" type="all" />}
>
>
<Route
path="folder/:folderId"
element={
<MyCollectionComponent
key="components"
type="component"
/>
}
/>
</Route>
<Route
path="folder/:folderId"
path="all/"
element={<MyCollectionComponent key="all" type="all" />}
>
<Route
path="folder/:folderId"
element={<MyCollectionComponent key="all" type="all" />}
/>
</Route>
</Route>
<Route path="settings" element={<SettingsPage />}>
<Route
index
element={<CustomNavigate replace to={"general"} />}
/>
<Route
path="global-variables"
element={<GlobalVariablesPage />}
/>
<Route path="api-keys" element={<ApiKeysPage />} />
<Route
path="general/:scrollId?"
element={
<AuthSettingsGuard>
<GeneralPage />
</AuthSettingsGuard>
}
/>
<Route path="shortcuts" element={<ShortcutsPage />} />
<Route path="messages" element={<MessagesPage />} />
</Route>
</Route>
<Route path="settings" element={<SettingsPage />}>
<Route
index
element={<CustomNavigate replace to={"general"} />}
path="store"
element={
<StoreGuard>
<StorePage />
</StoreGuard>
}
/>
<Route
path="global-variables"
element={<GlobalVariablesPage />}
path="store/:id/"
element={
<StoreGuard>
<StorePage />
</StoreGuard>
}
/>
<Route path="api-keys" element={<ApiKeysPage />} />
<Route path="account">
<Route path="delete" element={<DeleteAccountPage />}></Route>
</Route>
<Route
path="general/:scrollId?"
path="admin"
element={
<AuthSettingsGuard>
<GeneralPage />
</AuthSettingsGuard>
<ProtectedAdminRoute>
<AdminPage />
</ProtectedAdminRoute>
}
/>
<Route path="shortcuts" element={<ShortcutsPage />} />
<Route path="messages" element={<MessagesPage />} />
</Route>
<Route
path="store"
element={
<StoreGuard>
<StorePage />
</StoreGuard>
}
/>
<Route
path="store/:id/"
element={
<StoreGuard>
<StorePage />
</StoreGuard>
}
/>
<Route path="account">
<Route path="delete" element={<DeleteAccountPage />}></Route>
<Route path="flow/:id/">
<Route path="" element={<DashboardWrapperPage />}>
<Route path="folder/:folderId/" element={<FlowPage />} />
<Route path="" element={<FlowPage />} />
</Route>
<Route path="view" element={<ViewPage />} />
</Route>
<Route
path="admin"
element={
<ProtectedAdminRoute>
<AdminPage />
</ProtectedAdminRoute>
}
/>
</Route>
<Route path="flow/:id/">
<Route path="" element={<DashboardWrapperPage />}>
<Route path="folder/:folderId/" element={<FlowPage />} />
<Route path="" element={<FlowPage />} />
<Route path="playground/:id/">
<Route path="" element={<PlaygroundPage />} />
</Route>
<Route path="view" element={<ViewPage />} />
</Route>
<Route path="playground/:id/">
<Route path="" element={<PlaygroundPage />} />
</Route>
</Route>
<Route
Expand Down

0 comments on commit 3bef9aa

Please # to comment.