<commit_before>import React from "react";
import PropTypes from "prop-types";
import Immutable from "immutable";
import { actionCreators } from "../actions/actions.js";
import { connect } from "react-redux";
import { get, getIn } from "../utils.js";
import * as generalSelectors from "../redux/selectors/general-selectors.js";
import * as atomUtils from "../redux/utils/atom-utils.js";
import * as processUtils from "../redux/utils/process-utils.js";
import * as connectionSelectors from "../redux/selectors/connection-selectors.js";
import { Elm } from "../../elm/RatingView.elm";

import WonAtomIcon from "./atom-icon.jsx";
import WonDescriptionViewer from "./details/viewer/description-viewer.jsx";
import { details } from "../../config/detail-definitions.js";
import "~/style/_atom-content-persona.scss";
import ElmReact from "./elm-react";

const mapStateToProps = (state, ownProps) => {
  const connectionUri = generalSelectors.getConnectionUriFromRoute(state);
  const connection = connectionSelectors.getOwnedConnectionByUri(
    state,
    connectionUri
  );
  const ownAtom = generalSelectors.getOwnedAtomByConnectionUri(
    state,
    connectionUri
  );

  const ratingConnectionUri =
    get(connection, "targetAtomUri") == ownProps.holdsUri &&
    atomUtils.isHeld(ownAtom)
      ? connectionUri
      : null;

  const post = ownProps.holdsUri && getIn(state, ["atoms", ownProps.holdsUri]);
  const personaUri = atomUtils.getHeldByUri(post);
  const persona = post ? getIn(state, ["atoms", personaUri]) : undefined;

  const personaHasHolderSocket = atomUtils.hasHolderSocket(persona);
  const personaHolds = personaHasHolderSocket && get(persona, "holds");
  const personaVerified =
    personaHolds && personaHolds.includes(ownProps.holdsUri);

  const personaHasReviewSocket = atomUtils.hasReviewSocket(persona);
  const aggregateRating =
    personaHasReviewSocket && getIn(persona, ["rating", "aggregateRating"]);

  const personaHasBuddySocket = atomUtils.hasBuddySocket(persona);
  const personaBuddies = personaHasBuddySocket && get(persona, "buddies");

  const process = get(state, "process");

  return {
    holdsUri: ownProps.holdsUri,
    post,
    personaUri,
    postIsOwned: generalSelectors.isAtomOwned(state, ownProps.holdsUri),
    postHasHoldableSocket: atomUtils.hasHoldableSocket(post),
    personaLoading: !persona || processUtils.isAtomLoading(process, personaUri),
    personaFailedToLoad:
      persona && processUtils.hasAtomFailedToLoad(process, personaUri),
    personaName: getIn(persona, ["content", "personaName"]),
    personaDescription: getIn(persona, ["content", "description"]),
    personaWebsite: getIn(persona, ["content", "website"]),
    personaVerified,
    personaHoldsSize: personaHolds ? personaHolds.size : 0,
    personaBuddySize: personaBuddies ? personaBuddies.size : 0,
    personaHasReviewSocket,
    personaHasHolderSocket,
    personaHasBuddySocket,
    reviewCount:
      personaHasReviewSocket && getIn(persona, ["rating", "reviewCount"]),
    aggregateRatingString: aggregateRating && aggregateRating.toFixed(1),
    aggregateRatingRounded: aggregateRating ? Math.round(aggregateRating) : 0,
    ratingConnectionUri: ratingConnectionUri,
  };
};

const mapDispatchToProps = dispatch => {
  return {
    routerGo: (path, props) => {
      dispatch(actionCreators.router__stateGo(path, props));
    },
    selectTab: (atomUri, tab) => {
      dispatch(
        actionCreators.atoms__selectTab(
          Immutable.fromJS({ atomUri: atomUri, selectTab: tab })
        )
      );
    },
    hideModalDialog: () => {
      dispatch(actionCreators.view__hideModalDialog());
    },
    showModalDialog: payload => {
      dispatch(actionCreators.view__showModalDialog(payload));
    },
    personaDisconnect: (ownPersonaUri, theirPersonaUri) => {
      dispatch(
        actionCreators.personas__disconnect(ownPersonaUri, theirPersonaUri)
      );
    },
  };
};

class WonAtomContentPersona extends React.Component {
  render() {
    let personaNameElement;
    if (this.props.personaName) {
      const verificationElement = this.props.personaVerified ? (
        <span
          className="ac-persona__header__name__verification ac-persona__header__name__verification--verified"
          title="The Persona-Relation of this Post is verified by the Persona"
        >
          Verified
        </span>
      ) : (
        <span
          className="ac-persona__header__name__verification ac-persona__header__name__verification--unverified"
          title="The Persona-Relation of this Post is NOT verified by the Persona"
        >
          Unverified!
        </span>
      );

      personaNameElement = (
        <div className="ac-persona__header__name">
          <span className="ac-persona__header__name__label">
            {this.props.personaName}
          </span>
          {verificationElement}
        </div>
      );
    }

    const websiteFragment = this.props.personaWebsite && (
      <React.Fragment>
        <div className="ac-persona__websitelabel">Website:</div>
        <a
          className="ac-persona__websitelink"
          target="_blank"
          rel="noopener noreferrer"
          href="{this.props.personaWebsite}"
        >
          {this.props.personaWebsite}
        </a>
      </React.Fragment>
    );

    return (
      <won-atom-content-persona>
        <div className="ac-persona__header">
          {!this.props.personaLoading && (
            <WonAtomIcon atomUri={this.props.personaUri} />
          )}<commit_msg>Fix Persona Website link in atom-content-persona<commit_after>import React from "react";
import PropTypes from "prop-types";
import Immutable from "immutable";
import { actionCreators } from "../actions/actions.js";
import { connect } from "react-redux";
import { get, getIn } from "../utils.js";
import * as generalSelectors from "../redux/selectors/general-selectors.js";
import * as atomUtils from "../redux/utils/atom-utils.js";
import * as processUtils from "../redux/utils/process-utils.js";
import * as connectionSelectors from "../redux/selectors/connection-selectors.js";
import { Elm } from "../../elm/RatingView.elm";

import WonAtomIcon from "./atom-icon.jsx";
import WonDescriptionViewer from "./details/viewer/description-viewer.jsx";
import { details } from "../../config/detail-definitions.js";
import "~/style/_atom-content-persona.scss";
import ElmReact from "./elm-react";

const mapStateToProps = (state, ownProps) => {
  const connectionUri = generalSelectors.getConnectionUriFromRoute(state);
  const connection = connectionSelectors.getOwnedConnectionByUri(
    state,
    connectionUri
  );
  const ownAtom = generalSelectors.getOwnedAtomByConnectionUri(
    state,
    connectionUri
  );

  const ratingConnectionUri =
    get(connection, "targetAtomUri") == ownProps.holdsUri &&
    atomUtils.isHeld(ownAtom)
      ? connectionUri
      : null;

  const post = ownProps.holdsUri && getIn(state, ["atoms", ownProps.holdsUri]);
  const personaUri = atomUtils.getHeldByUri(post);
  const persona = post ? getIn(state, ["atoms", personaUri]) : undefined;

  const personaHasHolderSocket = atomUtils.hasHolderSocket(persona);
  const personaHolds = personaHasHolderSocket && get(persona, "holds");
  const personaVerified =
    personaHolds && personaHolds.includes(ownProps.holdsUri);

  const personaHasReviewSocket = atomUtils.hasReviewSocket(persona);
  const aggregateRating =
    personaHasReviewSocket && getIn(persona, ["rating", "aggregateRating"]);

  const personaHasBuddySocket = atomUtils.hasBuddySocket(persona);
  const personaBuddies = personaHasBuddySocket && get(persona, "buddies");

  const process = get(state, "process");

  return {
    holdsUri: ownProps.holdsUri,
    post,
    personaUri,
    postIsOwned: generalSelectors.isAtomOwned(state, ownProps.holdsUri),
    postHasHoldableSocket: atomUtils.hasHoldableSocket(post),
    personaLoading: !persona || processUtils.isAtomLoading(process, personaUri),
    personaFailedToLoad:
      persona && processUtils.hasAtomFailedToLoad(process, personaUri),
    personaName: getIn(persona, ["content", "personaName"]),
    personaDescription: getIn(persona, ["content", "description"]),
    personaWebsite: getIn(persona, ["content", "website"]),
    personaVerified,
    personaHoldsSize: personaHolds ? personaHolds.size : 0,
    personaBuddySize: personaBuddies ? personaBuddies.size : 0,
    personaHasReviewSocket,
    personaHasHolderSocket,
    personaHasBuddySocket,
    reviewCount:
      personaHasReviewSocket && getIn(persona, ["rating", "reviewCount"]),
    aggregateRatingString: aggregateRating && aggregateRating.toFixed(1),
    aggregateRatingRounded: aggregateRating ? Math.round(aggregateRating) : 0,
    ratingConnectionUri: ratingConnectionUri,
  };
};

const mapDispatchToProps = dispatch => {
  return {
    routerGo: (path, props) => {
      dispatch(actionCreators.router__stateGo(path, props));
    },
    selectTab: (atomUri, tab) => {
      dispatch(
        actionCreators.atoms__selectTab(
          Immutable.fromJS({ atomUri: atomUri, selectTab: tab })
        )
      );
    },
    hideModalDialog: () => {
      dispatch(actionCreators.view__hideModalDialog());
    },
    showModalDialog: payload => {
      dispatch(actionCreators.view__showModalDialog(payload));
    },
    personaDisconnect: (ownPersonaUri, theirPersonaUri) => {
      dispatch(
        actionCreators.personas__disconnect(ownPersonaUri, theirPersonaUri)
      );
    },
  };
};

class WonAtomContentPersona extends React.Component {
  render() {
    let personaNameElement;
    if (this.props.personaName) {
      const verificationElement = this.props.personaVerified ? (
        <span
          className="ac-persona__header__name__verification ac-persona__header__name__verification--verified"
          title="The Persona-Relation of this Post is verified by the Persona"
        >
          Verified
        </span>
      ) : (
        <span
          className="ac-persona__header__name__verification ac-persona__header__name__verification--unverified"
          title="The Persona-Relation of this Post is NOT verified by the Persona"
        >
          Unverified!
        </span>
      );

      personaNameElement = (
        <div className="ac-persona__header__name">
          <span className="ac-persona__header__name__label">
            {this.props.personaName}
          </span>
          {verificationElement}
        </div>
      );
    }

    const websiteFragment = this.props.personaWebsite && (
      <React.Fragment>
        <div className="ac-persona__websitelabel">Website:</div>
        <a
          className="ac-persona__websitelink"
          target="_blank"
          rel="noopener noreferrer"
          href={this.props.personaWebsite}
        >
          {this.props.personaWebsite}
        </a>
      </React.Fragment>
    );

    return (
      <won-atom-content-persona>
        <div className="ac-persona__header">
          {!this.props.personaLoading && (
            <WonAtomIcon atomUri={this.props.personaUri} />
          )}
{'fraction_non_alphanumeric': 0.11662911221270843, 'fraction_numerical': 0.0007210455159981974, 'mean_word_length': 3.5032467532467533, 'pattern_counts': {'":': 0, '<': 37, '<?xml version=': 0, '>': 51, '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': '5632312', 'n_tokens_mistral': 3309, 'n_tokens_neox': 3277, 'n_words': 607}