PromucFlow_constructor/app/client/src/AppRouter.tsx
Hetu Nandu a29dccbaf0
First time page load performance (#144)
* WIP

* Chunk names

* Add auth call

* add auth

* WIP

* Auth management setup

* fix a test

* fix cypress machine count

* some more changes

* fix header link

* check for auth

* fix import

* fix imports

* Use auth class

* WIP

* Better loading

* Remove unused

* Remove qs

* Auth loader

* Redirect for login

* Third part auth

* 404 redirects

* 404 page handling

* Adding custom docker image for performance fixes

* Correcting the workflow to get package step to run

* Clean up

* lazy auth load

* remove assertions from delete app and logout calls

* remove github workflow changes

* roll back lazy auth

* Error handling

* test editor chunk suspense

* Show header in editor before initialization

* Changes for app view

* Login header fixes

* Loader fixes

* Fix base login routes

Co-authored-by: Arpit Mohan <arpit@appsmith.com>
2020-08-03 19:48:48 +05:30

100 lines
2.8 KiB
TypeScript

import React, { Suspense } from "react";
import history from "utils/history";
import AppHeader from "pages/common/AppHeader";
import { Redirect, Router, Switch } from "react-router-dom";
import AppRoute from "pages/common/AppRoute";
import {
APP_VIEW_URL,
APPLICATIONS_URL,
AUTH_LOGIN_URL,
BASE_LOGIN_URL,
BASE_SIGNUP_URL,
BASE_URL,
BUILDER_URL,
ORG_URL,
PAGE_NOT_FOUND_URL,
SIGN_UP_URL,
USER_AUTH_URL,
USERS_URL,
} from "constants/routes";
import OrganizationLoader from "pages/organization/loader";
import ApplicationListLoader from "pages/Applications/loader";
import EditorLoader from "pages/Editor/loader";
import AppViewerLoader from "pages/AppViewer/loader";
import LandingScreen from "./LandingScreen";
import UserAuth from "pages/UserAuth";
import Users from "pages/users";
import PageNotFound from "pages/common/PageNotFound";
import Loader from "pages/common/Loader";
const loadingIndicator = <Loader />;
class AppRouter extends React.Component<any, any> {
render() {
return (
<Router history={history}>
<Suspense fallback={loadingIndicator}>
<AppHeader />
<Switch>
<AppRoute
exact
path={BASE_URL}
component={LandingScreen}
name={"App"}
/>
<Redirect exact from={BASE_LOGIN_URL} to={AUTH_LOGIN_URL} />
<Redirect exact from={BASE_SIGNUP_URL} to={SIGN_UP_URL} />
<AppRoute
path={ORG_URL}
component={OrganizationLoader}
name={"Organisation"}
routeProtected
/>
<AppRoute
exact
path={USERS_URL}
component={Users}
name={"Users"}
routeProtected
/>
<AppRoute
path={USER_AUTH_URL}
component={UserAuth}
name={"UserAuth"}
/>
<AppRoute
exact
path={APPLICATIONS_URL}
component={ApplicationListLoader}
name={"Home"}
routeProtected
/>
<AppRoute
path={BUILDER_URL}
component={EditorLoader}
name={"Editor"}
routeProtected
/>
<AppRoute
path={APP_VIEW_URL}
component={AppViewerLoader}
name={"AppViewer"}
routeProtected
logDisable
/>
<AppRoute
exact
path={PAGE_NOT_FOUND_URL}
component={PageNotFound}
name={"PageNotFound"}
/>
<AppRoute component={PageNotFound} name={"PageNotFound"} />
</Switch>
</Suspense>
</Router>
);
}
}
export default AppRouter;