<commit_before>/**
 * Copyright 2016, GeoSolutions Sas.
 * All rights reserved.
 *
 * This source code is licensed under the BSD-style license found in the
 * LICENSE file in the root directory of this source tree.
 */

const React = require('react');
const Dropzone = require('react-dropzone');
const Spinner = require('react-spinkit');

const LocaleUtils = require('../../utils/LocaleUtils');

const SelectShape = React.createClass({
    propTypes: {
        text: React.PropTypes.oneOfType([React.PropTypes.string, React.PropTypes.element]),
        accept: React.PropTypes.string,
        loading: React.PropTypes.bool,
        onShapeChoosen: React.PropTypes.func,
        onShapeError: React.PropTypes.func,
        error: React.PropTypes.oneOfType([React.PropTypes.string, React.PropTypes.element]),
        errorMessage: React.PropTypes.string
    },
    contextTypes: {
        messages: React.PropTypes.object
    },
    getDefaultProps() {
        return {
            text: "Drop or click to import a local Shape",
            accept: "application/zip",
            onShapeChoosen: () => {},
            onShapeError: () => {},
            errorMessage: "shapefile.error.select"
        };
    },
    render() {
        return (
            (this.props.loading) ? (<div className="btn btn-info" style={{"float": "center"}}> <Spinner spinnerName="circle"/></div>) :
            (<Dropzone rejectClassName="alert-danger" className="alert alert-info" accept={this.props.accept} onDrop={this.checkfile}>
              <div style={{textAlign: "center"}}>{this.props.text}</div>
            </Dropzone>)
            );
    },
    checkfile(files) {
        const allZip = (files.filter((file) => { return file.type !== 'application/zip'; }).length === 0 );
        if (allZip) {
            if (this.props.error) {
                this.props.onShapeError(null);
            }
            this.props.onShapeChoosen(files);
        }else {
            const error = LocaleUtils.getMessageById(this.context.messages, this.props.errorMessage);
            this.props.onShapeError(error);
        }
    }

});

module.exports = SelectShape;<commit_msg>Fixes #538: fixed shapefile upload on chrome for Windows (#544)<commit_after>/**
 * Copyright 2016, GeoSolutions Sas.
 * All rights reserved.
 *
 * This source code is licensed under the BSD-style license found in the
 * LICENSE file in the root directory of this source tree.
 */

const React = require('react');
const Dropzone = require('react-dropzone');
const Spinner = require('react-spinkit');

const LocaleUtils = require('../../utils/LocaleUtils');

const SelectShape = React.createClass({
    propTypes: {
        text: React.PropTypes.oneOfType([React.PropTypes.string, React.PropTypes.element]),
        loading: React.PropTypes.bool,
        onShapeChoosen: React.PropTypes.func,
        onShapeError: React.PropTypes.func,
        error: React.PropTypes.oneOfType([React.PropTypes.string, React.PropTypes.element]),
        errorMessage: React.PropTypes.string
    },
    contextTypes: {
        messages: React.PropTypes.object
    },
    getDefaultProps() {
        return {
            text: "Drop or click to import a local Shape",
            onShapeChoosen: () => {},
            onShapeError: () => {},
            errorMessage: "shapefile.error.select"
        };
    },
    render() {
        return (
            (this.props.loading) ? (<div className="btn btn-info" style={{"float": "center"}}> <Spinner spinnerName="circle"/></div>) :
            (<Dropzone rejectClassName="alert-danger" className="alert alert-info" onDrop={this.checkfile}>
              <div style={{textAlign: "center"}}>{this.props.text}</div>
            </Dropzone>)
            );
    },
    checkfile(files) {
        const allZip = (files.filter((file) => { return file.type !== 'application/zip' && file.type !== 'application/x-zip-compressed'; }).length === 0 );
        if (allZip) {
            if (this.props.error) {
                this.props.onShapeError(null);
            }
            this.props.onShapeChoosen(files);
        }else {
            const error = LocaleUtils.getMessageById(this.context.messages, this.props.errorMessage);
            this.props.onShapeError(error);
        }
    }

});

module.exports = SelectShape;
{'fraction_non_alphanumeric': 0.1414611447184737, 'fraction_numerical': 0.0037226617031177293, 'mean_word_length': 2.5295566502463056, 'pattern_counts': {'":': 2, '<': 17, '<?xml version=': 0, '>': 23, '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': '3426856', 'n_tokens_mistral': 1243, 'n_tokens_neox': 1206, 'n_words': 255}