<commit_before>Input = ReactBootstrap.Input
Row = ReactBootstrap.Row
Col = ReactBootstrap.Col
Button = ReactBootstrap.Button
ButtonGroup = ReactBootstrap.ButtonGroup
Panel = ReactBootstrap.Panel
ListGroup = ReactBootstrap.ListGroup
ListGroupItem = ReactBootstrap.ListGroupItem
Glyphicon = ReactBootstrap.Glyphicon
TabbedArea = ReactBootstrap.TabbedArea
TabPane = ReactBootstrap.TabPane

update = React.addons.update

MemberManagementItem = React.createClass
  removeTeam: ->
    apiCall "POST", "/api/group/teacher/leave", {gid: @props.gid, tid: @props.tid}
    .done ((resp) ->
      apiNotify resp
      @props.refresh()
    ).bind this

  switchUserRole: (uid, role) ->
    apiCall "POST", "/api/group/teacher/role_switch", {gid: @props.gid, uid: uid, role: role}
    .done ((resp) ->
      apiNotify resp
      @props.refresh()
    ).bind this

  render: ->
    user = _.first @props.members

    if @props.teacher
      userButton =
      <Button bsStyle="success" className="btn-sq">
        <Glyphicon glyph="user" bsSize="large"/>
        <p className="text-center">Teacher</p>
      </Button>
    else
      userButton =
      <Button bsStyle="primary" className="btn-sq">
        <Glyphicon glyph="user" bsSize="large"/>
        <p className="text-center">User</p>
      </Button>

    if @props.teacher
      switchUser = <Button onClick={@switchUserRole.bind(null, user.uid, "user")}>Make User</Button>
    else
      switchUser = <Button onClick={@switchUserRole.bind(null, user.uid, "teacher")}>Make Teacher</Button>

    <ListGroupItem>
      <Row>
        <Col xs={2}>
          {userButton}
        </Col>
        <Col xs={6}>
          <h4>{user.username}</h4>
          <p>
            <strong>Name:</strong> {user.firstname} {user.lastname}
          </p>
          <p><strong>Email:</strong> {user.email}</p>
        </Col>
        <Col xs={4}>
          <ButtonGroup vertical>
            <Button onClick={@removeTeam}>Remove User</Button>
          </ButtonGroup>
        </Col>
      </Row>
    </ListGroupItem>

MemberInvitePanel = React.createClass
  mixins: [React.addons.LinkedStateMixin]

  propTypes:
    gid: React.PropTypes.string.isRequired

  getInitialState: ->
    role: "member"

  inviteUser: (e) ->
    e.preventDefault()
    apiCall "POST", "/api/group/invite", {gid: @props.gid, email: @state.email, role: @state.role}
    .done ((resp) ->
      apiNotify resp
      @setState update @state, $set: email: ""
      @props.refresh()
    ).bind this

  render: ->
    <Panel>
      <form onSubmit={@inviteUser}>
        <Col xs={8}><commit_msg>Forgot to re-add switch user role.<commit_after>Input = ReactBootstrap.Input
Row = ReactBootstrap.Row
Col = ReactBootstrap.Col
Button = ReactBootstrap.Button
ButtonGroup = ReactBootstrap.ButtonGroup
Panel = ReactBootstrap.Panel
ListGroup = ReactBootstrap.ListGroup
ListGroupItem = ReactBootstrap.ListGroupItem
Glyphicon = ReactBootstrap.Glyphicon
TabbedArea = ReactBootstrap.TabbedArea
TabPane = ReactBootstrap.TabPane

update = React.addons.update

MemberManagementItem = React.createClass
  removeTeam: ->
    apiCall "POST", "/api/group/teacher/leave", {gid: @props.gid, tid: @props.tid}
    .done ((resp) ->
      apiNotify resp
      @props.refresh()
    ).bind this

  switchUserRole: (uid, role) ->
    apiCall "POST", "/api/group/teacher/role_switch", {gid: @props.gid, uid: uid, role: role}
    .done ((resp) ->
      apiNotify resp
      @props.refresh()
    ).bind this

  render: ->
    user = _.first @props.members

    if @props.teacher
      userButton =
      <Button bsStyle="success" className="btn-sq">
        <Glyphicon glyph="user" bsSize="large"/>
        <p className="text-center">Teacher</p>
      </Button>
    else
      userButton =
      <Button bsStyle="primary" className="btn-sq">
        <Glyphicon glyph="user" bsSize="large"/>
        <p className="text-center">User</p>
      </Button>

    if @props.teacher
      switchUser = <Button onClick={@switchUserRole.bind(null, user.uid, "user")}>Make User</Button>
    else
      switchUser = <Button onClick={@switchUserRole.bind(null, user.uid, "teacher")}>Make Teacher</Button>

    <ListGroupItem>
      <Row>
        <Col xs={2}>
          {userButton}
        </Col>
        <Col xs={6}>
          <h4>{user.username}</h4>
          <p>
            <strong>Name:</strong> {user.firstname} {user.lastname}
          </p>
          <p><strong>Email:</strong> {user.email}</p>
        </Col>
        <Col xs={4}>
          <ButtonGroup vertical>
            {switchUser}
            <Button onClick={@removeTeam}>Remove User</Button>
          </ButtonGroup>
        </Col>
      </Row>
    </ListGroupItem>

MemberInvitePanel = React.createClass
  mixins: [React.addons.LinkedStateMixin]

  propTypes:
    gid: React.PropTypes.string.isRequired

  getInitialState: ->
    role: "member"

  inviteUser: (e) ->
    e.preventDefault()
    apiCall "POST", "/api/group/invite", {gid: @props.gid, email: @state.email, role: @state.role}
    .done ((resp) ->
      apiNotify resp
      @setState update @state, $set: email: ""
      @props.refresh()
    ).bind this

  render: ->
    <Panel>
      <form onSubmit={@inviteUser}>
        <Col xs={8}>
{'fraction_non_alphanumeric': 0.14779270633397312, 'fraction_numerical': 0.0023032629558541267, 'mean_word_length': 2.730136005726557, 'pattern_counts': {'":': 0, '<': 85, '<?xml version=': 0, '>': 103, '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': '2268632', 'n_tokens_mistral': 1704, 'n_tokens_neox': 1654, 'n_words': 345}