// @flow import React, {Component} from "react"; import {commitWeight, userWeightForPath} from "./commitUtils"; import type {CommitData, FileTree} from "./commitUtils"; export class UserExplorer extends Component<{ selectedPath: string, selectedUser: ?string, onSelectUser: (newUser: string) => void, data: CommitData, }> { render() { const weights = userWeightForPath( this.props.selectedPath, this.props.data, commitWeight ); const sortedUserWeightTuples = Object.keys(weights) .map((k) => [k, weights[k]]) .sort((a, b) => b[1] - a[1]); const entries = sortedUserWeightTuples.map((authorWeight) => { const [author, weight] = authorWeight; return ; }); return (

User Explorer

{entries}
); } } /** * Record the cred earned by the user in a given scope. */ class UserEntry extends Component<{ userId: string, weight: number, }> { render() { return (
{this.props.userId} {this.props.weight.toFixed(1)}
); } }