mirror of
https://github.com/status-im/sourcecred.git
synced 2025-02-28 20:20:35 +00:00
Collect web-related utilities in webutil/
(#970)
I'm planning to pull `credExplorer` out of `app` and into its own top-level module. This is a bit awkward, as `credExplorer` depends on a lot of little modules that are currently collected in `app/`. To resolve this, I pull all of these little utility modules into `webutil/`. It's not a totally principled grouping, but it's quite convenient and keeps these rarely changing modules out of the way. Test plan: It's a file move, `yarn test` suffices.
This commit is contained in:
parent
b077bd8179
commit
c997f4e1ec
@ -2,7 +2,7 @@
|
||||
|
||||
import React from "react";
|
||||
|
||||
import Link from "./Link";
|
||||
import Link from "../webutil/Link";
|
||||
|
||||
export default class ExternalRedirect extends React.Component<{|
|
||||
+redirectTo: string,
|
||||
|
@ -2,8 +2,8 @@
|
||||
|
||||
import React from "react";
|
||||
|
||||
import type {Assets} from "./assets";
|
||||
import Link from "./Link";
|
||||
import type {Assets} from "../webutil/assets";
|
||||
import Link from "../webutil/Link";
|
||||
|
||||
export default class HomePage extends React.Component<{|+assets: Assets|}> {
|
||||
render() {
|
||||
|
@ -3,9 +3,9 @@
|
||||
import React, {type Node} from "react";
|
||||
import {StyleSheet, css} from "aphrodite/no-important";
|
||||
|
||||
import type {Assets} from "./assets";
|
||||
import Colors from "./Colors";
|
||||
import Link from "./Link";
|
||||
import type {Assets} from "../webutil/assets";
|
||||
import Colors from "../webutil/Colors";
|
||||
import Link from "../webutil/Link";
|
||||
import GithubLogo from "./GithubLogo";
|
||||
import TwitterLogo from "./TwitterLogo";
|
||||
import DiscordLogo from "./DiscordLogo";
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
import {Graph, type NodeAddressT, type EdgeAddressT} from "../../core/graph";
|
||||
import {NodeTrie, EdgeTrie} from "../../core/trie";
|
||||
import type {Assets} from "../assets";
|
||||
import type {Assets} from "../../webutil/assets";
|
||||
import type {RepoId} from "../../core/repoId";
|
||||
|
||||
import type {StaticAppAdapter, DynamicAppAdapter} from "./appAdapter";
|
||||
|
@ -9,7 +9,7 @@ import {
|
||||
fallbackNodeType,
|
||||
fallbackEdgeType,
|
||||
} from "../../analysis/fallbackDeclaration";
|
||||
import {Assets} from "../assets";
|
||||
import {Assets} from "../../webutil/assets";
|
||||
import {makeRepoId} from "../../core/repoId";
|
||||
|
||||
describe("app/adapters/adapterSet", () => {
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
import {type Node as ReactNode} from "react";
|
||||
import {Graph, type NodeAddressT} from "../../core/graph";
|
||||
import type {Assets} from "../assets";
|
||||
import type {Assets} from "../../webutil/assets";
|
||||
import type {RepoId} from "../../core/repoId";
|
||||
import type {PluginDeclaration} from "../../analysis/pluginDeclaration";
|
||||
|
||||
|
@ -5,7 +5,7 @@ import type {
|
||||
StaticAppAdapter,
|
||||
DynamicAppAdapter,
|
||||
} from "../../app/adapters/appAdapter";
|
||||
import {Assets} from "../../app/assets";
|
||||
import {Assets} from "../../webutil/assets";
|
||||
import {type RepoId} from "../../core/repoId";
|
||||
import {Graph, NodeAddress, type NodeAddressT} from "../../core/graph";
|
||||
|
||||
|
@ -5,7 +5,7 @@ import {IndexRoute, Route} from "react-router";
|
||||
|
||||
import Page from "./Page";
|
||||
import ExternalRedirect from "./ExternalRedirect";
|
||||
import withAssets from "./withAssets";
|
||||
import withAssets from "../webutil/withAssets";
|
||||
import {routeData} from "./routeData";
|
||||
|
||||
export function createRoutes() {
|
||||
|
@ -2,11 +2,11 @@
|
||||
|
||||
import React from "react";
|
||||
|
||||
import type {Assets} from "../assets";
|
||||
import type {LocalStore} from "../localStore";
|
||||
import CheckedLocalStore from "../checkedLocalStore";
|
||||
import BrowserLocalStore from "../browserLocalStore";
|
||||
import Link from "../Link";
|
||||
import type {Assets} from "../../webutil/assets";
|
||||
import type {LocalStore} from "../../webutil/localStore";
|
||||
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";
|
||||
|
@ -5,8 +5,8 @@ import {shallow} from "enzyme";
|
||||
|
||||
import {Graph} from "../../core/graph";
|
||||
import {makeRepoId} from "../../core/repoId";
|
||||
import {Assets} from "../assets";
|
||||
import testLocalStore from "../testLocalStore";
|
||||
import {Assets} from "../../webutil/assets";
|
||||
import testLocalStore from "../../webutil/testLocalStore";
|
||||
import {DynamicAdapterSet, StaticAdapterSet} from "../adapters/adapterSet";
|
||||
import {FactorioStaticAdapter} from "../../plugins/demo/appAdapter";
|
||||
import {defaultWeightsForAdapter} from "./weights/weights";
|
||||
@ -17,7 +17,7 @@ import {createApp, LoadingIndicator} from "./App";
|
||||
import {uninitializedState} from "./state";
|
||||
import {Prefix as GithubPrefix} from "../../plugins/github/nodes";
|
||||
|
||||
require("../testUtil").configureEnzyme();
|
||||
require("../../webutil/testUtil").configureEnzyme();
|
||||
|
||||
describe("app/credExplorer/App", () => {
|
||||
function example() {
|
||||
|
@ -5,8 +5,8 @@ import sortBy from "lodash.sortby";
|
||||
import deepEqual from "lodash.isequal";
|
||||
|
||||
import * as NullUtil from "../../util/null";
|
||||
import type {LocalStore} from "../localStore";
|
||||
import type {Assets} from "../assets";
|
||||
import type {LocalStore} from "../../webutil/localStore";
|
||||
import type {Assets} from "../../webutil/assets";
|
||||
|
||||
import {fromJSON, REPO_ID_REGISTRY_API} from "./repoIdRegistry";
|
||||
import {type RepoId, stringToRepoId, repoIdToString} from "../../core/repoId";
|
||||
|
@ -3,7 +3,7 @@ import React from "react";
|
||||
import {shallow, mount} from "enzyme";
|
||||
|
||||
import * as NullUtil from "../../util/null";
|
||||
import testLocalStore from "../testLocalStore";
|
||||
import testLocalStore from "../../webutil/testLocalStore";
|
||||
import RepositorySelect, {
|
||||
PureRepositorySelect,
|
||||
LocalStoreRepositorySelect,
|
||||
@ -11,7 +11,7 @@ import RepositorySelect, {
|
||||
type Status,
|
||||
REPO_ID_KEY,
|
||||
} from "./RepositorySelect";
|
||||
import {Assets} from "../assets";
|
||||
import {Assets} from "../../webutil/assets";
|
||||
|
||||
import {
|
||||
toJSON,
|
||||
@ -20,8 +20,8 @@ import {
|
||||
} from "./repoIdRegistry";
|
||||
import {makeRepoId} from "../../core/repoId";
|
||||
|
||||
require("../testUtil").configureEnzyme();
|
||||
require("../testUtil").configureAphrodite();
|
||||
require("../../webutil/testUtil").configureEnzyme();
|
||||
require("../../webutil/testUtil").configureAphrodite();
|
||||
|
||||
describe("app/credExplorer/RepositorySelect", () => {
|
||||
beforeEach(() => {
|
||||
|
@ -18,7 +18,7 @@ import {aggregateFlat, type FlatAggregation} from "./aggregate";
|
||||
import {TableRow} from "./TableRow";
|
||||
import {nodes as factorioNodes} from "../../../plugins/demo/graph";
|
||||
|
||||
require("../../testUtil").configureEnzyme();
|
||||
require("../../../webutil/testUtil").configureEnzyme();
|
||||
|
||||
describe("app/credExplorer/pagerankTable/Aggregation", () => {
|
||||
describe("AggregationRowList", () => {
|
||||
|
@ -11,7 +11,7 @@ import {TableRow} from "./TableRow";
|
||||
import {NodeRow} from "./Node";
|
||||
import {nodes as factorioNodes} from "../../../plugins/demo/graph";
|
||||
|
||||
require("../../testUtil").configureEnzyme();
|
||||
require("../../../webutil/testUtil").configureEnzyme();
|
||||
|
||||
describe("app/credExplorer/pagerankTable/Connection", () => {
|
||||
describe("ConnectionRowList", () => {
|
||||
|
@ -14,7 +14,7 @@ import {example} from "./sharedTestUtils";
|
||||
import {NodeRowList, NodeRow, type NodeRowProps} from "./Node";
|
||||
import {nodes as factorioNodes} from "../../../plugins/demo/graph";
|
||||
|
||||
require("../../testUtil").configureEnzyme();
|
||||
require("../../../webutil/testUtil").configureEnzyme();
|
||||
|
||||
describe("app/credExplorer/pagerankTable/Node", () => {
|
||||
describe("NodeRowList", () => {
|
||||
|
@ -12,7 +12,7 @@ import {WeightConfig} from "../weights/WeightConfig";
|
||||
import {defaultWeightsForAdapter} from "../weights/weights";
|
||||
import {FactorioStaticAdapter} from "../../../plugins/demo/appAdapter";
|
||||
|
||||
require("../../testUtil").configureEnzyme();
|
||||
require("../../../webutil/testUtil").configureEnzyme();
|
||||
describe("app/credExplorer/pagerankTable/Table", () => {
|
||||
describe("PagerankTable", () => {
|
||||
async function setup(defaultNodeFilter?: NodeAddressT) {
|
||||
|
@ -5,7 +5,7 @@ import {shallow} from "enzyme";
|
||||
import {TableRow, PaddingRow} from "./TableRow";
|
||||
|
||||
import {COLUMNS} from "./sharedTestUtils";
|
||||
require("../../testUtil").configureEnzyme();
|
||||
require("../../../webutil/testUtil").configureEnzyme();
|
||||
|
||||
describe("app/credExplorer/pagerankTable/TableRow", () => {
|
||||
function example() {
|
||||
|
@ -3,7 +3,7 @@
|
||||
import deepEqual from "lodash.isequal";
|
||||
|
||||
import {Graph, type NodeAddressT} from "../../core/graph";
|
||||
import type {Assets} from "../../app/assets";
|
||||
import type {Assets} from "../../webutil/assets";
|
||||
import type {RepoId} from "../../core/repoId";
|
||||
import {type EdgeEvaluator} from "../../analysis/pagerank";
|
||||
import {
|
||||
|
@ -8,7 +8,7 @@ import {
|
||||
} from "./state";
|
||||
|
||||
import {Graph, NodeAddress} from "../../core/graph";
|
||||
import {Assets} from "../assets";
|
||||
import {Assets} from "../../webutil/assets";
|
||||
import {makeRepoId, type RepoId} from "../../core/repoId";
|
||||
import {type EdgeEvaluator} from "../../analysis/pagerank";
|
||||
import type {WeightedTypes} from "../../analysis/weights";
|
||||
|
@ -7,7 +7,7 @@ import {WeightSlider} from "./WeightSlider";
|
||||
import {EdgeTypeConfig, EdgeWeightSlider} from "./EdgeTypeConfig";
|
||||
import {assemblesEdgeType} from "../../../plugins/demo/declaration";
|
||||
|
||||
require("../../testUtil").configureEnzyme();
|
||||
require("../../../webutil/testUtil").configureEnzyme();
|
||||
|
||||
describe("app/credExplorer/weights/EdgeTypeConfig", () => {
|
||||
describe("EdgeTypeConfig", () => {
|
||||
|
@ -7,7 +7,7 @@ import {WeightSlider} from "./WeightSlider";
|
||||
import {NodeTypeConfig} from "./NodeTypeConfig";
|
||||
import {inserterNodeType} from "../../../plugins/demo/declaration";
|
||||
|
||||
require("../../testUtil").configureEnzyme();
|
||||
require("../../../webutil/testUtil").configureEnzyme();
|
||||
|
||||
describe("app/credExplorer/weights/NodeTypeConfig", () => {
|
||||
describe("NodeTypeConfig", () => {
|
||||
|
@ -21,7 +21,7 @@ import {
|
||||
} from "../../../analysis/weights";
|
||||
import {defaultWeightsForAdapter} from "./weights";
|
||||
|
||||
require("../../testUtil").configureEnzyme();
|
||||
require("../../../webutil/testUtil").configureEnzyme();
|
||||
|
||||
describe("app/credExplorer/weights/PluginWeightConfig", () => {
|
||||
describe("PluginWeightConfig", () => {
|
||||
|
@ -12,7 +12,7 @@ import {FALLBACK_NAME} from "../../../analysis/fallbackDeclaration";
|
||||
import {defaultWeightsForAdapterSet, defaultWeightsForAdapter} from "./weights";
|
||||
import {WeightConfig} from "./WeightConfig";
|
||||
|
||||
require("../../testUtil").configureEnzyme();
|
||||
require("../../../webutil/testUtil").configureEnzyme();
|
||||
|
||||
describe("app/credExplorer/weights/WeightConfig", () => {
|
||||
describe("WeightConfig", () => {
|
||||
|
@ -5,7 +5,7 @@ import {shallow} from "enzyme";
|
||||
|
||||
import {WeightSlider, formatWeight} from "./WeightSlider";
|
||||
|
||||
require("../../testUtil").configureEnzyme();
|
||||
require("../../../webutil/testUtil").configureEnzyme();
|
||||
|
||||
describe("app/credExplorer/weights/WeightSlider", () => {
|
||||
describe("WeightSlider", () => {
|
||||
|
@ -3,7 +3,7 @@ import React from "react";
|
||||
import ReactDOM from "react-dom";
|
||||
import createBrowserHistory from "history/lib/createBrowserHistory";
|
||||
|
||||
import createRelativeHistory from "./createRelativeHistory";
|
||||
import createRelativeHistory from "../webutil/createRelativeHistory";
|
||||
import normalize from "../util/pathNormalize";
|
||||
import App from "./App";
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
// inline syntax.
|
||||
|
||||
/*::
|
||||
import type {Assets} from "./assets";
|
||||
import type {Assets} from "../webutil/assets";
|
||||
type RouteDatum = {|
|
||||
+path: string,
|
||||
+contents:
|
||||
|
@ -7,8 +7,8 @@ import ReactDOMServer from "react-dom/server";
|
||||
import {match, RouterContext} from "react-router";
|
||||
|
||||
import Page from "./Page";
|
||||
import {Assets, rootFromPath} from "./assets";
|
||||
import createRelativeHistory from "./createRelativeHistory";
|
||||
import {Assets, rootFromPath} from "../webutil/assets";
|
||||
import createRelativeHistory from "../webutil/createRelativeHistory";
|
||||
import ExternalRedirect from "./ExternalRedirect";
|
||||
import {createRoutes} from "./createRoutes";
|
||||
import {resolveRouteFromPath, resolveTitleFromPath} from "./routeData";
|
||||
|
@ -7,7 +7,7 @@ import type {
|
||||
DynamicAppAdapter,
|
||||
} from "../../app/adapters/appAdapter";
|
||||
import {StaticAdapterSet} from "../../app/adapters/adapterSet";
|
||||
import {Assets} from "../../app/assets";
|
||||
import {Assets} from "../../webutil/assets";
|
||||
import {type RepoId, makeRepoId} from "../../core/repoId";
|
||||
import {NodeAddress, type NodeAddressT} from "../../core/graph";
|
||||
import {graph} from "./graph";
|
||||
|
@ -6,7 +6,7 @@ import type {
|
||||
import {Graph} from "../../core/graph";
|
||||
import * as N from "./nodes";
|
||||
import {description} from "./render";
|
||||
import type {Assets} from "../../app/assets";
|
||||
import type {Assets} from "../../webutil/assets";
|
||||
import type {RepoId} from "../../core/repoId";
|
||||
import type {Repository} from "./types";
|
||||
import type {GitGateway} from "./gitGateway";
|
||||
|
@ -1,7 +1,7 @@
|
||||
// @flow
|
||||
|
||||
import React from "react";
|
||||
import Link from "../../app/Link";
|
||||
import Link from "../../webutil/Link";
|
||||
import * as N from "./nodes";
|
||||
import type {Repository} from "./types";
|
||||
import {type RepoIdString, stringToRepoId} from "../../core/repoId";
|
||||
|
@ -6,9 +6,9 @@ import {description} from "./render";
|
||||
import {type RepoId, repoIdToString, makeRepoId} from "../../core/repoId";
|
||||
import type {Repository, Hash, Commit} from "./types";
|
||||
import type {GitGateway, URL} from "./gitGateway";
|
||||
import Link from "../../app/Link";
|
||||
import Link from "../../webutil/Link";
|
||||
|
||||
require("../../app/testUtil").configureEnzyme();
|
||||
require("../../webutil/testUtil").configureEnzyme();
|
||||
|
||||
describe("plugins/git/render", () => {
|
||||
const repoId1 = makeRepoId("example-owner", "1");
|
||||
|
@ -10,7 +10,7 @@ import {createGraph} from "./createGraph";
|
||||
import * as N from "./nodes";
|
||||
import {RelationalView} from "./relationalView";
|
||||
import {description} from "./render";
|
||||
import type {Assets} from "../../app/assets";
|
||||
import type {Assets} from "../../webutil/assets";
|
||||
import type {RepoId} from "../../core/repoId";
|
||||
import type {PluginDeclaration} from "../../analysis/pluginDeclaration";
|
||||
import {declaration} from "./declaration";
|
||||
|
@ -3,7 +3,7 @@
|
||||
import React, {type Node as ReactNode} from "react";
|
||||
import * as R from "./relationalView";
|
||||
|
||||
import Link from "../../app/Link";
|
||||
import Link from "../../webutil/Link";
|
||||
|
||||
function EntityUrl(props) {
|
||||
return (
|
||||
|
@ -5,8 +5,8 @@ import {exampleEntities} from "./example/example";
|
||||
import {description} from "./render";
|
||||
import enzymeToJSON from "enzyme-to-json";
|
||||
|
||||
require("../../app/testUtil").configureAphrodite();
|
||||
require("../../app/testUtil").configureEnzyme();
|
||||
require("../../webutil/testUtil").configureAphrodite();
|
||||
require("../../webutil/testUtil").configureEnzyme();
|
||||
|
||||
describe("plugins/github/render", () => {
|
||||
const examples = exampleEntities();
|
||||
|
@ -9,7 +9,7 @@ import Link from "./Link";
|
||||
require("./testUtil").configureAphrodite();
|
||||
require("./testUtil").configureEnzyme();
|
||||
|
||||
describe("src/app/Link", () => {
|
||||
describe("webutil/Link", () => {
|
||||
const styles = StyleSheet.create({
|
||||
x: {fontWeight: "bold"},
|
||||
});
|
@ -2,7 +2,7 @@
|
||||
|
||||
import {Assets, rootFromPath} from "./assets";
|
||||
|
||||
describe("app/assets", () => {
|
||||
describe("webutil/assets", () => {
|
||||
describe("Assets", () => {
|
||||
describe("with an unknown root path (null)", () => {
|
||||
it("can be constructed", () => {
|
@ -3,7 +3,7 @@
|
||||
import {LocalStore} from "./localStore";
|
||||
import CheckedLocalStore from "./checkedLocalStore";
|
||||
|
||||
describe("src/app/checkedLocalStore", () => {
|
||||
describe("webutil/checkedLocalStore", () => {
|
||||
function makeBase(): LocalStore {
|
||||
return {
|
||||
get: jest.fn(),
|
@ -11,7 +11,7 @@ import createRelativeHistory from "./createRelativeHistory";
|
||||
|
||||
require("./testUtil").configureEnzyme();
|
||||
|
||||
describe("app/createRelativeHistory", () => {
|
||||
describe("webutil/createRelativeHistory", () => {
|
||||
function createHistory(basename, path) {
|
||||
const memoryHistory = createMemoryHistory(path);
|
||||
const relativeHistory = createRelativeHistory(memoryHistory, basename);
|
@ -2,7 +2,7 @@
|
||||
|
||||
import MemoryLocalStore from "./memoryLocalStore";
|
||||
|
||||
describe("src/app/memoryLocalStore", () => {
|
||||
describe("webutil/memoryLocalStore", () => {
|
||||
it("stores simple values", () => {
|
||||
const ls = new MemoryLocalStore();
|
||||
ls.set("one", 1);
|
@ -12,7 +12,7 @@ import createRelativeHistory from "./createRelativeHistory";
|
||||
|
||||
require("./testUtil").configureEnzyme();
|
||||
|
||||
describe("app/withAssets", () => {
|
||||
describe("webutil/withAssets", () => {
|
||||
function createHistory(basename, path) {
|
||||
const memoryHistory = createMemoryHistory(path);
|
||||
const relativeHistory = createRelativeHistory(memoryHistory, basename);
|
Loading…
x
Reference in New Issue
Block a user