From 244c01d7648eab8e17bbe24bbe6253f77ff6b78d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dandelion=20Man=C3=A9?= Date: Thu, 1 Nov 2018 11:39:07 -0700 Subject: [PATCH] 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. --- src/explorer/App.js | 8 +++++--- src/explorer/adapters/defaultPlugins.js | 13 ------------ src/homepage/homepageExplorer.js | 27 +++++++++++++++++++++++++ src/homepage/routeData.js | 2 +- 4 files changed, 33 insertions(+), 17 deletions(-) delete mode 100644 src/explorer/adapters/defaultPlugins.js create mode 100644 src/homepage/homepageExplorer.js diff --git a/src/explorer/App.js b/src/explorer/App.js index e8e1b4c..bbb2622 100644 --- a/src/explorer/App.js +++ b/src/explorer/App.js @@ -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 ( ); diff --git a/src/explorer/adapters/defaultPlugins.js b/src/explorer/adapters/defaultPlugins.js deleted file mode 100644 index f32a14e..0000000 --- a/src/explorer/adapters/defaultPlugins.js +++ /dev/null @@ -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()), - ]); -} diff --git a/src/homepage/homepageExplorer.js b/src/homepage/homepageExplorer.js new file mode 100644 index 0000000..3438d0b --- /dev/null +++ b/src/homepage/homepageExplorer.js @@ -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 ( + + ); + } +} diff --git a/src/homepage/routeData.js b/src/homepage/routeData.js index dce5f7c..0ed964c 100644 --- a/src/homepage/routeData.js +++ b/src/homepage/routeData.js @@ -38,7 +38,7 @@ const routeData /*: $ReadOnlyArray */ = [ path: "/prototype/", contents: { type: "PAGE", - component: () => require("../explorer/App").default, + component: () => require("./homepageExplorer").default, }, title: "SourceCred prototype", navTitle: "Prototype",