<commit_before>import React from 'react';
import PropTypes from 'prop-types';
import {t} from 'i18next';
import partial from 'lodash/partial';
import includes from 'lodash/includes';
import isNull from 'lodash/isNull';
import classnames from 'classnames';
import config from '../config';
import ProjectList from './ProjectList';
import LibraryPicker from './LibraryPicker';
import Pop from './Pop';

class Dashboard extends React.Component {
  _renderLoginState() {
    const {currentUser} = this.props;

    if (currentUser.authenticated) {
      const name = currentUser.displayName;

      return (
        <div className="dashboard__session">
          <img
            className="dashboard__avatar"
            src={currentUser.avatarUrl}
          />
          <span className="dashboard__username">{name}</span>
          <span
            className="dashboard__log-in-out"
            onClick={this.props.onLogOut}
          >
            {t('dashboard.session.log-out-prompt')}
          </span>
        </div>
      );
    }
    return (
      <div className="dashboard__session">
        <span className="dashboard__username">
          {t('dashboard.session.not-logged-in')}
        </span>
        <span
          className="dashboard__log-in-out"
          onClick={this.props.onStartLogIn}
        >
          {t('dashboard.session.log-in-prompt')}
        </span>
      </div>
    );
  }

  _renderSubmenuToggleButton(submenu, label) {
    return (
      <div
        className={classnames(
          'dashboard__menu-item',
          'dashboard__menu-item_grid',
          {'dashboard__menu-item_active':
            this.props.activeSubmenu === submenu},
        )}
        onClick={partial(this.props.onSubmenuToggled, submenu)}
      >
        {t(`dashboard.menu.${label}`)}
      </div>
    );
  }

  _renderMenu() {
    let newProjectButton, loadProjectButton;
    if (this.props.currentUser.authenticated) {
      newProjectButton = (
        <div
          className="dashboard__menu-item dashboard__menu-item_grid"
          onClick={this.props.onNewProject}
        >
          {t('dashboard.menu.new-project')}
        </div>
      );

      loadProjectButton =
        this._renderSubmenuToggleButton('projectList', 'load-project');
    }

    return (
      <div className="dashboard__menu dashboard__menu_grid">
        {newProjectButton}
        {loadProjectButton}
        {this._renderSubmenuToggleButton('libraryPicker', 'libraries')}
        <div
          className={
            classnames(
              'dashboard__menu-item',
              'dashboard__menu-item_grid',
              {
                'dashboard__menu-item_spinner':
                  this.props.gistExportInProgress,
              },
            )
          }
          onClick={this.props.onExportGist}
        >
          {t('dashboard.menu.export-gist')}
        </div>
        <a
          className="dashboard__menu-item dashboard__menu-item_grid"
          href={config.feedbackUrl}
          rel="noopener noreferrer"
          target="_blank"
        >
          {t('dashboard.menu.send-feedback')}
        </a>
      </div>
    );
  }

  _renderSubmenu() {
    if (this.props.activeSubmenu === 'projectList') {
      return this._renderProjects();
    }
    if (this.props.activeSubmenu === 'libraryPicker') {
      return this._renderLibraryPicker();
    }
    return null;
  }

  _renderProjects() {
    return (
      <ProjectList
        currentProject={this.props.currentProject}
        projects={this.props.allProjects}<commit_msg>Don’t render project list if the current project hasn’t resolved yet<commit_after>import React from 'react';
import PropTypes from 'prop-types';
import {t} from 'i18next';
import partial from 'lodash/partial';
import includes from 'lodash/includes';
import isNull from 'lodash/isNull';
import classnames from 'classnames';
import config from '../config';
import ProjectList from './ProjectList';
import LibraryPicker from './LibraryPicker';
import Pop from './Pop';

class Dashboard extends React.Component {
  _renderLoginState() {
    const {currentUser} = this.props;

    if (currentUser.authenticated) {
      const name = currentUser.displayName;

      return (
        <div className="dashboard__session">
          <img
            className="dashboard__avatar"
            src={currentUser.avatarUrl}
          />
          <span className="dashboard__username">{name}</span>
          <span
            className="dashboard__log-in-out"
            onClick={this.props.onLogOut}
          >
            {t('dashboard.session.log-out-prompt')}
          </span>
        </div>
      );
    }
    return (
      <div className="dashboard__session">
        <span className="dashboard__username">
          {t('dashboard.session.not-logged-in')}
        </span>
        <span
          className="dashboard__log-in-out"
          onClick={this.props.onStartLogIn}
        >
          {t('dashboard.session.log-in-prompt')}
        </span>
      </div>
    );
  }

  _renderSubmenuToggleButton(submenu, label) {
    return (
      <div
        className={classnames(
          'dashboard__menu-item',
          'dashboard__menu-item_grid',
          {'dashboard__menu-item_active':
            this.props.activeSubmenu === submenu},
        )}
        onClick={partial(this.props.onSubmenuToggled, submenu)}
      >
        {t(`dashboard.menu.${label}`)}
      </div>
    );
  }

  _renderMenu() {
    let newProjectButton, loadProjectButton;
    if (this.props.currentUser.authenticated) {
      newProjectButton = (
        <div
          className="dashboard__menu-item dashboard__menu-item_grid"
          onClick={this.props.onNewProject}
        >
          {t('dashboard.menu.new-project')}
        </div>
      );

      loadProjectButton =
        this._renderSubmenuToggleButton('projectList', 'load-project');
    }

    return (
      <div className="dashboard__menu dashboard__menu_grid">
        {newProjectButton}
        {loadProjectButton}
        {this._renderSubmenuToggleButton('libraryPicker', 'libraries')}
        <div
          className={
            classnames(
              'dashboard__menu-item',
              'dashboard__menu-item_grid',
              {
                'dashboard__menu-item_spinner':
                  this.props.gistExportInProgress,
              },
            )
          }
          onClick={this.props.onExportGist}
        >
          {t('dashboard.menu.export-gist')}
        </div>
        <a
          className="dashboard__menu-item dashboard__menu-item_grid"
          href={config.feedbackUrl}
          rel="noopener noreferrer"
          target="_blank"
        >
          {t('dashboard.menu.send-feedback')}
        </a>
      </div>
    );
  }

  _renderSubmenu() {
    if (this.props.activeSubmenu === 'projectList') {
      return this._renderProjects();
    }
    if (this.props.activeSubmenu === 'libraryPicker') {
      return this._renderLibraryPicker();
    }
    return null;
  }

  _renderProjects() {
    if (isNull(this.props.currentProject)) {
      return null;
    }

    return (
      <ProjectList
        currentProject={this.props.currentProject}
        projects={this.props.allProjects}
{'fraction_non_alphanumeric': 0.12178601050594415, 'fraction_numerical': 0.000552944429084877, 'mean_word_length': 2.115848406546081, 'pattern_counts': {'":': 0, '<': 51, '<?xml version=': 0, '>': 49, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3489552', 'n_tokens_mistral': 2067, 'n_tokens_neox': 2074, 'n_words': 333}