Skip to content
This repository has been archived by the owner on May 19, 2020. It is now read-only.

Commit

Permalink
Remove comments/old code, default show <Loading/>
Browse files Browse the repository at this point in the history
  • Loading branch information
el-mapache committed Jul 7, 2017
1 parent ec8a4be commit 4b495e1
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 34 deletions.
2 changes: 1 addition & 1 deletion static_src/components/header.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export default class Header extends React.Component {
<header className={ this.styler('header', 'header-no_sidebar', 'test-header') }>
<div className={ this.styler('header-wrap') }>
<div className={ this.styler('header-title') }>
<a href="/" className={ this.styler('logo') } title="Home">
<a href="/#/" className={ this.styler('logo') } title="Home">
<svg className={ this.styler('logo-img') }>
<use
xlinkHref={ this.getImagePath('logo-dashboard') }
Expand Down
1 change: 0 additions & 1 deletion static_src/components/main_container.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ function stateSetter() {

class App extends React.Component {
constructor(props) {
console.log(style, overrideStyle)
super(props);
this.styler = createStyler(style, overrideStyle);
this.state = stateSetter();;
Expand Down
6 changes: 6 additions & 0 deletions static_src/components/not_found.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import React from 'react';

const NotFound = () =>
<h1>Not Found</h1>

export default NotFound;
9 changes: 5 additions & 4 deletions static_src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import routes, { checkAuth, clearErrors, notFound } from './routes';

import RouterStore from './stores/router_store.js';
import MainContainer from './components/main_container.jsx';
import Loading from './components/loading.jsx';

const meta = document.querySelector('meta[name="gorilla.csrf.Token"]');

Expand Down Expand Up @@ -51,12 +52,12 @@ class RouteHandler extends React.Component {

render() {
const { component: Component, props } = this.state;
return Component ? <Component { ...props } /> : null;
return Component ? <Component { ...props } /> : <Loading />;
}
}

const cRouter = {
run(routes) {
run(routes, renderEl) {
const router = new Router(routes);
router.configure({
async: true,
Expand All @@ -69,10 +70,10 @@ const cRouter = {
ReactDOM.render(
<MainContainer>
<RouteHandler />
</MainContainer>, document.querySelector('.js-app'));
</MainContainer>, renderEl);

router.init('/');
}
};

cRouter.run(routes);
cRouter.run(routes, document.querySelector('.js-app'));
42 changes: 14 additions & 28 deletions static_src/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import Login from './components/login.jsx';
import loginActions from './actions/login_actions';
import LoginStore from './stores/login_store';
import MainContainer from './components/main_container.jsx';
import NotFound from './components/not_found.jsx';
import orgActions from './actions/org_actions.js';
import Overview from './components/overview_container.jsx';
import OrgContainer from './components/org_container.jsx';
Expand All @@ -33,7 +34,7 @@ const mainEl = document.querySelector('.js-app');
const MAX_OVERVIEW_SPACES = 10;

export function login(next) {
ReactDOM.render(<MainContainer><Login /></MainContainer>, mainEl);
routerActions.navigate(Login);
}

export function overview(next) {
Expand All @@ -55,11 +56,8 @@ export function overview(next) {

return Promise.all(fetches);
})
.then(pageActions.loadSuccess, pageActions.loadError);

ReactDOM.render(<MainContainer>
<Overview />
</MainContainer>, mainEl);
.then(pageActions.loadSuccess, pageActions.loadError)
.then(() => routerActions.navigate(Overview));
}

export function org(orgGuid, next) {
Expand All @@ -73,10 +71,7 @@ export function org(orgGuid, next) {
userActions.changeCurrentlyViewedType('org_users');
userActions.fetchOrgUsers(orgGuid);
userActions.fetchOrgUserRoles(orgGuid);
ReactDOM.render(
<MainContainer>
<OrgContainer />
</MainContainer>, mainEl);
routerActions.navigate(OrgContainer);
}

export function space(orgGuid, spaceGuid, next) {
Expand All @@ -94,13 +89,6 @@ export function space(orgGuid, spaceGuid, next) {
orgActions.fetch(orgGuid);
serviceActions.fetchAllServices(orgGuid);
routerActions.navigate(SpaceContainer, { currentPage: 'apps' });
//
// ReactDOM.render(
// <MainContainer>
// <SpaceContainer
// currentPage="apps"
// />
// </MainContainer>, mainEl);
}

export function app(orgGuid, spaceGuid, appGuid, next) {
Expand All @@ -123,17 +111,11 @@ export function app(orgGuid, spaceGuid, appGuid, next) {
serviceActions.fetchAllInstances(spaceGuid);
serviceActions.fetchServiceBindings();
routerActions.navigate(AppContainer);
// ReactDOM.render(
// <MainContainer>
// <AppContainer />
// </MainContainer>, mainEl);
}

export function checkAuth(...args) {
const next = args.pop();

console.log(next)

// These may or may not be set depending on route
const [orgGuid, spaceGuid] = args;

Expand Down Expand Up @@ -167,9 +149,14 @@ export function checkAuth(...args) {
// Just in case something goes wrong, don't leave the user hanging. Show
// a delayed loading indicator to give them a hint. Hopefully the
// redirect is quick and they never see the loader.
ReactDOM.render(
<Loading text="Redirecting to login" loadingDelayMS={ 3000 } style="inline" />
, mainEl);
// ReactDOM.render(
// <Loading text="Redirecting to login" loadingDelayMS={ 3000 } style="inline" />
// , mainEl);
routerActions.navigate(Loading, {
text: 'Redirecting to login',
loadingDelayMS: 3000,
style: 'inline'
});

// Stop the routing
next(false);
Expand Down Expand Up @@ -197,8 +184,7 @@ export function notFound(next) {
orgActions.changeCurrentOrg();
spaceActions.changeCurrentSpace();
appActions.changeCurrentApp();

ReactDOM.render(<h1>Not Found</h1>, mainEl);
routerActions.navigate(NotFound);
}

const routes = {
Expand Down

0 comments on commit 4b495e1

Please sign in to comment.