<commit_before>const React = require('react');
const dispatcher = require('../dispatcher');
import {isUndefined} from 'lodash/lang';
import confirm from './confirm';
//Empty compoennt.
const Empty = props => <div data-focus='empty'></div>;
Empty.displayName = 'Empty';

module.exports = {
    render: require('./render'),
    builtInStore: require('./built-in-store'),
    actionBuilder: require('./action-builder'),
    clear: require('./clear'),
    mountedComponents: require('./mounted-components'),
    /**
     * Change application mode.
     * @param  {string} newMode      - New application mode.
     * @param  {string} previousMode - Previous mode.
     */
    changeMode(newMode, previousMode){
        const mode = {newMode: newMode, previousMode: previousMode};
        dispatcher.handleViewAction({data: {mode: mode}, type: 'update'});
    },
    /**
     * Change application route (maybe not the wole route but a route's group.)
     * @param  {string} newRoute - new route name.
     */
    changeRoute(newRoute){
        dispatcher.handleViewAction({data: {route: newRoute}, type: 'update'});
    },
    /**
     * Set component to application's header.
     * @param {ReactComponent} cartridge     component injected in the cartridge
     * @param {ReactComponent} summary       component injected in the summary bar
     * @param {ReactComponent} actions       arrays of cartridge actions
     * @param {ReactComponent} barLeft       component injected in the left bar
     * @param {ReactComponent} canDeploy     indicates wether the cartridge can deploy or not
     * @param {ReactComponent} barRight      component injected in the right bar
     * @param {ReactComponent} EmptyComponent Empty component
     */
    setHeader({cartridge, summary, actions, barLeft, canDeploy, barRight, EmptyComponent = Empty}) {
        const data = {
            cartridgeComponent: cartridge || {component: EmptyComponent},
            summaryComponent: summary || {component: EmptyComponent},
            actions: actions || {primary: [], secondary: []},
            barContentLeftComponent: barLeft || {component: EmptyComponent},
            canDeploy: isUndefined(canDeploy) ? true : canDeploy
        };

        if (barRight) {
            data.barContentRightComponent = barRight;
        }

        dispatcher.handleViewAction({data, type: 'update'});
    },
    /**<commit_msg>[New Feature] Add method to set the header partialy  (#350)<commit_after>const React = require('react');
const dispatcher = require('../dispatcher');
import {isUndefined} from 'lodash/lang';
import confirm from './confirm';
//Empty compoennt.
const Empty = props => <div data-focus='empty'></div>;
Empty.displayName = 'Empty';

module.exports = {
    render: require('./render'),
    builtInStore: require('./built-in-store'),
    actionBuilder: require('./action-builder'),
    clear: require('./clear'),
    mountedComponents: require('./mounted-components'),
    /**
     * Change application mode.
     * @param  {string} newMode      - New application mode.
     * @param  {string} previousMode - Previous mode.
     */
    changeMode(newMode, previousMode){
        const mode = {newMode: newMode, previousMode: previousMode};
        dispatcher.handleViewAction({data: {mode: mode}, type: 'update'});
    },
    /**
     * Change application route (maybe not the wole route but a route's group.)
     * @param  {string} newRoute - new route name.
     */
    changeRoute(newRoute){
        dispatcher.handleViewAction({data: {route: newRoute}, type: 'update'});
    },
    /**
     * Set component to application's header.
     * @param {ReactComponent} cartridge     component injected in the cartridge
     * @param {ReactComponent} summary       component injected in the summary bar
     * @param {ReactComponent} actions       arrays of cartridge actions
     * @param {ReactComponent} barLeft       component injected in the left bar
     * @param {ReactComponent} canDeploy     indicates wether the cartridge can deploy or not
     * @param {ReactComponent} barRight      component injected in the right bar
     * @param {ReactComponent} EmptyComponent Empty component
     */
    setHeader({cartridge, summary, actions, barLeft, canDeploy, barRight, EmptyComponent = Empty}) {
        const data = {
            cartridgeComponent: cartridge || {component: EmptyComponent},
            summaryComponent: summary || {component: EmptyComponent},
            actions: actions || {primary: [], secondary: []},
            barContentLeftComponent: barLeft || {component: EmptyComponent},
            canDeploy: isUndefined(canDeploy) ? true : canDeploy
        };

        if (barRight) {
            data.barContentRightComponent = barRight;
        }

        dispatcher.handleViewAction({data, type: 'update'});
    },
    /**
     * Set component to application's header with only the component gived in parameter.
     * @param {ReactComponent} cartridge     component injected in the cartridge
     * @param {ReactComponent} summary       component injected in the summary bar
     * @param {ReactComponent} actions       arrays of cartridge actions
     * @param {ReactComponent} barLeft       component injected in the left bar
     * @param {ReactComponent} canDeploy     indicates wether the cartridge can deploy or not
     * @param {ReactComponent} barRight      component injected in the right bar
     * @param {ReactComponent} EmptyComponent Empty component
     */
    setPartialHeader({cartridge, summary, actions, barLeft, barRight, canDeploy}) {
        const data = {
            canDeploy: isUndefined(canDeploy) ? true : canDeploy
        };
    
        if(cartridge) {
            data.cartridgeComponent = cartridge;
        }
        if(summary) {
            data.summaryComponent = summary;
        }
        if(actions) {
            data.actions = actions;
        }
        if(barLeft) {
            data.barContentLeftComponent = barLeft;
        }
        if(barRight) {
            data.barContentRightComponent = barRight;
        }
    
        dispatcher.handleViewAction({data, type: 'update'});
    }
    /**
{'fraction_non_alphanumeric': 0.11183355006501951, 'fraction_numerical': 0.00048764629388816646, 'mean_word_length': 2.788793103448276, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, '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': '5362219', 'n_tokens_mistral': 1641, 'n_tokens_neox': 1579, 'n_words': 479}