From 1d49ec87dc82c58b52801847c8d7ac98c55ab90d Mon Sep 17 00:00:00 2001 From: William Chargin Date: Fri, 29 Jun 2018 13:13:57 -0700 Subject: [PATCH] =?UTF-8?q?Add=20a=20=E2=80=9Cversion=20select=E2=80=9D=20?= =?UTF-8?q?to=20the=20bridged=20app=20(#449)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- src/bridge/app/index.js | 23 ++++++++++++++++++++++- src/v1/app/App.js | 39 +++++++++++++++++++-------------------- 2 files changed, 41 insertions(+), 21 deletions(-) diff --git a/src/bridge/app/index.js b/src/bridge/app/index.js index 379e289..2260d5d 100644 --- a/src/bridge/app/index.js +++ b/src/bridge/app/index.js @@ -1,6 +1,12 @@ // @flow import React from "react"; import ReactDOM from "react-dom"; +import { + BrowserRouter as Router, + NavLink, + Redirect, + Route, +} from "react-router-dom"; import "./index.css"; import V1App from "../../v1/app/App"; import registerServiceWorker from "./registerServiceWorker"; @@ -9,5 +15,20 @@ const root = document.getElementById("root"); if (root == null) { throw new Error("Unable to find root element!"); } -ReactDOM.render(, root); +ReactDOM.render( + + + Select version: +
    +
  • + V1 +
  • +
+ } /> +
+ +
+
, + root +); registerServiceWorker(); diff --git a/src/v1/app/App.js b/src/v1/app/App.js index 8bf062d..3c68192 100644 --- a/src/v1/app/App.js +++ b/src/v1/app/App.js @@ -1,32 +1,31 @@ // @flow 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"; -export default class App extends React.Component<{}> { +export default class App extends React.Component<{match: Match}> { render() { - const CRED_EXPLORER_ROUTE = "/explorer"; + const {match} = this.props; + const CRED_EXPLORER_ROUTE = match.url + "/explorer"; return ( - -
- +
+ -
- - -
- +
+ + +
); } }