<commit_before>/* tslint:disable:react-this-binding-issue */

import * as React from 'react'

import { Dispatcher } from '../../lib/dispatcher'
import { TabBar } from '../tab-bar'
import { AddExistingRepository } from './add-existing-repository'
import { CreateRepository } from './create-repository'
import { CloneRepository } from './clone-repository'
import { assertNever } from '../../lib/fatal-error'

interface IAddRepositoryProps {
  readonly dispatcher: Dispatcher
}

interface IAddRepositoryState {
  readonly selectedTab: AddRepositoryTab
}

enum AddRepositoryTab {
  AddExisting = 0,
  Create,
  Clone
}

/**
 * The component for adding a local repository, creating a new repository, or
 * cloning an existing repository.
 */
export class AddRepository extends React.Component<IAddRepositoryProps, IAddRepositoryState> {
  public constructor(props: IAddRepositoryProps) {
    super(props)

    this.state = { selectedTab: AddRepositoryTab.AddExisting }
  }

  private onTabClicked(tab: AddRepositoryTab) {
    this.setState({ selectedTab: tab })
  }

  public renderSelectedTab() {
    switch (this.state.selectedTab) {
      case AddRepositoryTab.AddExisting:
        return <AddExistingRepository dispatcher={this.props.dispatcher}/>

      case AddRepositoryTab.Create:
        return <CreateRepository dispatcher={this.props.dispatcher}/>

      case AddRepositoryTab.Clone:
        return <CloneRepository />

      default:
        return assertNever(this.state.selectedTab, `Unknown tab: ${this.state.selectedTab}`)
    }
  }

  public render() {
    return (
      <div>
        <nav className='popup-navigation'>
          <TabBar onTabClicked={index => this.onTabClicked(index)} selectedIndex={this.state.selectedTab}>
            <span role='button'>Add</span>
            <span role='button'>Create</span>
            <span role='button'>Clone</span>
          </TabBar>
        </nav>

        {this.renderSelectedTab()}
      </div>
    )
  }
}<commit_msg>Bind event handler in add-repository<commit_after>import * as React from 'react'

import { Dispatcher } from '../../lib/dispatcher'
import { TabBar } from '../tab-bar'
import { AddExistingRepository } from './add-existing-repository'
import { CreateRepository } from './create-repository'
import { CloneRepository } from './clone-repository'
import { assertNever } from '../../lib/fatal-error'

interface IAddRepositoryProps {
  readonly dispatcher: Dispatcher
}

interface IAddRepositoryState {
  readonly selectedTab: AddRepositoryTab
}

enum AddRepositoryTab {
  AddExisting = 0,
  Create,
  Clone
}

/**
 * The component for adding a local repository, creating a new repository, or
 * cloning an existing repository.
 */
export class AddRepository extends React.Component<IAddRepositoryProps, IAddRepositoryState> {
  public constructor(props: IAddRepositoryProps) {
    super(props)

    this.state = { selectedTab: AddRepositoryTab.AddExisting }
  }

  private onTabClicked = (tab: AddRepositoryTab) => {
    this.setState({ selectedTab: tab })
  }

  public renderSelectedTab() {
    switch (this.state.selectedTab) {
      case AddRepositoryTab.AddExisting:
        return <AddExistingRepository dispatcher={this.props.dispatcher}/>

      case AddRepositoryTab.Create:
        return <CreateRepository dispatcher={this.props.dispatcher}/>

      case AddRepositoryTab.Clone:
        return <CloneRepository />

      default:
        return assertNever(this.state.selectedTab, `Unknown tab: ${this.state.selectedTab}`)
    }
  }

  public render() {
    return (
      <div>
        <nav className='popup-navigation'>
          <TabBar onTabClicked={this.onTabClicked} selectedIndex={this.state.selectedTab}>
            <span role='button'>Add</span>
            <span role='button'>Create</span>
            <span role='button'>Clone</span>
          </TabBar>
        </nav>

        {this.renderSelectedTab()}
      </div>
    )
  }
}
{'fraction_non_alphanumeric': 0.11736252545824848, 'fraction_numerical': 0.0005091649694501018, 'mean_word_length': 3.308114035087719, 'pattern_counts': {'":': 0, '<': 35, '<?xml version=': 0, '>': 37, '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': '802262', 'n_tokens_mistral': 1108, 'n_tokens_neox': 1094, 'n_words': 254}