<commit_before>import React from 'react';
import ReactDOM from 'react-dom';
import Modal from 'react-modal';

var dbTestConn = {
    host: '192.168.99.100',
    port: 32772,
    database: 'osm',
    user: 'osm',
    password: '<PASSWORD>'
};

const customStyles = {
  content : {
    top                   : '50%',
    left                  : '50%',
    right                 : 'auto',
    bottom                : 'auto',
    marginRight           : '-50%',
    transform             : 'translate(-50%, -50%)'
  }
};


export class Toolbar extends React.Component {
    constructor(props) {
        super(props);
		this.runQuery = this.runQuery.bind(this);
		this.saveConnection = this.saveConnection(this);
		this.connectDatabase = this.connectDatabase.bind(this);
		this.state = {
			editConnection: false
		};
    }

    connectDatabase() {
		this.setState({editConnection: true});
        this.props.db.connect(dbTestConn);
    }

    runQuery() {
		window.events.publish('runQuery', {});
    }

    saveConnection() {
		//TODO: Find better name for editConnection
		this.setState({editConnection: false});
    }

	render() {
		return <div className="toolbar-container">
			<button onClick={this.runQuery} className="toolbar-button toolbar-button-primary">
				<i className="fa fa-play"></i>
				<span>Run</span>
			</button>
			<button onClick={this.connectDatabase} className="toolbar-button">
				<i className="toolbar-icon fa fa-database"></i>
				<span>Connect</span>
			</button>
			<Modal
			  isOpen={this.state.editConnection}
			  className="dark-modal"
			  overlayClassName="dark-overlay"
			  onRequestClose={this.saveConnection}
			>
			  <h1>Hi Guys! Please set the connection details</h1>
			</Modal>

		</div>;
	}
}<commit_msg>Implement connection dialog<commit_after>import React from 'react';
import ReactDOM from 'react-dom';
import Modal from 'react-modal';

var dbTestConn = {
    host: '192.168.99.100',
    port: 32772,
    database: 'osm',
    user: 'osm',
    password: '<PASSWORD>'
};

const customStyles = {
  content : {
    top                   : '50%',
    left                  : '50%',
    right                 : 'auto',
    bottom                : 'auto',
    marginRight           : '-50%',
    transform             : 'translate(-50%, -50%)'
  }
};


export class Toolbar extends React.Component {
    constructor(props) {
        super(props);
		this.runQuery = this.runQuery.bind(this);
		this.saveConnection = this.saveConnection.bind(this);
		this.showEditConnectionModal = this.showEditConnectionModal.bind(this);
		this.closeEditConnectionModal = this.closeEditConnectionModal.bind(this);
		this.state = {
			editConnection: false,
			connection: {
                host: '192.168.99.100',
                port: 32772,
                database: 'osm',
                user: 'osm',
                password: '<PASSWORD>'
			}
		};
    }

    showEditConnectionModal() {
		this.setState({editConnection: true});
    }

    closeEditConnectionModal() {
		this.setState({editConnection: false});
    }

    runQuery() {
		window.events.publish('runQuery', {});
    }

    saveConnection() {
		//TODO: Find better name for editConnection
		this.setState({editConnection: false});
        this.props.db.connect(this.state.connection);
        console.log('Connected', this.state.connection);
    }

	render() {
		return <div className="toolbar-container">
			<button onClick={this.runQuery} className="toolbar-button toolbar-button-primary">
				<i className="fa fa-play"></i>
				<span>Run</span>
			</button>
			<button onClick={this.showEditConnectionModal} className="toolbar-button">
				<i className="toolbar-icon fa fa-database"></i>
				<span>Connect</span>
			</button>
			<Modal
			  isOpen={this.state.editConnection}
			  className="dark-modal"
			  overlayClassName="dark-overlay"
			  onRequestClose={this.saveConnection}
			>
			  <h1>Hi Guys! Please set the connection details</h1>
              <button onClick={this.closeEditConnectionModal}>Close Modal...</button>
		<section class="postgis-form">
        <div>
			<input type="text" placeholder="pg_hostname" value={this.state.connection.host} />
			<input type="text" placeholder="database_name" value={this.state.connection.database} />
            <input type="text" placeholder="pg_port" value={this.state.connection.port} />
			<input type="text" placeholder="pg_username" value={this.state.connection.user} />
            <input type="password" placeholder="<PASSWORD>" value={this.state.connection.password} />
        </div>
		</section>
              <button onClick={this.saveConnection}>Save Connection</button>
			</Modal>

		</div>;
	}
}
{'fraction_non_alphanumeric': 0.14803690195237074, 'fraction_numerical': 0.015447328899377817, 'mean_word_length': 2.756647864625302, 'pattern_counts': {'":': 0, '<': 56, '<?xml version=': 0, '>': 56, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 3, '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': '3046175', 'n_tokens_mistral': 1571, 'n_tokens_neox': 1386, 'n_words': 265}