homepage: add prototypes listing (#983)

Test Plan:
Apply the following patch:

```diff
diff --git a/src/homepage/routeData.js b/src/homepage/routeData.js
index 32d3eb65..aac7fc9a 100644
--- a/src/homepage/routeData.js
+++ b/src/homepage/routeData.js
@@ -38,7 +38,10 @@ const routeData /*: $ReadOnlyArray<RouteDatum> */ = [
     path: "/prototypes/",
     contents: {
       type: "PAGE",
-      component: () => require("./PrototypesPage").default([]),
+      component: () =>
+        require("./PrototypesPage").default([
+          {owner: "sourcecred", name: "example-github"},
+        ]),
     },
     title: "SourceCred prototypes",
     navTitle: null, // for now
```

Then, load <http://localhost:8080/prototypes/> and see that there is an
entry in the list, and that it links to
<http://localhost:8080/prototypes/sourcecred/example-github/>. Note that
clicking the link raises a console error because there is no such route.

wchargin-branch: homepage-prototypes-page
This commit is contained in:
William Chargin 2018-11-01 13:30:36 -07:00 committed by GitHub
parent 415210b772
commit 665bb67e33
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 48 additions and 0 deletions

View File

@ -0,0 +1,39 @@
// @flow
import stringify from "json-stable-stringify";
import React, {type ComponentType} from "react";
import type {RepoIdRegistry} from "../explorer/repoIdRegistry";
import Link from "../webutil/Link";
import type {Assets} from "../webutil/assets";
export default function makePrototypesPage(
registry: RepoIdRegistry
): ComponentType<{|+assets: Assets|}> {
return class PrototypesPage extends React.Component<{|+assets: Assets|}> {
render() {
return (
<div
style={{
maxWidth: 900,
margin: "0 auto",
marginBottom: 200,
padding: "0 10px",
lineHeight: 1.5,
}}
>
<p>Select a project:</p>
<ul>
{registry.map((x) => (
<li key={stringify(x)}>
<Link to={`/prototypes/${x.owner}/${x.name}/`}>
{`${x.owner}/${x.name}`}
</Link>
</li>
))}
</ul>
</div>
);
}
};
}

View File

@ -34,6 +34,15 @@ const routeData /*: $ReadOnlyArray<RouteDatum> */ = [
title: "SourceCred", title: "SourceCred",
navTitle: "Home", navTitle: "Home",
}, },
{
path: "/prototypes/",
contents: {
type: "PAGE",
component: () => require("./PrototypesPage").default([]),
},
title: "SourceCred prototypes",
navTitle: null, // for now
},
{ {
path: "/prototype/", path: "/prototype/",
contents: { contents: {