Factor out the non-recursive RecursiveTable
Test plan: Behavior is unchanged; manually verify. Paired with @wchargin
This commit is contained in:
parent
2f0f523065
commit
0dae0c995f
|
@ -4,6 +4,7 @@ import React from "react";
|
||||||
import stringify from "json-stable-stringify";
|
import stringify from "json-stable-stringify";
|
||||||
|
|
||||||
import {Graph} from "../../core/graph";
|
import {Graph} from "../../core/graph";
|
||||||
|
import type {Address} from "../../core/address";
|
||||||
import {PLUGIN_NAME as GITHUB_PLUGIN_NAME} from "../../plugins/github/pluginName";
|
import {PLUGIN_NAME as GITHUB_PLUGIN_NAME} from "../../plugins/github/pluginName";
|
||||||
import {GIT_PLUGIN_NAME} from "../../plugins/git/types";
|
import {GIT_PLUGIN_NAME} from "../../plugins/git/types";
|
||||||
import {nodeDescription as githubNodeDescription} from "../../plugins/github/render";
|
import {nodeDescription as githubNodeDescription} from "../../plugins/github/render";
|
||||||
|
@ -134,18 +135,37 @@ export class PagerankTable extends React.Component<Props, State> {
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{nodesByScore.map((node) => {
|
{nodesByScore.map((node) => (
|
||||||
const score = pagerankResult.get(node.address).probability;
|
<RecursiveTable
|
||||||
return (
|
address={node.address}
|
||||||
<tr key={JSON.stringify(node.address)}>
|
graph={graph}
|
||||||
<td>{(score * 100).toPrecision(3)}</td>
|
pagerankResult={pagerankResult}
|
||||||
<td>{Math.log(score).toPrecision(3)}</td>
|
key={stringify(node.address)}
|
||||||
<td>{nodeDescription(graph, node.address)}</td>
|
/>
|
||||||
</tr>
|
))}
|
||||||
);
|
|
||||||
})}
|
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type RTState = {};
|
||||||
|
type RTProps = {|
|
||||||
|
+address: Address,
|
||||||
|
+graph: Graph<any, any>,
|
||||||
|
+pagerankResult: PagerankResult,
|
||||||
|
|};
|
||||||
|
|
||||||
|
class RecursiveTable extends React.Component<RTProps, RTState> {
|
||||||
|
render() {
|
||||||
|
const {address, graph, pagerankResult} = this.props;
|
||||||
|
const score = pagerankResult.get(address).probability;
|
||||||
|
return (
|
||||||
|
<tr key={JSON.stringify(address)}>
|
||||||
|
<td>{(score * 100).toPrecision(3)}</td>
|
||||||
|
<td>{Math.log(score).toPrecision(3)}</td>
|
||||||
|
<td>{nodeDescription(graph, address)}</td>
|
||||||
|
</tr>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue