<commit_before>import React from 'react';

import ApiMixin from '../../mixins/apiMixin';
import GroupParticipants from './participants';
import GroupReleaseStats from './releaseStats';
import GroupState from '../../mixins/groupState';
import IndicatorStore from '../../stores/indicatorStore';
import TagDistributionMeter from './tagDistributionMeter';
import {t} from '../../locale';

const GroupSidebar = React.createClass({
  propTypes: {
    group: React.PropTypes.object,
  },

  contextTypes: {
    location: React.PropTypes.object
  },

  mixins: [
    ApiMixin,
    GroupState
  ],

  subscriptionReasons: {
    commented: t('You\'re receiving updates because you have commented on this issue.'),
    assigned: t('You\'re receiving updates because you were assigned to this issue.'),
    bookmarked: t('You\'re receiving updates because you have bookmarked this issue.'),
    changed_status: t('You\'re receiving updates because you have changed the status of this issue.'),
  },

  toggleSubscription() {
    let group = this.props.group;
    let project = this.getProject();
    let org = this.getOrganization();
    let loadingIndicator = IndicatorStore.add(t('Saving changes..'));

    this.api.bulkUpdate({
      orgId: org.slug,
      projectId: project.slug,
      itemIds: [group.id],
      data: {
        isSubscribed: !group.isSubscribed
      }
    }, {
      complete: () => {
        this.api.request(`/issues/${group.id}/participants/`, {
          success: (data) => {
            this.setState({participants: data});
            IndicatorStore.remove(loadingIndicator);
          }
        });
      }
    });
  },

  renderPluginIssue() {
    let issues = [];
    (this.props.group.pluginIssues || []).forEach((plugin) => {
      let issue = plugin.issue;
      if (issue) {
        issues.push(
          <dl key={plugin.slug}>
            <dt>{plugin.title + ': '}</dt><dd><a href={issue.url}>{issue.label}</a></dd>
          </dl>
        );
      }
    });
    if (issues.length) {
      return (
        <div>
          <h6><span>{t('External Issues')}</span></h6>
          {issues}
        </div>
      );
    }
  },

  getNotificationText() {
    let group = this.getGroup();

    if (group.isSubscribed) {
      let result = t('You\'re receiving updates because you are subscribed to this issue.');
      if (group.subscriptionDetails) {
        let reason = group.subscriptionDetails.reason;
        if (this.subscriptionReasons.hasOwnProperty(reason)) {
          result = this.subscriptionReasons[reason];
        }
      } else {
        result = t('You\'re receiving updates because you are subscribed to workflow notifications for this project.');
      }
      return result;
    } else {
      return t('You\'re not subscribed to this issue.');
    }
  },

  render() {
    let project = this.getProject();
    let projectId = project.slug;
    let orgId = this.getOrganization().slug;
    let defaultEnvironment = project.defaultEnvironment;
    let group = this.getGroup();
    let participants = (this.state || {}).participants || [];

    return (
      <div className="group-stats">
        <GroupReleaseStats
            group={group}
            location={this.context.location}<commit_msg>Improve subscription reason text for implicit subscriptions. (#4545)<commit_after>import React from 'react';

import ApiMixin from '../../mixins/apiMixin';
import GroupParticipants from './participants';
import GroupReleaseStats from './releaseStats';
import GroupState from '../../mixins/groupState';
import IndicatorStore from '../../stores/indicatorStore';
import TagDistributionMeter from './tagDistributionMeter';
import {t, tct} from '../../locale';

const GroupSidebar = React.createClass({
  propTypes: {
    group: React.PropTypes.object,
  },

  contextTypes: {
    location: React.PropTypes.object
  },

  mixins: [
    ApiMixin,
    GroupState
  ],

  subscriptionReasons: {
    commented: t('You\'re receiving updates because you have commented on this issue.'),
    assigned: t('You\'re receiving updates because you were assigned to this issue.'),
    bookmarked: t('You\'re receiving updates because you have bookmarked this issue.'),
    changed_status: t('You\'re receiving updates because you have changed the status of this issue.'),
  },

  toggleSubscription() {
    let group = this.props.group;
    let project = this.getProject();
    let org = this.getOrganization();
    let loadingIndicator = IndicatorStore.add(t('Saving changes..'));

    this.api.bulkUpdate({
      orgId: org.slug,
      projectId: project.slug,
      itemIds: [group.id],
      data: {
        isSubscribed: !group.isSubscribed
      }
    }, {
      complete: () => {
        this.api.request(`/issues/${group.id}/participants/`, {
          success: (data) => {
            this.setState({participants: data});
            IndicatorStore.remove(loadingIndicator);
          }
        });
      }
    });
  },

  renderPluginIssue() {
    let issues = [];
    (this.props.group.pluginIssues || []).forEach((plugin) => {
      let issue = plugin.issue;
      if (issue) {
        issues.push(
          <dl key={plugin.slug}>
            <dt>{plugin.title + ': '}</dt><dd><a href={issue.url}>{issue.label}</a></dd>
          </dl>
        );
      }
    });
    if (issues.length) {
      return (
        <div>
          <h6><span>{t('External Issues')}</span></h6>
          {issues}
        </div>
      );
    }
  },

  getNotificationText() {
    let group = this.getGroup();

    if (group.isSubscribed) {
      let result = t('You\'re receiving updates because you are subscribed to this issue.');
      if (group.subscriptionDetails) {
        let reason = group.subscriptionDetails.reason;
        if (this.subscriptionReasons.hasOwnProperty(reason)) {
          result = this.subscriptionReasons[reason];
        }
      } else {
        result = tct('You\'re receiving updates because you are [link:subscribed to workflow notifications] for this project.', {
          link: <a href="/account/settings/notifications/" />,
        });
      }
      return result;
    } else {
      return t('You\'re not subscribed to this issue.');
    }
  },

  render() {
    let project = this.getProject();
    let projectId = project.slug;
    let orgId = this.getOrganization().slug;
    let defaultEnvironment = project.defaultEnvironment;
    let group = this.getGroup();
    let participants = (this.state || {}).participants || [];

    return (
      <div className="group-stats">
        <GroupReleaseStats
            group={group}
            location={this.context.location}
{'fraction_non_alphanumeric': 0.1414766722029292, 'fraction_numerical': 0.0012079118224369622, 'mean_word_length': 2.5441412520064204, 'pattern_counts': {'":': 0, '<': 36, '<?xml version=': 0, '>': 40, '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': '3747374', 'n_tokens_mistral': 1891, 'n_tokens_neox': 1887, 'n_words': 458}