import ChevronRightIcon from 'mdi-react/ChevronRightIcon';
import * as React from 'react';
import { Link } from 'react-router-dom';
export class DiscussionsNavbar extends React.PureComponent {
    render() {
        // TODO(slimsag:discussions): make ID number smaller and grey like on thread list
        const { threadID, threadTitle, commentID, commentContent, filePath, location } = this.props;
        return (React.createElement("div", { className: "discussions-navbar" },
            React.createElement(Link, { to: this.locationWith(location), "data-tooltip": `All discussions on ${filePath}` }, filePath),
            React.createElement(ChevronRightIcon, { className: "icon-inline" }),
            threadID !== undefined &&
                commentID !== undefined && (React.createElement(React.Fragment, null,
                React.createElement(Link, { to: this.locationWith(location, threadID), "data-tooltip": `Discussion thread #${this.props.threadID}` },
                    threadTitle !== undefined && `${threadTitle} `,
                    "#",
                    threadID),
                React.createElement(ChevronRightIcon, { className: "icon-inline" }),
                React.createElement("strong", null,
                    commentContent !== undefined && `${commentContent} `,
                    "#",
                    this.props.commentID))),
            threadID !== undefined &&
                commentID === undefined && (React.createElement("strong", null,
                threadTitle !== undefined && `${threadTitle} `,
                "#",
                threadID)),
            threadID === undefined &&
                commentID === undefined && (React.createElement(React.Fragment, null,
                !threadTitle && React.createElement("strong", null, "New discussion"),
                threadTitle && (React.createElement(React.Fragment, null,
                    React.createElement("strong", { className: "discussions-navbar__title-container" },
                        "New discussion:",
                        ' ',
                        React.createElement("small", { className: "discussions-navbar__title text-muted" },
                            "\"",
                            threadTitle,
                            "\""))))))));
    }
    locationWith(location, threadID) {
        // TODO(slimsag:discussions): future: for correctness, this should not
        // assume the current location and instead use this.props.filePath etc.
        const hash = new URLSearchParams(location.hash.slice('#'.length));
        hash.set('tab', 'discussions');
        hash.delete('createThread');
        hash.delete('commentID');
        if (threadID) {
            hash.set('threadID', threadID);
        }
        else {
            hash.delete('threadID');
        }
        return location.pathname + location.search + '#' + hash.toString();
    }
}
//# sourceMappingURL=DiscussionsNavbar.js.map