import * as React from 'react';
import { NavLink } from 'react-router-dom';
import { replaceRevisionInURL } from '.';
import { fetchCommits } from '../commits/backend';
import { FilteredConnection } from '../components/FilteredConnection';
import { UserAvatar } from '../user/UserAvatar';
const CommitNode = ({ node, location }) => (React.createElement("li", { className: "repo-rev-sidebar-commits-node" },
    React.createElement(NavLink, { to: replaceRevisionInURL(location.pathname + location.search + location.hash, node.oid), className: "repo-rev-sidebar-commits-node__link", activeClassName: "repo-rev-sidebar-commits-node__link--active" },
        node.author.person ? (React.createElement(UserAvatar, { user: node.author.person, tooltip: node.author.person.name, className: "icon-inline mr-1" })) : (React.createElement(UserAvatar, { className: "icon-inline mr-1" })),
        React.createElement("span", { className: "repo-rev-sidebar-commits-node__name" }, node.abbreviatedOID),
        React.createElement("span", { className: "repo-rev-sidebar-commits-node__message" },
            React.createElement("small", null, node.message)))));
export class RepoRevSidebarCommits extends React.PureComponent {
    constructor() {
        super(...arguments);
        this.fetchCommits = (args) => fetchCommits(this.props.repoID, this.props.rev || '', Object.assign({}, args, { currentPath: this.props.filePath || '' }));
    }
    render() {
        return (React.createElement(FilteredConnection, { className: "repo-rev-sidebar-commits", compact: true, noun: "commit", pluralNoun: "commits", queryConnection: this.fetchCommits, nodeComponent: CommitNode, nodeComponentProps: { location: this.props.location }, defaultFirst: 100, shouldUpdateURLQuery: false, history: this.props.history, location: this.props.location }));
    }
}
//# sourceMappingURL=RepoRevSidebarCommits.js.map