From b3ffd3758b416a76ea6b492e9ad35655c68a0d5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dandelion=20Man=C3=A9?= Date: Tue, 10 Sep 2019 22:50:39 +0200 Subject: [PATCH] TimelineExplorer defaults to showing all users (#1371) Now instead of always defaulting to GitHub users, it shows all user-typed nodes. This will make SourceCred work non-hackily when there is e.g. just a Discourse plugin in scope. I also fixed an issue where it was loading the GitHub declaration in a hardcoded way, instead of properly getting it from the TimelineCred's plugin array. Test plan: Manual UI inspection. --- src/explorer/TimelineApp.js | 8 -------- src/explorer/TimelineCredView.js | 10 ++++++++-- src/explorer/TimelineExplorer.js | 20 +++++++------------- 3 files changed, 15 insertions(+), 23 deletions(-) diff --git a/src/explorer/TimelineApp.js b/src/explorer/TimelineApp.js index ad75284..6a35b70 100644 --- a/src/explorer/TimelineApp.js +++ b/src/explorer/TimelineApp.js @@ -4,11 +4,6 @@ import React from "react"; import type {Assets} from "../webutil/assets"; import {TimelineExplorer} from "./TimelineExplorer"; import {TimelineCred} from "../analysis/timeline/timelineCred"; -import { - declaration as githubDeclaration, - userNodeType, - repoNodeType, -} from "../plugins/github/declaration"; import {encodeProjectId, type ProjectId} from "../core/project"; export type Props = {| @@ -72,9 +67,6 @@ export class TimelineApp extends React.Component { ); } diff --git a/src/explorer/TimelineCredView.js b/src/explorer/TimelineCredView.js index 5dc420d..d9dd2b9 100644 --- a/src/explorer/TimelineCredView.js +++ b/src/explorer/TimelineCredView.js @@ -10,7 +10,7 @@ import {TimelineCred} from "../analysis/timeline/timelineCred"; export type Props = {| +timelineCred: TimelineCred, - +selectedNodeFilter: NodeAddressT, + +selectedNodeFilter: NodeAddressT | null, |}; const MAX_ENTRIES_PER_LIST = 100; @@ -33,7 +33,13 @@ const DEFAULT_ENTRIES_PER_CHART = 6; export class TimelineCredView extends React.Component { render() { const {selectedNodeFilter, timelineCred} = this.props; - const nodes = timelineCred.credSortedNodes([selectedNodeFilter]); + const nodes = (() => { + if (selectedNodeFilter == null) { + return timelineCred.userNodes(); + } else { + return timelineCred.credSortedNodes([selectedNodeFilter]); + } + })(); const tableNodes = nodes.slice(0, MAX_ENTRIES_PER_LIST); const chartNodes = nodes .slice(0, DEFAULT_ENTRIES_PER_CHART) diff --git a/src/explorer/TimelineExplorer.js b/src/explorer/TimelineExplorer.js index c4107a2..ed7a847 100644 --- a/src/explorer/TimelineExplorer.js +++ b/src/explorer/TimelineExplorer.js @@ -2,10 +2,7 @@ import React from "react"; import deepEqual from "lodash.isequal"; -import { - type PluginDeclaration, - combineTypes, -} from "../analysis/pluginDeclaration"; +import {combineTypes} from "../analysis/pluginDeclaration"; import {type Weights, copy as weightsCopy} from "../analysis/weights"; import {type NodeAddressT} from "../core/graph"; import { @@ -16,14 +13,10 @@ import {TimelineCredView} from "./TimelineCredView"; import Link from "../webutil/Link"; import {WeightConfig} from "./weights/WeightConfig"; import {WeightsFileManager} from "./weights/WeightsFileManager"; -import {type NodeType} from "../analysis/types"; export type Props = { projectId: string, initialTimelineCred: TimelineCred, - // TODO: Get this info from the TimelineCred - declarations: $ReadOnlyArray, - +defaultNodeType: NodeType, }; export type State = { @@ -33,7 +26,7 @@ export type State = { intervalDecay: number, loading: boolean, showWeightConfig: boolean, - selectedNodeTypePrefix: NodeAddressT, + selectedNodeTypePrefix: NodeAddressT | null, }; /** @@ -48,9 +41,7 @@ export class TimelineExplorer extends React.Component { constructor(props: Props) { super(props); const timelineCred = props.initialTimelineCred; - const {defaultNodeType} = props; const {alpha, intervalDecay, weights} = timelineCred.params(); - const selectedNodeTypePrefix = defaultNodeType.prefix; this.state = { timelineCred, alpha, @@ -61,7 +52,7 @@ export class TimelineExplorer extends React.Component { weights: weightsCopy(weights), loading: false, showWeightConfig: false, - selectedNodeTypePrefix, + selectedNodeTypePrefix: null, }; } @@ -90,7 +81,7 @@ export class TimelineExplorer extends React.Component { ); const weightConfig = ( { @@ -164,6 +155,9 @@ export class TimelineExplorer extends React.Component { this.setState({selectedNodeTypePrefix: e.target.value}) } > + {nodeTypes.map(({prefix, pluralName}) => (