<commit_before>import React from 'react';
import Screen from '../../lock/screen';
import SocialButtonsPane from '../../field/social/social_buttons_pane';
import LoginPane from '../../database/login_pane';
import PaneSeparator from '../../lock/pane_separator';
import { hasScreen, signUpLink, authWithUsername } from '../../database/index';
import { signIn as databaseSignIn } from '../../database/actions';
import { renderSignedInConfirmation } from '../../lock/signed_in_confirmation';
import LoginSignUpTabs from '../../database/login_sign_up_tabs';
import * as l from '../../lock/index';
import { icon } from '../../ui/input/password_input';
import * as c from '../../field/index';
import { emailDomain } from '../../field/email';
import {
  signIn as enterpriseSignIn,
  startHRD
} from '../../connection/enterprise/actions';
import {
  findADConnectionWithoutDomain,
  isADEnabled,
  isHRDDomain,
  isSSODomain
} from '../../connection/enterprise';


const SingleSignOnNotice = ({children}) => (
  <div className="auth0-sso-notice-container">
    <span dangerouslySetInnerHTML={{__html: icon}} /> {" "}
    <span className="auth0-sso-notice">{children}</span>
  </div>
);

export default class Login extends Screen {

  constructor() {
    super("login");
  }

  renderAuxiliaryPane(lock) {
    return renderSignedInConfirmation(lock);
  }

  renderTabs(model) {
    return this.shouldRenderTabs(model);
  }

  submitHandler(model) {
    if (l.getEnabledConnections(model, "social").count() === l.getEnabledConnections(model).count()) {
      return null;
    }

    if (isHRDDomain(model, c.email(model))) {
      return startHRD;
    }

    return this.isSSOEnabled(model) || l.getEnabledConnections(model, "database").count() === 0
      ? enterpriseSignIn
      : databaseSignIn;
  }

  shouldRenderTabs(lock) {
    return l.getEnabledConnections(lock, "database").count() > 0
      && hasScreen(lock, "signUp")
      && !this.isSSOEnabled(lock);
  }

  isSSOEnabled(model) {
    return isSSODomain(
      model,
      this.usernameStyle(model) === "username"
        ? c.username(model)
        : c.email(model)
    );
  }

  usernameStyle(model) {
    return authWithUsername(model) && !isADEnabled(model)
      ? "username"
      : "email";
  }

  render({model}) {
    const headerText = this.t(model, ["headerText"]) || null;
    const header = headerText && <p>{headerText}</p>;

    const sso = this.isSSOEnabled(model);

    const tabs = this.shouldRenderTabs(model)
      && <LoginSignUpTabs
           key="loginsignup"
           lock={model}
           loginTabLabel={this.t(model, ["loginTabLabel"], {__textOnly: true})}
           signUpLink={signUpLink(model)}
           signUpTabLabel={this.t(model, ["signUpTabLabel"], {__textOnly: true})}
         />;

    const social = !sso && l.getEnabledConnections(model, "social").count() > 0
      && <SocialButtonsPane
           lock={model}
           signUp={false}
           smallButtonsHeader={this.shouldRenderTabs(model) ? '' : this.t(model, ["smallSocialButtonsHeader"], {__textOnly: true})}<commit_msg>Show loading during social only login<commit_after>import React from 'react';
import Screen from '../../lock/screen';
import SocialButtonsPane from '../../field/social/social_buttons_pane';
import LoginPane from '../../database/login_pane';
import PaneSeparator from '../../lock/pane_separator';
import { hasScreen, signUpLink, authWithUsername } from '../../database/index';
import { signIn as databaseSignIn } from '../../database/actions';
import { renderSignedInConfirmation } from '../../lock/signed_in_confirmation';
import LoginSignUpTabs from '../../database/login_sign_up_tabs';
import * as l from '../../lock/index';
import { icon } from '../../ui/input/password_input';
import * as c from '../../field/index';
import { emailDomain } from '../../field/email';
import {
  signIn as enterpriseSignIn,
  startHRD
} from '../../connection/enterprise/actions';
import {
  findADConnectionWithoutDomain,
  isADEnabled,
  isHRDDomain,
  isSSODomain
} from '../../connection/enterprise';


const SingleSignOnNotice = ({children}) => (
  <div className="auth0-sso-notice-container">
    <span dangerouslySetInnerHTML={{__html: icon}} /> {" "}
    <span className="auth0-sso-notice">{children}</span>
  </div>
);

export default class Login extends Screen {

  constructor() {
    super("login");
  }

  renderAuxiliaryPane(lock) {
    return renderSignedInConfirmation(lock);
  }

  renderTabs(model) {
    return this.shouldRenderTabs(model);
  }

  submitHandler(model) {
    if (l.getEnabledConnections(model, "social").count() === l.getEnabledConnections(model).count()) {
      return null;
    }

    if (isHRDDomain(model, c.email(model))) {
      return startHRD;
    }

    return this.isSSOEnabled(model) || l.getEnabledConnections(model, "database").count() === 0
      ? enterpriseSignIn
      : databaseSignIn;
  }

  shouldRenderTabs(lock) {
    return l.getEnabledConnections(lock, "database").count() > 0
      && hasScreen(lock, "signUp")
      && !this.isSSOEnabled(lock);
  }

  isSSOEnabled(model) {
    return isSSODomain(
      model,
      this.usernameStyle(model) === "username"
        ? c.username(model)
        : c.email(model)
    );
  }

  usernameStyle(model) {
    return authWithUsername(model) && !isADEnabled(model)
      ? "username"
      : "email";
  }

  render({model}) {
    const headerText = this.t(model, ["headerText"]) || null;
    const header = headerText && <p>{headerText}</p>;

    const sso = this.isSSOEnabled(model);
    const onlySocial = l.getEnabledConnections(model).count() === l.getEnabledConnections(model, "social").count();

    const tabs = this.shouldRenderTabs(model)
      && <LoginSignUpTabs
           key="loginsignup"
           lock={model}
           loginTabLabel={this.t(model, ["loginTabLabel"], {__textOnly: true})}
           signUpLink={signUpLink(model)}
           signUpTabLabel={this.t(model, ["signUpTabLabel"], {__textOnly: true})}
         />;

    const social = !sso && l.getEnabledConnections(model, "social").count() > 0
      && <SocialButtonsPane
           lock={model}
           showLoading={onlySocial}
           signUp={false}
           smallButtonsHeader={this.shouldRenderTabs(model) ? '' : this.t(model, ["smallSocialButtonsHeader"], {__textOnly: true})}
{'fraction_non_alphanumeric': 0.1610410094637224, 'fraction_numerical': 0.0015772870662460567, 'mean_word_length': 3.3640743289745356, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 25, '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': '3197700', 'n_tokens_mistral': 1960, 'n_tokens_neox': 1945, 'n_words': 370}