<commit_before>/*
 * Copyright 2015 Mirantis, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may
 * not use this file except in compliance with the License. You may obtain
 * a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations
 * under the License.
**/
define([
    'underscore',
    'i18n',
    'react',
    'jsx!views/layout',
    'dispatcher',
    'jsx!component_mixins',
    'react-dnd'
], function(_, i18n, React, layoutComponents, dispatcher, componentMixins, DND) {
    'use strict';

    var RootComponent = React.createClass({
        mixins: [
            componentMixins.dispatcherMixin('updatePageLayout', 'updateTitle'),
            componentMixins.dispatcherMixin('showDefaultPasswordWarning', 'showDefaultPasswordWarning')
        ],
        showDefaultPasswordWarning: function() {
            this.setState({showDefaultPasswordWarning: true});
        },
        hideDefaultPasswordWarning: function() {
            this.setState({showDefaultPasswordWarning: false});
        },
        getInitialState: function() {
            return {showDefaultPasswordWarning: false};
        },
        setPage: function(Page, pageOptions) {
            this.setState({
                Page: Page,
                pageOptions: pageOptions
            });
            return this.refs.page;
        },
        updateTitle: function() {
            var Page = this.state.Page,
                title = _.isFunction(Page.title) ? Page.title(this.state.pageOptions) : Page.title;
            document.title = i18n('common.title') + (title ? ' - ' + title : '');
        },
        componentDidUpdate: function() {
            dispatcher.trigger('updatePageLayout');
        },
        render: function() {
            var Page = this.state.Page;
            if (!Page) return <div className='loading' />;
            return (
                <div id='content-wrapper'>
                    <div className='clamp'>
                        {!Page.hiddenLayout && [
                            <layoutComponents.Navbar key='navbar' ref='navbar' activeElement={Page.navbarActiveElement} {...this.props} />,
                            <layoutComponents.Breadcrumbs key='breadcrumbs' ref='breadcrumbs' {...this.state} />,
                            this.state.showDefaultPasswordWarning && <layoutComponents.DefaultPasswordWarning close={this.hideDefaultPasswordWarning} />
                        ]}
                        <div id='content'>
                            <Page ref='page' {...this.state.pageOptions} />
                        </div>
                        {!Page.hiddenLayout && <div id='footer-spacer'></div>}
                    </div>
                    {!Page.hiddenLayout && <layoutComponents.Footer version={this.props.version} />}
                </div>
            );
        }
    });

    return DND.DragDropContext(DND.HTML5)(RootComponent);
});
<commit_msg>Add key to default password warning component<commit_after>/*
 * Copyright 2015 Mirantis, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may
 * not use this file except in compliance with the License. You may obtain
 * a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations
 * under the License.
**/
define([
    'underscore',
    'i18n',
    'react',
    'jsx!views/layout',
    'dispatcher',
    'jsx!component_mixins',
    'react-dnd'
], function(_, i18n, React, layoutComponents, dispatcher, componentMixins, DND) {
    'use strict';

    var RootComponent = React.createClass({
        mixins: [
            componentMixins.dispatcherMixin('updatePageLayout', 'updateTitle'),
            componentMixins.dispatcherMixin('showDefaultPasswordWarning', 'showDefaultPasswordWarning')
        ],
        showDefaultPasswordWarning: function() {
            this.setState({showDefaultPasswordWarning: true});
        },
        hideDefaultPasswordWarning: function() {
            this.setState({showDefaultPasswordWarning: false});
        },
        getInitialState: function() {
            return {showDefaultPasswordWarning: false};
        },
        setPage: function(Page, pageOptions) {
            this.setState({
                Page: Page,
                pageOptions: pageOptions
            });
            return this.refs.page;
        },
        updateTitle: function() {
            var Page = this.state.Page,
                title = _.isFunction(Page.title) ? Page.title(this.state.pageOptions) : Page.title;
            document.title = i18n('common.title') + (title ? ' - ' + title : '');
        },
        componentDidUpdate: function() {
            dispatcher.trigger('updatePageLayout');
        },
        render: function() {
            var Page = this.state.Page;
            if (!Page) return <div className='loading' />;
            return (
                <div id='content-wrapper'>
                    <div className='clamp'>
                        {!Page.hiddenLayout && [
                            <layoutComponents.Navbar key='navbar' ref='navbar' activeElement={Page.navbarActiveElement} {...this.props} />,
                            <layoutComponents.Breadcrumbs key='breadcrumbs' ref='breadcrumbs' {...this.state} />,
                            this.state.showDefaultPasswordWarning && <layoutComponents.DefaultPasswordWarning key='password-<PASSWORD>' close={this.hideDefaultPasswordWarning} />
                        ]}
                        <div id='content'>
                            <Page ref='page' {...this.state.pageOptions} />
                        </div>
                        {!Page.hiddenLayout && <div id='footer-spacer'></div>}
                    </div>
                    {!Page.hiddenLayout && <layoutComponents.Footer version={this.props.version} />}
                </div>
            );
        }
    });

    return DND.DragDropContext(DND.HTML5)(RootComponent);
});

{'fraction_non_alphanumeric': 0.1178985949908369, 'fraction_numerical': 0.004581551618814905, 'mean_word_length': 2.027739251040222, 'pattern_counts': {'":': 0, '<': 32, '<?xml version=': 0, '>': 32, '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': '6513695', 'n_tokens_mistral': 1683, 'n_tokens_neox': 1636, 'n_words': 389}