<commit_before>import React, { Component } from 'react';
import { connect } from 'react-redux';
import ReactRedirect from 'react-redirect'
import FlatButton from 'material-ui/FlatButton';
import Dialog from 'material-ui/Dialog';
import google from './google.svg';
import github from './github.svg';
import PropTypes from 'prop-types';
import _ from 'lodash';

import selectors from '../../redux/selectors';
import { selectAuthProvider, setAuthProvider } from '../../redux/ducks/app'
import { authenticate } from '../../redux/ducks/girder'

import './index.css'

class OauthRedirect extends Component {
  render = () => {
    const {providers, provider} = this.props;

    if (!_.isNil(providers) && !_.isNil(providers) && _.has(providers, provider)) {
      const url = providers[provider];
      return (
           <ReactRedirect location={url}/>
      );
    } else {
      return (null);
    }
  }
}

OauthRedirect.propTypes = {
    providers: PropTypes.object,
    provider: PropTypes.string
  }

OauthRedirect.defaultProps = {
  providers: {},
  provider: null
}

function redirectMapStateToProps(state, ownProps) {
  const providers = selectors.girder.getOauthProviders(state);
  const provider = selectors.app.getOauthProvider(state);

  return {
    providers,
    provider
  }
}
OauthRedirect = connect(redirectMapStateToProps)(OauthRedirect);

class SelectLoginProvider extends Component {
  constructor(props) {
    super(props)

    this.state = {
      open: false
    }
  }

  componentWillReceiveProps = (nextProps) => {
    const {open} = nextProps;
    this.setState({
      open
    });
  }

  handleOpen = () => {
    this.setState({open: true});
  };

  handleClose = () => {
    this.setState({open: false});
    this.props.dispatch(selectAuthProvider(false))
  };

  handleGoogle = () => {
    this.props.dispatch(selectAuthProvider(false))
    this.props.dispatch(authenticate(this.props.token))
    this.props.dispatch(setAuthProvider('Google'))
  }

  handleGitHub = () => {
    this.props.dispatch(selectAuthProvider(false))
    this.props.dispatch(authenticate(this.props.token))
    this.props.dispatch(setAuthProvider('GitHub'))
  }

  render = () => {

  const actions = [
    <FlatButton
      label="Cancel"
      primary={true}
      onTouchTap={this.handleClose}
    />]

    return (
      <Dialog
        title="Select a login provider. You'll be taken to the provider to authenticate."

        actions={actions}
        modal={false}
        open={this.state.open}
        onRequestClose={this.handleClose}
      >
      <FlatButton icon={<img className='mdb-google' src={google} alt="google" />}
        onTouchTap={this.handleGoogle}
        label='Sign in with Google'
        labelPosition='after' />
      <FlatButton icon={<img className='mdb-github' src={github} alt="github" />}
        onTouchTap={this.handleGitHub}
        label='Sign in with GitHub'
         labelPosition='after' />
      </Dialog>
    );

  }
}

function selectLoginProviderMapStateToProps(state, ownProps) {
  const open = selectors.app.selectAuthProvider(state);

  return {
    open,
  }
}
SelectLoginProvider = connect(selectLoginProviderMapStateToProps)(SelectLoginProvider)

export {
  OauthRedirect,
  SelectLoginProvider
}<commit_msg>Disable GitHub provider for now<commit_after>import React, { Component } from 'react';
import { connect } from 'react-redux';
import ReactRedirect from 'react-redirect'
import FlatButton from 'material-ui/FlatButton';
import Dialog from 'material-ui/Dialog';
import google from './google.svg';
import github from './github.svg';
import PropTypes from 'prop-types';
import _ from 'lodash';

import selectors from '../../redux/selectors';
import { selectAuthProvider, setAuthProvider } from '../../redux/ducks/app'
import { authenticate } from '../../redux/ducks/girder'

import './index.css'

class OauthRedirect extends Component {
  render = () => {
    const {providers, provider} = this.props;

    if (!_.isNil(providers) && !_.isNil(providers) && _.has(providers, provider)) {
      const url = providers[provider];
      return (
           <ReactRedirect location={url}/>
      );
    } else {
      return (null);
    }
  }
}

OauthRedirect.propTypes = {
    providers: PropTypes.object,
    provider: PropTypes.string
  }

OauthRedirect.defaultProps = {
  providers: {},
  provider: null
}

function redirectMapStateToProps(state, ownProps) {
  const providers = selectors.girder.getOauthProviders(state);
  const provider = selectors.app.getOauthProvider(state);

  return {
    providers,
    provider
  }
}
OauthRedirect = connect(redirectMapStateToProps)(OauthRedirect);

const contentStyle = {
  maxWidth: '300px'
}

class SelectLoginProvider extends Component {
  constructor(props) {
    super(props)

    this.state = {
      open: false
    }
  }

  componentWillReceiveProps = (nextProps) => {
    const {open} = nextProps;
    this.setState({
      open
    });
  }

  handleOpen = () => {
    this.setState({open: true});
  };

  handleClose = () => {
    this.setState({open: false});
    this.props.dispatch(selectAuthProvider(false))
  };

  handleGoogle = () => {
    this.props.dispatch(selectAuthProvider(false))
    this.props.dispatch(authenticate(this.props.token))
    this.props.dispatch(setAuthProvider('Google'))
  }

  handleGitHub = () => {
    this.props.dispatch(selectAuthProvider(false))
    this.props.dispatch(authenticate(this.props.token))
    this.props.dispatch(setAuthProvider('GitHub'))
  }

  render = () => {

  const actions = [
    <FlatButton
      label="Cancel"
      primary={true}
      onTouchTap={this.handleClose}
    />]

    // title="Select a login provider. You'll be taken to the provider to authenticate.
    return (
      <Dialog
       contentStyle={contentStyle}
        actions={actions}
        modal={false}
        open={this.state.open}
        onRequestClose={this.handleClose}
      >
      <FlatButton icon={<img className='mdb-google' src={google} alt="google" />}
        onTouchTap={this.handleGoogle}
        label='Sign in with Google'
        labelPosition='after' />
      {/*<FlatButton icon={<img className='mdb-github' src={github} alt="github" />}
        onTouchTap={this.handleGitHub}
        label='Sign in with GitHub'
         labelPosition='after' />*/}
      </Dialog>
    );

  }
}

function selectLoginProviderMapStateToProps(state, ownProps) {
  const open = selectors.app.selectAuthProvider(state);

  return {
    open,
  }
}
SelectLoginProvider = connect(selectLoginProviderMapStateToProps)(SelectLoginProvider)

export {
  OauthRedirect,
  SelectLoginProvider
}
{'fraction_non_alphanumeric': 0.1352248717174766, 'fraction_numerical': 0.00045276184726833685, 'mean_word_length': 3.3342053629823414, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 33, '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': '912920', 'n_tokens_mistral': 2026, 'n_tokens_neox': 1994, 'n_words': 387}