<commit_before>import angular from "angular";

import won from "../../won-es6.js";
import Immutable from "immutable";
import { connect2Redux } from "../../won-utils.js";
import { attach, getIn } from "../../utils.js";
import { actionCreators } from "../../actions/actions.js";
import {
  selectNeedByConnectionUri,
  isMessageProposable,
  isMessageClaimable,
  isMessageCancelable,
  isMessageRejectable,
  isMessageRetractable,
  isMessageAcceptable,
  isMessageProposed,
  isMessageClaimed,
  isMessageRejected,
  isMessageAccepted,
  isMessageRetracted,
  isMessageCancelled,
  isMessageCancellationPending,
  isMessageUnread,
} from "../../selectors.js";

import "style/_connection-message-actions.scss";

const serviceDependencies = ["$ngRedux", "$scope"];

function genComponentConf() {
  let template = `
      <button class="won-button--filled thin black"
          ng-if="self.isProposable"
          ng-disabled="self.multiSelectType || self.clicked"
          ng-click="self.sendActionMessage('proposes')">
          {{ self.getProposeLabel() }}
      </button>
      <button class="won-button--filled thin black"
          ng-if="self.isClaimable"
          ng-disabled="self.multiSelectType || self.clicked"
          ng-click="self.sendActionMessage('claims')">
          Claim
      </button>
      <button class="won-button--filled thin red"
          ng-if="self.isAcceptable"
          ng-disabled="self.multiSelectType || self.clicked"
          ng-click="self.sendActionMessage('accepts')">
        Accept
      </button>
      <button class="won-button--filled thin black"
          ng-if="self.isRejectable"
          ng-disabled="self.multiSelectType || self.clicked"
          ng-click="self.sendActionMessage('rejects')">
        Reject
      </button>
      <button class="won-button--filled thin black"
          ng-if="self.isRetractable"
          ng-disabled="self.multiSelectType || self.clicked"
          ng-click="self.sendActionMessage('retracts')">
        Retract
      </button>
      <button class="won-button--filled thin red"
          ng-if="self.isCancelable"
          ng-disabled="self.multiSelectType || self.clicked"
          ng-click="self.sendActionMessage('proposesToCancel')">
        Propose To Cancel
      </button>
      <button class="won-button--filled thin red"
          ng-if="self.isCancellationPending"
          ng-disabled="true">
        Cancellation Pending...
      </button>
      <button class="won-button--filled thin red"
          ng-if="self.isCancelled"
          ng-disabled="true">
        Cancelled
      </button>
      <button class="won-button--filled thin red"
          ng-if="self.isRejected"
          ng-disabled="true">
        Rejected
      </button>
      <button class="won-button--filled thin red"
          ng-if="self.isRetracted"
          ng-disabled="true">
        Retracted
      </button>
    `;

  class Controller {
    constructor(/* arguments = dependency injections */) {
      attach(this, serviceDependencies, arguments);
      this.clicked = false;

      const selectFromState = state => {
        const ownNeed =
          this.connectionUri &&
          selectNeedByConnectionUri(state, this.connectionUri);
        const connection =
          ownNeed && ownNeed.getIn(["connections", this.connectionUri]);
        const message =
          connection && this.messageUri
            ? getIn(connection, ["messages", this.messageUri])
            : Immutable.Map();

        return {
          ownNeed,
          message,
          multiSelectType: connection && connection.get("multiSelectType"),
          isProposed: isMessageProposed(this.message),
          isClaimed: isMessageClaimed(this.message),
          isAccepted: isMessageAccepted(this.message),
          isRejected: isMessageRejected(this.message),
          isRetracted: isMessageRetracted(this.message),
          isCancellationPending: isMessageCancellationPending(this.message),
          isCancelled: isMessageCancelled(this.message),
          isProposable:
            connection &&
            connection.get("state") === won.WON.Connected &&
            isMessageProposable(message),
          isClaimable:
            connection &&
            connection.get("state") === won.WON.Connected &&
            isMessageClaimable(message),
          isCancelable: isMessageCancelable(message),
          isRetractable: isMessageRetractable(message),
          isRejectable: isMessageRejectable(message),
          isAcceptable: isMessageAcceptable(message),
          isUnread: isMessageUnread(message),
          isFromSystem: message && message.get("systemMessage"),
          hasReferences: message && message.get("hasReferences"),
        };
      };

      connect2Redux(
        selectFromState,
        actionCreators,
        ["self.connectionUri", "self.messageUri"],
        this
      );
    }

    sendActionMessage(type) {<commit_msg>Fixes state retrieval bug<commit_after>import angular from "angular";

import won from "../../won-es6.js";
import Immutable from "immutable";
import { connect2Redux } from "../../won-utils.js";
import { attach, getIn } from "../../utils.js";
import { actionCreators } from "../../actions/actions.js";
import {
  selectNeedByConnectionUri,
  isMessageProposable,
  isMessageClaimable,
  isMessageCancelable,
  isMessageRejectable,
  isMessageRetractable,
  isMessageAcceptable,
  isMessageProposed,
  isMessageClaimed,
  isMessageRejected,
  isMessageAccepted,
  isMessageRetracted,
  isMessageCancelled,
  isMessageCancellationPending,
  isMessageUnread,
} from "../../selectors.js";

import "style/_connection-message-actions.scss";

const serviceDependencies = ["$ngRedux", "$scope"];

function genComponentConf() {
  let template = `
      <button class="won-button--filled thin black"
          ng-if="self.isProposable"
          ng-disabled="self.multiSelectType || self.clicked"
          ng-click="self.sendActionMessage('proposes')">
          {{ self.getProposeLabel() }}
      </button>
      <button class="won-button--filled thin black"
          ng-if="self.isClaimable"
          ng-disabled="self.multiSelectType || self.clicked"
          ng-click="self.sendActionMessage('claims')">
          Claim
      </button>
      <button class="won-button--filled thin red"
          ng-if="self.isAcceptable"
          ng-disabled="self.multiSelectType || self.clicked"
          ng-click="self.sendActionMessage('accepts')">
        Accept
      </button>
      <button class="won-button--filled thin black"
          ng-if="self.isRejectable"
          ng-disabled="self.multiSelectType || self.clicked"
          ng-click="self.sendActionMessage('rejects')">
        Reject
      </button>
      <button class="won-button--filled thin black"
          ng-if="self.isRetractable"
          ng-disabled="self.multiSelectType || self.clicked"
          ng-click="self.sendActionMessage('retracts')">
        Retract
      </button>
      <button class="won-button--filled thin red"
          ng-if="self.isCancelable"
          ng-disabled="self.multiSelectType || self.clicked"
          ng-click="self.sendActionMessage('proposesToCancel')">
        Propose To Cancel
      </button>
      <button class="won-button--filled thin red"
          ng-if="self.isCancellationPending"
          ng-disabled="true">
        Cancellation Pending...
      </button>
      <button class="won-button--filled thin red"
          ng-if="self.isCancelled"
          ng-disabled="true">
        Cancelled
      </button>
      <button class="won-button--filled thin red"
          ng-if="self.isRejected"
          ng-disabled="true">
        Rejected
      </button>
      <button class="won-button--filled thin red"
          ng-if="self.isRetracted"
          ng-disabled="true">
        Retracted
      </button>
    `;

  class Controller {
    constructor(/* arguments = dependency injections */) {
      attach(this, serviceDependencies, arguments);
      this.clicked = false;

      const selectFromState = state => {
        const ownNeed =
          this.connectionUri &&
          selectNeedByConnectionUri(state, this.connectionUri);
        const connection =
          ownNeed && ownNeed.getIn(["connections", this.connectionUri]);
        const message =
          connection && this.messageUri
            ? getIn(connection, ["messages", this.messageUri])
            : Immutable.Map();

        return {
          ownNeed,
          message,
          multiSelectType: connection && connection.get("multiSelectType"),
          isProposed: isMessageProposed(message),
          isClaimed: isMessageClaimed(message),
          isAccepted: isMessageAccepted(message),
          isRejected: isMessageRejected(message),
          isRetracted: isMessageRetracted(message),
          isCancellationPending: isMessageCancellationPending(message),
          isCancelled: isMessageCancelled(message),
          isProposable:
            connection &&
            connection.get("state") === won.WON.Connected &&
            isMessageProposable(message),
          isClaimable:
            connection &&
            connection.get("state") === won.WON.Connected &&
            isMessageClaimable(message),
          isCancelable: isMessageCancelable(message),
          isRetractable: isMessageRetractable(message),
          isRejectable: isMessageRejectable(message),
          isAcceptable: isMessageAcceptable(message),
          isUnread: isMessageUnread(message),
          isFromSystem: message && message.get("systemMessage"),
          hasReferences: message && message.get("hasReferences"),
        };
      };

      connect2Redux(
        selectFromState,
        actionCreators,
        ["self.connectionUri", "self.messageUri"],
        this
      );
    }

    sendActionMessage(type) {
{'fraction_non_alphanumeric': 0.12229338212869777, 'fraction_numerical': 0.000609942055504727, 'mean_word_length': 2.494849023090586, 'pattern_counts': {'":': 0, '<': 43, '<?xml version=': 0, '>': 45, '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': '1924324', 'n_tokens_mistral': 2756, 'n_tokens_neox': 2712, 'n_words': 469}