import { ActionsNavItems } from '@sourcegraph/extensions-client-common/lib/app/actions/ActionsNavItems';
import { CommandListPopoverButton } from '@sourcegraph/extensions-client-common/lib/app/CommandList';
import * as React from 'react';
import { Link } from 'react-router-dom';
import { Subscription } from 'rxjs';
import { ContributableMenu } from 'sourcegraph/module/protocol';
import { HelpPopover } from '../components/HelpPopover';
import { ThemeSwitcher } from '../components/ThemeSwitcher';
import { isDiscussionsEnabled } from '../discussions';
import { OpenHelpPopoverButton } from '../global/OpenHelpPopoverButton';
import { eventLogger } from '../tracking/eventLogger';
import { UserAvatar } from '../user/UserAvatar';
import { canListAllRepositories, showDotComMarketing } from '../util/features';
export class NavLinks extends React.PureComponent {
    constructor() {
        super(...arguments);
        this.subscriptions = new Subscription();
        this.onClickInstall = () => {
            eventLogger.log('InstallSourcegraphServerCTAClicked', {
                location_on_page: 'Navbar',
            });
        };
        this.onHelpPopoverToggle = () => {
            this.props.onHelpPopoverToggle();
        };
    }
    componentWillUnmount() {
        this.subscriptions.unsubscribe();
    }
    render() {
        return (React.createElement("ul", { className: "nav-links nav align-items-center pl-2 pr-1" },
            showDotComMarketing && (React.createElement("li", { className: "nav-item" },
                React.createElement("a", { href: "https://about.sourcegraph.com", className: "nav-link text-truncate", onClick: this.onClickInstall, title: "Install self-hosted Sourcegraph to search your own code" },
                    "Install ",
                    React.createElement("span", { className: "nav-links__widescreen-only" }, "Sourcegraph")))),
            React.createElement(ActionsNavItems, { menu: ContributableMenu.GlobalNav, extensionsController: this.props.extensionsController, extensions: this.props.extensions }),
            this.props.user && (React.createElement("li", { className: "nav-item" },
                React.createElement(Link, { to: "/search/searches", className: "nav-link" }, "Searches"))),
            canListAllRepositories && (React.createElement("li", { className: "nav-item" },
                React.createElement(Link, { to: "/explore", className: "nav-link" }, "Explore"))),
            isDiscussionsEnabled(this.props.configurationCascade) && (React.createElement("li", { className: "nav-item" },
                React.createElement(Link, { to: "/discussions", className: "nav-link" }, "Discussions"))),
            React.createElement("li", { className: "nav-item" },
                React.createElement(Link, { to: "/extensions", className: "nav-link" }, "Extensions")),
            this.props.user &&
                this.props.user.siteAdmin && (React.createElement("li", { className: "nav-item" },
                React.createElement(Link, { to: "/site-admin", className: "nav-link" }, "Admin"))),
            React.createElement(CommandListPopoverButton, { menu: ContributableMenu.CommandPalette, extensionsController: this.props.extensionsController, extensions: this.props.extensions }),
            this.props.user ? (React.createElement("li", { className: "nav-item" },
                React.createElement(Link, { className: "nav-link py-0", to: `${this.props.user.url}/account` }, this.props.user.avatarURL ? (React.createElement(UserAvatar, { size: 64 })) : (React.createElement("strong", null, this.props.user.username))))) : (this.props.location.pathname !== '/sign-in' && (React.createElement("li", { className: "nav-item mx-1" },
                React.createElement(Link, { className: "nav-link btn btn-primary", to: "/sign-in" }, "Sign in")))),
            React.createElement("li", { className: "nav-item" },
                React.createElement(OpenHelpPopoverButton, { className: "nav-link px-0", onHelpPopoverToggle: this.onHelpPopoverToggle })),
            this.props.showHelpPopover && (React.createElement(HelpPopover, { onDismiss: this.onHelpPopoverToggle, extensionsController: this.props.extensionsController, extensions: this.props.extensions })),
            !this.props.isMainPage && (React.createElement("li", { className: "nav-item" },
                React.createElement(ThemeSwitcher, Object.assign({}, this.props, { className: "nav-link px-0" })))),
            showDotComMarketing && (React.createElement("li", { className: "nav-item" },
                React.createElement("a", { href: "https://about.sourcegraph.com", className: "nav-link" }, "About")))));
    }
}
//# sourceMappingURL=NavLinks.js.map