PromucFlow_constructor/app/client/src/pages/common/AppHeader.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

48 lines
1.4 KiB
TypeScript

import React from "react";
import { connect } from "react-redux";
import { getCurrentUser } from "actions/authActions";
import PageHeader from "pages/common/PageHeader";
import LoginHeader from "pages/common/LoginHeader";
import { Route, Switch } from "react-router";
import {
APP_VIEW_URL,
BASE_URL,
BUILDER_URL,
USER_AUTH_URL,
} from "constants/routes";
import { withRouter, RouteComponentProps } from "react-router";
type Props = { getCurrentUser: () => void } & RouteComponentProps;
const NoRender = () => {
return null;
};
/*
* App header is rendered as the first thing in the app. This kicks off the auth check
* Currently each path has rendered their own header but we can move that here to have
* a consistent header experience
*/
class AppHeader extends React.Component<Props, any> {
componentDidMount() {
this.props.getCurrentUser();
}
render() {
return (
<React.Fragment>
<Switch>
<Route path={BUILDER_URL} component={NoRender} />
<Route path={APP_VIEW_URL} component={NoRender} />
<Route path={USER_AUTH_URL} component={LoginHeader} />
<Route path={BASE_URL} component={PageHeader} />
</Switch>
</React.Fragment>
);
}
}
const mapStateToProps = (dispatch: any) => ({
getCurrentUser: () => dispatch(getCurrentUser()),
});
export default withRouter(connect(null, mapStateToProps)(AppHeader));