Add a “version select” to the bridged app (#449)
Summary: The bridge now lets you select any version of the app that you want, as long as that’s V1, because that’s the only version that exists. We’ll add a V3 version shortly. This implements Step 2 of the plan described in #448. Test Plan: In `yarn start` and `node bin/sourcecred.js start`, note that navigating to `/` redirects to `/v1`, and that the cred explorer works. wchargin-branch: bridge-select
This commit is contained in:
parent
ca5346b524
commit
1d49ec87dc
|
@ -1,6 +1,12 @@
|
||||||
// @flow
|
// @flow
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import ReactDOM from "react-dom";
|
import ReactDOM from "react-dom";
|
||||||
|
import {
|
||||||
|
BrowserRouter as Router,
|
||||||
|
NavLink,
|
||||||
|
Redirect,
|
||||||
|
Route,
|
||||||
|
} from "react-router-dom";
|
||||||
import "./index.css";
|
import "./index.css";
|
||||||
import V1App from "../../v1/app/App";
|
import V1App from "../../v1/app/App";
|
||||||
import registerServiceWorker from "./registerServiceWorker";
|
import registerServiceWorker from "./registerServiceWorker";
|
||||||
|
@ -9,5 +15,20 @@ const root = document.getElementById("root");
|
||||||
if (root == null) {
|
if (root == null) {
|
||||||
throw new Error("Unable to find root element!");
|
throw new Error("Unable to find root element!");
|
||||||
}
|
}
|
||||||
ReactDOM.render(<V1App />, root);
|
ReactDOM.render(
|
||||||
|
<Router>
|
||||||
|
<React.Fragment>
|
||||||
|
<strong>Select version:</strong>
|
||||||
|
<ul>
|
||||||
|
<li>
|
||||||
|
<NavLink to="/v1">V1</NavLink>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
<Route exact path="/" render={() => <Redirect to="/v1" />} />
|
||||||
|
<hr />
|
||||||
|
<Route path="/v1" component={V1App} />
|
||||||
|
</React.Fragment>
|
||||||
|
</Router>,
|
||||||
|
root
|
||||||
|
);
|
||||||
registerServiceWorker();
|
registerServiceWorker();
|
||||||
|
|
|
@ -1,20 +1,20 @@
|
||||||
// @flow
|
// @flow
|
||||||
|
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import {BrowserRouter as Router, Route, NavLink} from "react-router-dom";
|
import {Route, NavLink, type Match} from "react-router-dom";
|
||||||
|
|
||||||
import CredExplorer from "./credExplorer/App";
|
import CredExplorer from "./credExplorer/App";
|
||||||
|
|
||||||
export default class App extends React.Component<{}> {
|
export default class App extends React.Component<{match: Match}> {
|
||||||
render() {
|
render() {
|
||||||
const CRED_EXPLORER_ROUTE = "/explorer";
|
const {match} = this.props;
|
||||||
|
const CRED_EXPLORER_ROUTE = match.url + "/explorer";
|
||||||
return (
|
return (
|
||||||
<Router>
|
|
||||||
<div>
|
<div>
|
||||||
<nav>
|
<nav>
|
||||||
<ul>
|
<ul>
|
||||||
<li>
|
<li>
|
||||||
<NavLink to="/">Home</NavLink>
|
<NavLink to={match.url}>Home</NavLink>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<NavLink to={CRED_EXPLORER_ROUTE}>Cred Explorer</NavLink>
|
<NavLink to={CRED_EXPLORER_ROUTE}>Cred Explorer</NavLink>
|
||||||
|
@ -23,10 +23,9 @@ export default class App extends React.Component<{}> {
|
||||||
</nav>
|
</nav>
|
||||||
|
|
||||||
<hr />
|
<hr />
|
||||||
<Route exact path="/" component={Home} />
|
<Route exact path={match.url} component={Home} />
|
||||||
<Route path={CRED_EXPLORER_ROUTE} component={CredExplorer} />
|
<Route path={CRED_EXPLORER_ROUTE} component={CredExplorer} />
|
||||||
</div>
|
</div>
|
||||||
</Router>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue