<commit_before>import utils = require("../common/utils");
import styles = require("./styles/styles");
import React = require("react");
import Radium = require('radium');
import csx = require('csx');
import {BaseComponent} from "./ui";
import * as ui from "./ui";
import {cast,server} from "../socket/socketClient";
import * as commands from "./commands/commands";
import * as types from "../common/types";

import {connect} from "react-redux";
import {StoreState,expandErrors,collapseErrors} from "./state/state";

export interface Props extends React.Props<any> {
    // from react-redux ... connected below
    errorsExpanded?: boolean;
    activeProject?: string;
    inActiveProject?: types.TriState;
    currentFilePath?: string;
    errorsByFilePath?: ErrorsByFilePath;
}
export interface State {
}

/**
 * The singleton status bar
 */
export var statusBar: StatusBar;

@connect((state: StoreState): Props => {
    return {
        errorsExpanded: state.errorsExpanded,
        activeProject: state.activeProject,
        inActiveProject: state.inActiveProject,
        currentFilePath: state.currentFilePath,
        errorsByFilePath: state.errorsByFilePath
    };
})
@ui.Radium
export class StatusBar extends BaseComponent<Props, State>{
    constructor(props:Props){
        super(props);
        this.state = {
        }
    }

    componentDidMount() {
    }

    render(){

        let errorCount = utils.selectMany(Object.keys(this.props.errorsByFilePath).map((k)=>this.props.errorsByFilePath[k])).length;

        let errorPanel = null;
        if (this.props.errorsExpanded){
            errorPanel = <div style={styles.errorsPanel.main}>
            {
                errorCount?
                Object.keys(this.props.errorsByFilePath)
                .filter(filePath=>!!this.props.errorsByFilePath[filePath].length)
                .map((filePath,i)=>{

                    let errors =
                        this.props.errorsByFilePath[filePath]
                            .map((e, j) => (
                                <div key={`${i}:${j}`} style={[styles.hand, styles.errorsPanel.errorDetailsContainer]} onClick={()=>this.openFile(filePath,e)}>
                                    <div style={styles.errorsPanel.errorDetailsContent}>
                                        <div style={styles.errorsPanel.errorMessage}>
                                            🐛({e.from.line+1}:{e.from.ch+1}) {e.message}
                                        </div>
                                        {e.preview?<div style={styles.errorsPanel.errorPreview}>{e.preview}</div>:''}
                                    </div>
                                </div>
                            ));

                    return <div key={i}>
                        <div style={styles.errorsPanel.filePath} onClick={()=>this.openFile(filePath,this.props.errorsByFilePath[filePath][0])}>{filePath}</div>

                        <div style={styles.errorsPanel.perFileList}>
                            {errors}
                        </div>
                    </div>
                }): <div style={styles.errorsPanel.success}>No Errors ❤</div>
            }
            </div>
        }

        let inActiveProjectSection =
            this.props.inActiveProject == types.TriState.Unknown
            ? ''
            : <span style={[styles.statusBarSection]}>
                {this.props.inActiveProject == types.TriState.True
                    ?<span style={[styles.statusBarSuccess,styles.noSelect]} title="File is part of the currently active project. Robots providing code intelligence.">👌</span>
                    :<span style={[styles.statusBarError,styles.noSelect]} title="File is not a part of the currently active project. Robots deactivated.">🚫</span>}
            </span>

        return (
            <div>
                {errorPanel}
                <div style={[styles.statusBar,csx.horizontal,csx.center]}>
                    {/* Left sections */}
                    <span style={[styles.statusBarSection, styles.noSelect]} title="Here have a rose. Because you deserve it.">🌹</span>
                    {this.props.activeProject?<span style={[styles.statusBarSection]}>{this.props.activeProject}</span>:''}
                    {this.props.currentFilePath?<span style={[styles.statusBarSection]}>{this.props.currentFilePath}</span>:''}
                    {inActiveProjectSection}

                    {/* seperator */}
                    <span style={csx.flex}></span>

                    {/* Right sections */}
                    <span style={[styles.statusBarSection, styles.hand, styles.noSelect]} onClick={this.toggleErrors}>
                        {errorCount} ⛔
                    </span>

                </div><commit_msg>style(statusbar) color the number as well<commit_after>import utils = require("../common/utils");
import styles = require("./styles/styles");
import React = require("react");
import Radium = require('radium');
import csx = require('csx');
import {BaseComponent} from "./ui";
import * as ui from "./ui";
import {cast,server} from "../socket/socketClient";
import * as commands from "./commands/commands";
import * as types from "../common/types";

import {connect} from "react-redux";
import {StoreState,expandErrors,collapseErrors} from "./state/state";

export interface Props extends React.Props<any> {
    // from react-redux ... connected below
    errorsExpanded?: boolean;
    activeProject?: string;
    inActiveProject?: types.TriState;
    currentFilePath?: string;
    errorsByFilePath?: ErrorsByFilePath;
}
export interface State {
}

/**
 * The singleton status bar
 */
export var statusBar: StatusBar;

@connect((state: StoreState): Props => {
    return {
        errorsExpanded: state.errorsExpanded,
        activeProject: state.activeProject,
        inActiveProject: state.inActiveProject,
        currentFilePath: state.currentFilePath,
        errorsByFilePath: state.errorsByFilePath
    };
})
@ui.Radium
export class StatusBar extends BaseComponent<Props, State>{
    constructor(props:Props){
        super(props);
        this.state = {
        }
    }

    componentDidMount() {
    }

    render(){

        let errorCount = utils.selectMany(Object.keys(this.props.errorsByFilePath).map((k)=>this.props.errorsByFilePath[k])).length;

        let errorPanel = null;
        if (this.props.errorsExpanded){
            errorPanel = <div style={styles.errorsPanel.main}>
            {
                errorCount?
                Object.keys(this.props.errorsByFilePath)
                .filter(filePath=>!!this.props.errorsByFilePath[filePath].length)
                .map((filePath,i)=>{

                    let errors =
                        this.props.errorsByFilePath[filePath]
                            .map((e, j) => (
                                <div key={`${i}:${j}`} style={[styles.hand, styles.errorsPanel.errorDetailsContainer]} onClick={()=>this.openFile(filePath,e)}>
                                    <div style={styles.errorsPanel.errorDetailsContent}>
                                        <div style={styles.errorsPanel.errorMessage}>
                                            🐛({e.from.line+1}:{e.from.ch+1}) {e.message}
                                        </div>
                                        {e.preview?<div style={styles.errorsPanel.errorPreview}>{e.preview}</div>:''}
                                    </div>
                                </div>
                            ));

                    return <div key={i}>
                        <div style={styles.errorsPanel.filePath} onClick={()=>this.openFile(filePath,this.props.errorsByFilePath[filePath][0])}>{filePath}</div>

                        <div style={styles.errorsPanel.perFileList}>
                            {errors}
                        </div>
                    </div>
                }): <div style={styles.errorsPanel.success}>No Errors ❤</div>
            }
            </div>
        }

        let inActiveProjectSection =
            this.props.inActiveProject == types.TriState.Unknown
            ? ''
            : <span style={[styles.statusBarSection]}>
                {this.props.inActiveProject == types.TriState.True
                    ?<span style={[styles.statusBarSuccess,styles.noSelect]} title="File is part of the currently active project. Robots providing code intelligence.">👌</span>
                    :<span style={[styles.statusBarError,styles.noSelect]} title="File is not a part of the currently active project. Robots deactivated.">🚫</span>}
            </span>

        return (
            <div>
                {errorPanel}
                <div style={[styles.statusBar,csx.horizontal,csx.center]}>
                    {/* Left sections */}
                    <span style={[styles.statusBarSection, styles.noSelect]} title="Here have a rose. Because you deserve it.">🌹</span>
                    {this.props.activeProject?<span style={[styles.statusBarSection]}>{this.props.activeProject}</span>:''}
                    {this.props.currentFilePath?<span style={[styles.statusBarSection]}>{this.props.currentFilePath}</span>:''}
                    {inActiveProjectSection}

                    {/* seperator */}
                    <span style={csx.flex}></span>

                    {/* Right sections */}
                    <span style={[styles.statusBarSection, styles.hand, styles.noSelect]} onClick={this.toggleErrors}>
                        {errorCount ? <span style={styles.statusBarError}>{errorCount} ⛔</span> : <span style={styles.statusBarSuccess}>{errorCount} ⛔</span> }
                    </span>

                </div>
{'fraction_non_alphanumeric': 0.13302421432251416, 'fraction_numerical': 0.0006182380216383308, 'mean_word_length': 1.8869720404521118, 'pattern_counts': {'":': 0, '<': 85, '<?xml version=': 0, '>': 99, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 18, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3671698', 'n_tokens_mistral': 2543, 'n_tokens_neox': 2453, 'n_words': 465}