<commit_before>const React = require('react');
const {Modal, Button, FormGroup, FormControl, ControlLabel, HelpBlock} = require('react-bootstrap');
const validUrl = require('valid-url');

class NewTeamModal extends React.Component {

  constructor() {
    super();
    this.state = {
      teamName: '',
      teamUrl: ''
    };
  }

  shouldComponentUpdate() {
    return true;
  }

  getTeamNameValidationState() {
    return this.state.teamName.length > 0 ? '' : 'error';
  }

  handleTeamNameChange(e) {
    this.setState({
      teamName: e.target.value
    });
  }

  getTeamUrlValidationState() {
    if (this.state.teamUrl.length === 0) {
      return 'error';
    }
    if (!validUrl.isUri(this.state.teamUrl)) {
      return 'error';
    }
    return '';
  }

  handleTeamUrlChange(e) {
    this.setState({
      teamUrl: e.target.value
    });
  }

  validateForm() {
    return this.getTeamNameValidationState() === '' &&
           this.getTeamUrlValidationState() === '';
  }

  render() {
    return (
      <Modal.Dialog
        id='newServerModal'
      >
        <Modal.Header>
          <Modal.Title>{'Add a new Team'}</Modal.Title>
        </Modal.Header>

        <Modal.Body>
          {'Please specify a server name and a valid Mattermost URL'}
          <form>
            <FormGroup
              validationState={this.getTeamNameValidationState()}
            >
              <ControlLabel>{'Server Display Name'}</ControlLabel>
              <FormControl
                id='teamNameInput'
                type='text'
                value={this.state.teamName}
                placeholder='Server Name'
                onChange={this.handleTeamNameChange.bind(this)}
              />
              <FormControl.Feedback/>
              <HelpBlock>{'The name of the server displayed on your desktop app tab bar.'}</HelpBlock>
            </FormGroup>
            <FormGroup
              validationState={this.getTeamUrlValidationState()}
            >
              <ControlLabel>{'Team URL'}</ControlLabel>
              <FormControl
                id='teamUrlInput'
                type='text'
                value={this.state.teamUrl}
                placeholder='https://<EMAIL>'
                onChange={this.handleTeamUrlChange.bind(this)}
              />
              <FormControl.Feedback/>
              <HelpBlock>{'The URL of your Mattermost server. Must start with http:// or https://.'}</HelpBlock>
            </FormGroup>
          </form>
        </Modal.Body>

        <Modal.Footer>
          <Button
            id='cancelNewServerModal'
            onClick={this.props.onClose}
          >{'Cancel'}</Button>
          <Button
            id='saveNewServerModal'
            onClick={() => {
              this.props.onSave({
                url: this.state.teamUrl,
                name: this.state.teamName
              });
            }}
            disabled={!this.validateForm()}<commit_msg>Change labels and texts according to visual feedback<commit_after>const React = require('react');
const {Modal, Button, FormGroup, FormControl, ControlLabel, HelpBlock} = require('react-bootstrap');
const validUrl = require('valid-url');

class NewTeamModal extends React.Component {

  constructor() {
    super();
    this.state = {
      teamName: '',
      teamUrl: ''
    };
  }

  shouldComponentUpdate() {
    return true;
  }

  getTeamNameValidationState() {
    return this.state.teamName.length > 0 ? '' : 'error';
  }

  handleTeamNameChange(e) {
    this.setState({
      teamName: e.target.value
    });
  }

  getTeamUrlValidationState() {
    if (this.state.teamUrl.length === 0) {
      return 'error';
    }
    if (!validUrl.isUri(this.state.teamUrl)) {
      return 'error';
    }
    return '';
  }

  handleTeamUrlChange(e) {
    this.setState({
      teamUrl: e.target.value
    });
  }

  validateForm() {
    return this.getTeamNameValidationState() === '' &&
           this.getTeamUrlValidationState() === '';
  }

  render() {
    return (
      <Modal.Dialog
        id='newServerModal'
      >
        <Modal.Header>
          <Modal.Title>{'Add Server'}</Modal.Title>
        </Modal.Header>

        <Modal.Body>
          <form>
            <FormGroup
              validationState={this.getTeamNameValidationState()}
            >
              <ControlLabel>{'Server Display Name'}</ControlLabel>
              <FormControl
                id='teamNameInput'
                type='text'
                value={this.state.teamName}
                placeholder='Server Name'
                onChange={this.handleTeamNameChange.bind(this)}
              />
              <FormControl.Feedback/>
              <HelpBlock>{'The name of the server displayed on your desktop app tab bar.'}</HelpBlock>
            </FormGroup>
            <FormGroup
              validationState={this.getTeamUrlValidationState()}
            >
              <ControlLabel>{'Team URL'}</ControlLabel>
              <FormControl
                id='teamUrlInput'
                type='text'
                value={this.state.teamUrl}
                placeholder='https://example.com'
                onChange={this.handleTeamUrlChange.bind(this)}
              />
              <FormControl.Feedback/>
              <HelpBlock>{'The URL of your Mattermost server. Must start with http:// or https://.'}</HelpBlock>
            </FormGroup>
          </form>
        </Modal.Body>

        <Modal.Footer>
          <Button
            id='cancelNewServerModal'
            onClick={this.props.onClose}
          >{'Cancel'}</Button>
          <Button
            id='saveNewServerModal'
            onClick={() => {
              this.props.onSave({
                url: this.state.teamUrl,
                name: this.state.teamName
              });
            }}
            disabled={!this.validateForm()}
{'fraction_non_alphanumeric': 0.1283012438234793, 'fraction_numerical': 0.0006815471119441132, 'mean_word_length': 1.7340475081509081, 'pattern_counts': {'":': 0, '<': 62, '<?xml version=': 0, '>': 64, 'https://': 4, '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': '7235412', 'n_tokens_mistral': 1600, 'n_tokens_neox': 1567, 'n_words': 278}