This repository has been archived by the owner on May 27, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19 from andymikulski/multiple-app-entries
#18: Multiple app entry points
- Loading branch information
Showing
14 changed files
with
272 additions
and
119 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
/* @flow */ | ||
|
||
import React, { Component } from 'react'; | ||
|
||
import 'console/App.less'; | ||
|
||
import LoginPage from './LoginPage'; | ||
import Normandy from 'normandy/App'; | ||
import { BrowserRouter, NavLink, Link } from 'react-router-dom'; | ||
import { Route, Redirect } from 'react-router'; | ||
|
||
import { Alert, Layout } from 'antd'; | ||
const { Header, Content } = Layout; | ||
|
||
const Homepage = props => ( | ||
<div> | ||
<h3>Welcome {props.authToken ? 'back' : 'home'}!</h3> | ||
{props.authToken ? ( | ||
<p> | ||
Go to the <Link to="/normandy">Normandy page</Link>. | ||
</p> | ||
) : ( | ||
<p> | ||
You are not logged in! Go to the <Link to="/login">login page</Link>. | ||
</p> | ||
)} | ||
</div> | ||
); | ||
|
||
type AppProps = {}; | ||
type AppState = { | ||
authToken: ?string, | ||
username: ?string, | ||
}; | ||
|
||
class App extends Component<AppProps, AppState> { | ||
state = { | ||
authToken: null, | ||
username: null, | ||
}; | ||
|
||
onUserLogin = (username: string, authToken: string) => { | ||
this.setState({ | ||
username, | ||
authToken, | ||
}); | ||
}; | ||
|
||
render() { | ||
return ( | ||
<BrowserRouter> | ||
<Layout className="app"> | ||
<Header className="app-header"> | ||
<h1>Delivery Console</h1> | ||
|
||
<NavLink exact to="/"> | ||
Home | ||
</NavLink> | ||
<NavLink to="/login">Login</NavLink> | ||
<NavLink exact to="/normandy"> | ||
Normandy | ||
</NavLink> | ||
|
||
{this.state.username && ( | ||
<Alert | ||
style={{ marginLeft: '3em' }} | ||
type="info" | ||
showIcon | ||
message={`You are logged in as ${this.state.username}.`} | ||
/> | ||
)} | ||
</Header> | ||
<Content className="app-content"> | ||
{/* Homepage */} | ||
<Route | ||
exact | ||
path="/" | ||
component={() => <Homepage authToken={this.state.authToken} />} | ||
/> | ||
|
||
{/* Login */} | ||
<Route | ||
exact | ||
path="/login/" | ||
component={() => | ||
this.state.username ? ( | ||
<Redirect to="/" /> | ||
) : ( | ||
<LoginPage onAuth={this.onUserLogin} /> | ||
) | ||
} | ||
/> | ||
|
||
{/* Normandy App */} | ||
<Route | ||
exact | ||
path="/normandy/" | ||
component={() => | ||
this.state.username ? ( | ||
<Normandy authToken={this.state.authToken} /> | ||
) : ( | ||
<Redirect to="/login/?next=/normandy/" /> | ||
) | ||
} | ||
/> | ||
</Content> | ||
</Layout> | ||
</BrowserRouter> | ||
); | ||
} | ||
} | ||
|
||
export default App; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,116 +1,5 @@ | ||
/* @flow */ | ||
import React from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
import DevConsoleApp from './App'; | ||
|
||
import React, { Component } from 'react'; | ||
|
||
import 'console/App.less'; | ||
|
||
import LoginPage from './LoginPage'; | ||
import { BrowserRouter, NavLink, Link } from 'react-router-dom'; | ||
import { Route, Redirect } from 'react-router'; | ||
|
||
import { Alert, Layout } from 'antd'; | ||
const { Header, Content } = Layout; | ||
|
||
const Homepage = props => ( | ||
<div> | ||
<h3>Welcome {props.authToken ? 'back' : 'home'}!</h3> | ||
{props.authToken ? ( | ||
<p> | ||
Go to the <Link to="/normandy">Normandy page</Link>. | ||
</p> | ||
) : ( | ||
<p> | ||
You are not logged in! Go to the <Link to="/login">login page</Link>. | ||
</p> | ||
)} | ||
</div> | ||
); | ||
|
||
const MockNormandy = props => ( | ||
<div>Normandy with auth token {props.authToken}</div> | ||
); | ||
|
||
type AppProps = {}; | ||
type AppState = { | ||
authToken: ?string, | ||
username: ?string, | ||
}; | ||
|
||
class App extends Component<AppProps, AppState> { | ||
state = { | ||
authToken: null, | ||
username: null, | ||
}; | ||
|
||
onUserLogin = (username: string, authToken: string) => { | ||
this.setState({ | ||
username, | ||
authToken, | ||
}); | ||
}; | ||
|
||
render() { | ||
return ( | ||
<BrowserRouter> | ||
<Layout className="app"> | ||
<Header className="app-header"> | ||
<h1>Delivery Console</h1> | ||
|
||
<NavLink exact to="/"> | ||
Home | ||
</NavLink> | ||
<NavLink to="/login">Login</NavLink> | ||
<NavLink exact to="/normandy"> | ||
Normandy | ||
</NavLink> | ||
|
||
{this.state.username && ( | ||
<Alert | ||
style={{ marginLeft: '3em' }} | ||
type="info" | ||
showIcon | ||
message={`You are logged in as ${this.state.username}.`} | ||
/> | ||
)} | ||
</Header> | ||
<Content className="app-content"> | ||
{/* Homepage */} | ||
<Route | ||
exact | ||
path="/" | ||
component={() => <Homepage authToken={this.state.authToken} />} | ||
/> | ||
|
||
{/* Login */} | ||
<Route | ||
exact | ||
path="/login/" | ||
component={() => | ||
this.state.username ? ( | ||
<Redirect to="/" /> | ||
) : ( | ||
<LoginPage onAuth={this.onUserLogin} /> | ||
) | ||
} | ||
/> | ||
|
||
{/* Normandy App */} | ||
<Route | ||
exact | ||
path="/normandy/" | ||
component={() => | ||
this.state.username ? ( | ||
<MockNormandy authToken={this.state.authToken} /> | ||
) : ( | ||
<Redirect to="/login/?next=/normandy/" /> | ||
) | ||
} | ||
/> | ||
</Content> | ||
</Layout> | ||
</BrowserRouter> | ||
); | ||
} | ||
} | ||
|
||
export default App; | ||
ReactDOM.render(<DevConsoleApp />, document.getElementById('root')); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import React from "react"; | ||
import ReactDOM from "react-dom"; | ||
import DevConsoleApp from "./console"; | ||
import DevConsoleApp from "./console/App"; | ||
|
||
ReactDOM.render(<DevConsoleApp />, document.getElementById("root")); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
.App { | ||
text-align: center; | ||
} | ||
|
||
.App-logo { | ||
animation: App-logo-spin infinite 20s linear; | ||
height: 80px; | ||
} | ||
|
||
.App-header { | ||
background-color: #222; | ||
height: 150px; | ||
padding: 20px; | ||
color: white; | ||
} | ||
|
||
.App-title { | ||
font-size: 1.5em; | ||
} | ||
|
||
.App-intro { | ||
font-size: large; | ||
} | ||
|
||
@keyframes App-logo-spin { | ||
from { transform: rotate(0deg); } | ||
to { transform: rotate(360deg); } | ||
} |
Oops, something went wrong.