<commit_before>import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import { every } from 'lodash';
import queryString from 'querystringify';
import { FormattedMessage } from 'react-intl';
import Modal from './Modal';
import { showModal } from '../actions/activeModal';
import Notification from './Notification';
import IMAGES from '../constants/images';
import * as auth from '../utilities/auth';

require('../styles/reset.global.scss');
require('../styles/style.global.scss');
require('./Main.scss');
require('fixed-data-table-2/dist/fixed-data-table.css');

class Main extends Component {
  componentDidMount() {
    const queryParams = queryString.parse(this.props.location.search);
    const showEditUser = queryParams.edit_user === 'false';
    const {
      dispatch,
      profile: { firstName, lastName },
    } = this.props;
    if ((!showEditUser)
      && (!every([firstName, lastName], Boolean))) {
      dispatch(showModal('edit-user'));
    }
  }
  render() {
    const {
      content, sidebar, notification, loadStatus, env,
    } = this.props;
    if (loadStatus === 'failed') {
      const { tenant } = env;
      return (
        <div className="Main">
          <div className="failedToLoadMessage">
            <div className="message">
              <div className="msgContainer">
                <img src={IMAGES.BRAND.logo} title="Welcome to Akvo Lumen" alt="Welcome to Akvo Lumen" />
                <h1>
                  <FormattedMessage id="you_need_permission_to_access" />: <span id="urlLoc">{ tenant }</span>
                </h1>
                <p>
                  <FormattedMessage id="request_permission_from_your_organisation_admin" /> <button type="button" onClick={() => auth.logout()}><FormattedMessage id="logout" /></button> <FormattedMessage id="to_try_with_another_account" />.
                </p>
              </div>
            </div>
          </div>
          <div className="Main blur">
            {sidebar}
          </div>
        </div>
      );
    }
    return (
      <div className="Main">
        {notification && <Notification {...notification} />}
        {sidebar}
        {content}
        <Modal />
      </div>
    );
  }
}

Main.propTypes = {
  content: PropTypes.object,
  sidebar: PropTypes.object,
  location: PropTypes.object,
  notification: PropTypes.object,
  loadStatus: PropTypes.string,
  env: PropTypes.object,
  dispatch: PropTypes.func.isRequired,
  profile: PropTypes.shape({
    firstName: PropTypes.string,
    lastName: PropTypes.string,
  }).isRequired,
};

function mapStateToProps(state) {
  return {
    loadStatus: state.loadStatus,
    notification: state.notification,
    modalVisible: state.activeModal != null,
    env: state.env,
    profile: state.profile,
  };
}

export default connect(mapStateToProps)(Main);
<commit_msg>[#2619] Fix query args parsing to show modal with user settings<commit_after>import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import { every } from 'lodash';
import { FormattedMessage } from 'react-intl';
import Modal from './Modal';
import { showModal } from '../actions/activeModal';
import Notification from './Notification';
import IMAGES from '../constants/images';
import * as auth from '../utilities/auth';

require('../styles/reset.global.scss');
require('../styles/style.global.scss');
require('./Main.scss');
require('fixed-data-table-2/dist/fixed-data-table.css');

class Main extends Component {
  componentDidMount() {
    const q = new URLSearchParams(this.props.location.search);
    const showEditUser = q.get('edit_user') !== 'false';
    const {
      dispatch,
      profile: { firstName, lastName },
    } = this.props;
    if (showEditUser
      && (!every([firstName, lastName], Boolean))) {
      dispatch(showModal('edit-user'));
    }
  }
  render() {
    const {
      content, sidebar, notification, loadStatus, env,
    } = this.props;
    if (loadStatus === 'failed') {
      const { tenant } = env;
      return (
        <div className="Main">
          <div className="failedToLoadMessage">
            <div className="message">
              <div className="msgContainer">
                <img src={IMAGES.BRAND.logo} title="Welcome to Akvo Lumen" alt="Welcome to Akvo Lumen" />
                <h1>
                  <FormattedMessage id="you_need_permission_to_access" />: <span id="urlLoc">{ tenant }</span>
                </h1>
                <p>
                  <FormattedMessage id="request_permission_from_your_organisation_admin" /> <button type="button" onClick={() => auth.logout()}><FormattedMessage id="logout" /></button> <FormattedMessage id="to_try_with_another_account" />.
                </p>
              </div>
            </div>
          </div>
          <div className="Main blur">
            {sidebar}
          </div>
        </div>
      );
    }
    return (
      <div className="Main">
        {notification && <Notification {...notification} />}
        {sidebar}
        {content}
        <Modal />
      </div>
    );
  }
}

Main.propTypes = {
  content: PropTypes.object,
  sidebar: PropTypes.object,
  location: PropTypes.object,
  notification: PropTypes.object,
  loadStatus: PropTypes.string,
  env: PropTypes.object,
  dispatch: PropTypes.func.isRequired,
  profile: PropTypes.shape({
    firstName: PropTypes.string,
    lastName: PropTypes.string,
  }).isRequired,
};

function mapStateToProps(state) {
  return {
    loadStatus: state.loadStatus,
    notification: state.notification,
    modalVisible: state.activeModal != null,
    env: state.env,
    profile: state.profile,
  };
}

export default connect(mapStateToProps)(Main);

{'fraction_non_alphanumeric': 0.14528432732316227, 'fraction_numerical': 0.0017337031900138697, 'mean_word_length': 2.714745653573728, 'pattern_counts': {'":': 0, '<': 57, '<?xml version=': 0, '>': 59, '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': '3284809', 'n_tokens_mistral': 1682, 'n_tokens_neox': 1671, 'n_words': 377}