<commit_before>// Dependencies

const {builder} = require('focus-core').component;
const {reduce} = require('lodash/collection');

// Components

const Dropdown = require('../../common/select-action').component;
const ActionContextual = require('../action-contextual').component;
const TopicDisplayer = require('../../common/topic-displayer').component;

// Mixins

const translationMixin = require('../../common/i18n/mixin');

const ActionBar = {

    /**
    * Display name.
    */
    displayName: 'list-action-bar',

    mixins: [translationMixin],

    /**
    * INit default props
    * @returns {object} Defautkl props.
    */
    getDefaultProps() {
        return {
            selectionStatus: 'none', // none, selected, partial
            selectionAction(selectionStatus) {
                console.warn(selectionStatus);
            }, // Action on selection click
            orderableColumnList: undefined, // [{key:'columnKey', label:'columnLabel'}]
            orderAction(key, order) {
                console.warn(key + '-' + order);
            }, // Action on click on order function
            orderSelected: {},
            facetClickAction(key) {
                console.warn(key);
            }, // Action when click on facet
            facetList: {}, // {facet1: 'Label of facet one', facet2:'Label of facet 2'} List of facets
            groupableColumnList: {}, // {col1: 'Label1', col2: 'Label2'}
            groupAction(key) {
                console.warn(key);
            }, // Action on group function
            groupSelectedKey: undefined, // Defautl grouped key.
            operationList: [], // List of contextual operations
            groupLabelPrefix: '',
            style: require('./style')
        };
    },

    /**
    * @returns {JSX} Selection component.
    * @private
    */
    _getSelectionObject() {
        // Selection datas
        const selectionOperationList = [
            {
                action: this._selectionFunction('selected'),
                label: this.i18n('list.actionBar.selection.all'),
                style: this._getSelectedStyle(this.props.selectionStatus, 'selected')
            },
            {
                action: this._selectionFunction('none'),
                label: this.i18n('list.actionBar.selection.none'),
                style: this._getSelectedStyle(this.props.selectionStatus, 'none')
            }
        ];
        const {style} = this.props;
        return (
            <div style={style.actions.select}>
                <Dropdown iconProps={this._getSelectionObjectIcon()} operationList={selectionOperationList}/>
            </div>
        );
    },

    /**
    * @returns {JSX} Order component.
    * @private
    */
    _getOrderObject() {
        if (this.props.orderableColumnList) {
            const orderSelectedParsedKey = this.props.orderSelected.key + this.props.orderSelected.order;
            const orderOperationList = []; // [{key:'columnKey', order:'asc', label:'columnLabel'}]
            for (const key in this.props.orderableColumnList) {
                const description = this.props.orderableColumnList[key];
                orderOperationList.push({
                    action: this._orderFunction(description.key, description.order),
                    label: description.label,
                    style: this._getSelectedStyle(description.key + description.order, orderSelectedParsedKey)
                });
            }
            const orderIcon = this.props.orderSelected.order ? 'sort-alpha-desc' : 'sort-alpha-asc';
            const {style} = this.props;
            return (
                <div style={style.actions.sort}>
                    <Dropdown iconProps={{name: orderIcon}} key='down' operationList={orderOperationList}/>
                </div>
            );
        }
        return null;
    },

    /**
    * @returns {JSX} Grouping component.<commit_msg>Fix action bar Material sort icon.<commit_after>// Dependencies

const {builder} = require('focus-core').component;
const {reduce} = require('lodash/collection');

// Components

const Dropdown = require('../../common/select-action').component;
const ActionContextual = require('../action-contextual').component;
const TopicDisplayer = require('../../common/topic-displayer').component;

// Mixins

const translationMixin = require('../../common/i18n/mixin');

const ActionBar = {

    /**
    * Display name.
    */
    displayName: 'list-action-bar',

    mixins: [translationMixin],

    /**
    * INit default props
    * @returns {object} Defautkl props.
    */
    getDefaultProps() {
        return {
            selectionStatus: 'none', // none, selected, partial
            selectionAction(selectionStatus) {
                console.warn(selectionStatus);
            }, // Action on selection click
            orderableColumnList: undefined, // [{key:'columnKey', label:'columnLabel'}]
            orderAction(key, order) {
                console.warn(key + '-' + order);
            }, // Action on click on order function
            orderSelected: {},
            facetClickAction(key) {
                console.warn(key);
            }, // Action when click on facet
            facetList: {}, // {facet1: 'Label of facet one', facet2:'Label of facet 2'} List of facets
            groupableColumnList: {}, // {col1: 'Label1', col2: 'Label2'}
            groupAction(key) {
                console.warn(key);
            }, // Action on group function
            groupSelectedKey: undefined, // Defautl grouped key.
            operationList: [], // List of contextual operations
            groupLabelPrefix: '',
            style: require('./style')
        };
    },

    /**
    * @returns {JSX} Selection component.
    * @private
    */
    _getSelectionObject() {
        // Selection datas
        const selectionOperationList = [
            {
                action: this._selectionFunction('selected'),
                label: this.i18n('list.actionBar.selection.all'),
                style: this._getSelectedStyle(this.props.selectionStatus, 'selected')
            },
            {
                action: this._selectionFunction('none'),
                label: this.i18n('list.actionBar.selection.none'),
                style: this._getSelectedStyle(this.props.selectionStatus, 'none')
            }
        ];
        const {style} = this.props;
        return (
            <div style={style.actions.select}>
                <Dropdown iconProps={this._getSelectionObjectIcon()} operationList={selectionOperationList}/>
            </div>
        );
    },

    /**
    * @returns {JSX} Order component.
    * @private
    */
    _getOrderObject() {
        if (this.props.orderableColumnList) {
            const orderSelectedParsedKey = this.props.orderSelected.key + this.props.orderSelected.order;
            const orderOperationList = []; // [{key:'columnKey', order:'asc', label:'columnLabel'}]
            for (const key in this.props.orderableColumnList) {
                const description = this.props.orderableColumnList[key];
                orderOperationList.push({
                    action: this._orderFunction(description.key, description.order),
                    label: description.label,
                    style: this._getSelectedStyle(description.key + description.order, orderSelectedParsedKey)
                });
            }
            const orderIcon = 'sort_by_alpha';
            const {style} = this.props;
            return (
                <div style={style.actions.sort}>
                    <Dropdown iconProps={{name: orderIcon}} key='down' operationList={orderOperationList}/>
                </div>
            );
        }
        return null;
    },

    /**
    * @returns {JSX} Grouping component.
{'fraction_non_alphanumeric': 0.1288005131494548, 'fraction_numerical': 0.003335471456061578, 'mean_word_length': 1.913303437967115, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, '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': '4598809', 'n_tokens_mistral': 2030, 'n_tokens_neox': 1953, 'n_words': 404}