<commit_before>import * as React from 'react';
import * as ReactGridLayout from 'react-grid-layout';
import { action, extendObservable, computed, observable, toJS } from 'mobx';
import { observer } from 'mobx-react';
import { Menu, MainButton, ChildButton } from 'react-mfb';
import { unset, find } from 'lodash';

import { Dialog, DialogType, DialogFooter } from 'office-ui-fabric-react/lib/Dialog';
import { PrimaryButton, DefaultButton } from 'office-ui-fabric-react/lib/Button';

import { WebPartPageSettingsModal } from '../webpart-page-settings-modal';
import { BaseWebPartProps, asScriptedWebPart, asAutoRefreshingWebPart, webPartTypeOptions } from '../webpart';

import { PagesStore, PageSettings, ResponsivePageLayouts, WebPartLayout, WebPartSettings, Util } from '../../models';
import Barista from '../../services/barista';

import './index.css';

const ResponsiveLayout = ReactGridLayout.WidthProvider(ReactGridLayout.Responsive);

@observer
export default class WebPartPage extends React.Component<PageProps, PageState> {
    private webPartInstances = {};

    public constructor(props: PageProps) {
        super(props);

        this.state = {
            showPageSettingsModal: false,
            showPageDeleteConfirmDialog: false,
            gridLayout: this.mapWebPartLayoutToGridLayout(props.currentPage)
        };
    }

    public mapWebPartLayoutToGridLayout(currentPage: PageSettings): ReactGridLayout.Layouts {
        let layouts: Partial<ReactGridLayout.Layouts> = {};

        for (const size of Object.keys(currentPage.layouts)) {
            const webPartLayouts: ResponsivePageLayouts = currentPage.layouts[size];
            const layout: Array<ReactGridLayout.Layout> = [];
            for (const id of Object.keys(webPartLayouts)) {
                const webPart: WebPartSettings = currentPage.webParts[id];
                const webPartLayout: WebPartLayout = webPartLayouts[id];
                layout.push({
                    x: webPartLayout.x,
                    y: webPartLayout.y,
                    w: webPartLayout.w,
                    h: webPartLayout.h,
                    i: id,
                    isDraggable: !webPart.locked,
                    isResizable: !webPart.locked,
                    static: webPart.locked
                });
                layouts[size] = layout;
            }
        }

        return layouts as ReactGridLayout.Layouts;
    }

    componentWillReceiveProps(nextProps: PageProps) {
        if (this.props.currentPage != nextProps.currentPage) {
            this.webPartInstances = [];
            this.setState({
                gridLayout: this.mapWebPartLayoutToGridLayout(nextProps.currentPage)
            });
        }
    }

    public render() {
        const { currentPage, pagesStore } = this.props;
        const { columns, rowHeight, locked } = currentPage;<commit_msg>Feed the grue<commit_after>import * as React from 'react';
import * as ReactGridLayout from 'react-grid-layout';
import { action, extendObservable, computed, observable, toJS } from 'mobx';
import { observer } from 'mobx-react';
import { Menu, MainButton, ChildButton } from 'react-mfb';
import { unset, find } from 'lodash';

import { Dialog, DialogType, DialogFooter } from 'office-ui-fabric-react/lib/Dialog';
import { PrimaryButton, DefaultButton } from 'office-ui-fabric-react/lib/Button';

import { WebPartPageSettingsModal } from '../webpart-page-settings-modal';
import { BaseWebPartProps, asScriptedWebPart, asAutoRefreshingWebPart, webPartTypeOptions } from '../webpart';

import { PagesStore, PageSettings, ResponsivePageLayouts, WebPartLayout, WebPartSettings, Util } from '../../models';
import Barista from '../../services/barista';

import './index.css';

const ResponsiveLayout = ReactGridLayout.WidthProvider(ReactGridLayout.Responsive);

@observer
export default class WebPartPage extends React.Component<PageProps, PageState> {
    private webPartInstances = {};

    public constructor(props: PageProps) {
        super(props);

        this.state = {
            showPageSettingsModal: false,
            showPageDeleteConfirmDialog: false,
            gridLayout: this.mapWebPartLayoutToGridLayout(props.currentPage)
        };
    }

    public mapWebPartLayoutToGridLayout(currentPage: PageSettings): ReactGridLayout.Layouts {
        let layouts: Partial<ReactGridLayout.Layouts> = {};

        for (const size of Object.keys(currentPage.layouts)) {
            const webPartLayouts: ResponsivePageLayouts = currentPage.layouts[size];
            const layout: Array<ReactGridLayout.Layout> = [];
            for (const id of Object.keys(webPartLayouts)) {
                const webPart: WebPartSettings = currentPage.webParts[id];
                const webPartLayout: WebPartLayout = webPartLayouts[id];
                layout.push({
                    x: webPartLayout.x,
                    y: webPartLayout.y,
                    w: webPartLayout.w,
                    h: webPartLayout.h,
                    i: id,
                    isDraggable: !webPart.locked,
                    isResizable: !webPart.locked,
                    static: webPart.locked
                });
                layouts[size] = layout;
            }
        }

        return layouts as ReactGridLayout.Layouts;
    }

    componentWillReceiveProps(nextProps: PageProps) {
        if (this.props.currentPage !== nextProps.currentPage) {
            this.webPartInstances = [];
            this.setState({
                gridLayout: this.mapWebPartLayoutToGridLayout(nextProps.currentPage)
            });
        }
    }

    public render() {
        const { currentPage, pagesStore } = this.props;
        const { columns, rowHeight, locked } = currentPage;
{'fraction_non_alphanumeric': 0.10214024708543588, 'fraction_numerical': 0.0, 'mean_word_length': 2.5591331269349844, 'pattern_counts': {'":': 0, '<': 9, '<?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': '6423204', 'n_tokens_mistral': 1574, 'n_tokens_neox': 1516, 'n_words': 339}