Move plugin choice from explorer to homepage (#979)

The explorer no longer ships with a set of default plugins. (This made
an inappropriate dependency from explorer/ to plugins/, and complicated
explorer's contract as a generic component.) Instead, the homepage
module is responsible for choosing the plugins to display on the
homepage.

Test plan: `yarn test --full` passes, and `yarn start` reveals a
functioning homepage and prototype.
This commit is contained in:
Dandelion Mané 2018-11-01 11:39:07 -07:00 committed by GitHub
parent de861d104a
commit 244c01d764
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 33 additions and 17 deletions

View File

@ -8,7 +8,6 @@ import CheckedLocalStore from "../webutil/checkedLocalStore";
import BrowserLocalStore from "../webutil/browserLocalStore";
import Link from "../webutil/Link";
import {defaultStaticAdapters} from "./adapters/defaultPlugins";
import {PagerankTable} from "./pagerankTable/Table";
import type {WeightedTypes} from "../analysis/weights";
import {defaultWeightsForAdapterSet} from "./weights/weights";
@ -22,7 +21,10 @@ import {
} from "./state";
import {StaticAdapterSet} from "./adapters/adapterSet";
export default class AppPage extends React.Component<{|+assets: Assets|}> {
export class AppPage extends React.Component<{|
+assets: Assets,
+adapters: StaticAdapterSet,
|}> {
static _LOCAL_STORE = new CheckedLocalStore(
new BrowserLocalStore({
version: "2",
@ -35,7 +37,7 @@ export default class AppPage extends React.Component<{|+assets: Assets|}> {
return (
<App
assets={this.props.assets}
adapters={defaultStaticAdapters()}
adapters={this.props.adapters}
localStore={AppPage._LOCAL_STORE}
/>
);

View File

@ -1,13 +0,0 @@
// @flow
import {StaticAdapterSet} from "./adapterSet";
import {StaticAppAdapter as GithubAdapter} from "../../plugins/github/appAdapter";
import {StaticAppAdapter as GitAdapter} from "../../plugins/git/appAdapter";
import {GithubGitGateway} from "../../plugins/github/githubGitGateway";
export function defaultStaticAdapters(): StaticAdapterSet {
return new StaticAdapterSet([
new GithubAdapter(),
new GitAdapter(new GithubGitGateway()),
]);
}

View File

@ -0,0 +1,27 @@
// @flow
import React from "react";
import type {Assets} from "../webutil/assets";
import {StaticAdapterSet} from "../explorer/adapters/adapterSet";
import {StaticAppAdapter as GithubAdapter} from "../plugins/github/appAdapter";
import {StaticAppAdapter as GitAdapter} from "../plugins/git/appAdapter";
import {GithubGitGateway} from "../plugins/github/githubGitGateway";
import {AppPage} from "../explorer/App";
function homepageStaticAdapters(): StaticAdapterSet {
return new StaticAdapterSet([
new GithubAdapter(),
new GitAdapter(new GithubGitGateway()),
]);
}
export default class HomepageExplorer extends React.Component<{|
+assets: Assets,
|}> {
render() {
return (
<AppPage assets={this.props.assets} adapters={homepageStaticAdapters()} />
);
}
}

View File

@ -38,7 +38,7 @@ const routeData /*: $ReadOnlyArray<RouteDatum> */ = [
path: "/prototype/",
contents: {
type: "PAGE",
component: () => require("../explorer/App").default,
component: () => require("./homepageExplorer").default,
},
title: "SourceCred prototype",
navTitle: "Prototype",