<commit_before>/* This file is part of Indico.
 * Copyright (C) 2002 - 2018 European Organization for Nuclear Research (CERN).
 *
 * Indico is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 3 of the
 * License, or (at your option) any later version.
 *
 * Indico is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Indico; if not, see <http://www.gnu.org/licenses/>.
 */

import React from 'react';
import PropTypes from 'prop-types';
import {bindActionCreators} from 'redux';
import {connect} from 'react-redux';
import {Dimmer, Loader} from 'semantic-ui-react';

import {Preloader} from 'indico/react/util';
import * as bookingsActions from './actions';
import * as bookingsSelectors from './selectors';


const BookingDetailsPreloader = ({bookingId, component: Component, fetchDetails, onClose}) => (
    <Preloader checkCached={state => bookingsSelectors.hasDetails(state, {bookingId})}
               action={() => fetchDetails(bookingId)}
               dimmer={<Dimmer active page><Loader /></Dimmer>}>
        {() => <Component bookingId={bookingId} onClose={onClose} />}
    </Preloader>
);

BookingDetailsPreloader.propTypes = {
    bookingId: PropTypes.number.isRequired,
    fetchDetails: PropTypes.func.isRequired,
    component: PropTypes.func.isRequired,
    onClose: PropTypes.func.isRequired,
};

export default connect(
    null,
    dispatch => bindActionCreators({
        fetchDetails: bookingsActions.fetchBookingDetails,
    }, dispatch)
)(BookingDetailsPreloader);<commit_msg>Make sure new booking is preloaded properly<commit_after>/* This file is part of Indico.
 * Copyright (C) 2002 - 2018 European Organization for Nuclear Research (CERN).
 *
 * Indico is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 3 of the
 * License, or (at your option) any later version.
 *
 * Indico is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Indico; if not, see <http://www.gnu.org/licenses/>.
 */

import React from 'react';
import PropTypes from 'prop-types';
import {bindActionCreators} from 'redux';
import {connect} from 'react-redux';
import {Dimmer, Loader} from 'semantic-ui-react';

import {Preloader} from 'indico/react/util';
import * as bookingsActions from './actions';
import * as bookingsSelectors from './selectors';


const BookingDetailsPreloader = ({bookingId, component: Component, fetchDetails, onClose}) => (
    <Preloader key={bookingId}
               checkCached={state => bookingsSelectors.hasDetails(state, {bookingId})}
               action={() => fetchDetails(bookingId)}
               dimmer={<Dimmer active page><Loader /></Dimmer>}>
        {() => <Component bookingId={bookingId} onClose={onClose} />}
    </Preloader>
);

BookingDetailsPreloader.propTypes = {
    bookingId: PropTypes.number.isRequired,
    fetchDetails: PropTypes.func.isRequired,
    component: PropTypes.func.isRequired,
    onClose: PropTypes.func.isRequired,
};

export default connect(
    null,
    dispatch => bindActionCreators({
        fetchDetails: bookingsActions.fetchBookingDetails,
    }, dispatch)
)(BookingDetailsPreloader);
{'fraction_non_alphanumeric': 0.10387919812548815, 'fraction_numerical': 0.004686279614683676, 'mean_word_length': 4.115845539280959, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '7592228', 'n_tokens_mistral': 1054, 'n_tokens_neox': 1051, 'n_words': 382}