import * as React from 'react'
import { DialogContent } from '../dialog'
import { TextArea } from '../lib/text-area'
import { LinkButton } from '../lib/link-button'

interface IGitIgnoreProps {
  readonly text: string | null
  readonly isDefaultBranch: boolean
  readonly onIgnoreTextChanged: (text: string) => void
  readonly onShowExamples: () => void
}

/** A view for creating or modifying the repository's gitignore file */
export class GitIgnore extends React.Component<IGitIgnoreProps, {}> {
  private renderBranchWarning(): JSX.Element | null {
    if (this.props.isDefaultBranch) {
      return null
    }

    return (
      <p>
        You are not on the default branch, so changes here may not be applied to
        the repository when you switch branches.
      </p>
    )
  }

  public render() {
    return (
      <DialogContent>
        <p>
          The .gitignore file controls which files are tracked by Git and which
          are ignored. Check out{' '}
          <LinkButton onClick={this.props.onShowExamples}>
            git-scm.com
          </LinkButton>{' '}
          for more information about the file format, or simply ignore a file by
          right clicking on it in the uncommitted changes view.
        </p>

        {this.renderBranchWarning()}

        <TextArea
          placeholder="Ignored files"
          value={this.props.text || ''}
          onValueChanged={this.props.onIgnoreTextChanged}
          rows={6}
        />
      </DialogContent>
    )
  }
}

import * as React from 'react'
import { DialogContent } from '../dialog'
import { TextArea } from '../lib/text-area'
import { LinkButton } from '../lib/link-button'

interface IGitIgnoreProps {
  readonly text: string | null
  readonly isDefaultBranch: boolean
  readonly onIgnoreTextChanged: (text: string) => void
  readonly onShowExamples: () => void
}

/** A view for creating or modifying the repository's gitignore file */
export class GitIgnore extends React.Component<IGitIgnoreProps, {}> {
  private renderBranchWarning(): JSX.Element | null {
    if (this.props.isDefaultBranch) {
      return null
    }

    return (
      <p>
        You are not on the default branch, changes here will only be stored
        locally on this branch.
      </p>
    )
  }

  public render() {
    return (
      <DialogContent>
        <p>
          The .gitignore file controls which files are tracked by Git and which
          are ignored. Check out{' '}
          <LinkButton onClick={this.props.onShowExamples}>
            git-scm.com
          </LinkButton>{' '}
          for more information about the file format, or simply ignore a file by
          right clicking on it in the uncommitted changes view.
        </p>

        {this.renderBranchWarning()}

        <TextArea
          placeholder="Ignored files"
          value={this.props.text || ''}
          onValueChanged={this.props.onIgnoreTextChanged}
          rows={6}
        />
      </DialogContent>
    )
  }
}

Update message to state changes will only be stored on the current branch
Update message to state changes will only be stored on the current branch
