<commit_before>package EnsEMBL::Users::Component::Account::Groups::Notifications;

### Notifications component for a logged in user about group invitations or requests
### @author hr5

use strict;
use warnings;

use base qw(EnsEMBL::Users::Component::Account);

sub content {
  my $self  = shift;
  my $user  = $self->hub->user->rose_object;

  # if a group admin sent an invitation to the user
  my @invitations = map({ $_->is_pending_invitation
    ? sprintf(q{<li><i>%s (%s)</i> is inviting you to join the group <i>%s</i><br />%s &middot; %s &middot; %s</li>},
        map({ $self->html_encode($_->name), $_->email } $_->modified_by_user || $_->created_by_user),
        $self->html_encode($_->group->name),
        $self->js_link({'href' => {'action' => 'Membership', 'function' => 'Accept',     'id' => $_->group_member_id}, 'target' => 'page', 'caption' => 'Accept'}),
        $self->js_link({'href' => {'action' => 'Membership', 'function' => 'Decline',    'id' => $_->group_member_id}, 'target' => 'page', 'caption' => 'Decline'}),
        $self->js_link({'href' => {'action' => 'Membership', 'function' => 'BlockGroup', 'id' => $_->group_member_id}, 'target' => 'page', 'caption' => 'Block group from sending further invitations'})
      )
    : ()
    } @{$user->memberships}
  );

  # if someone requested for membership of a group administrated by the user
  my @requests = map({ $_->is_pending_request
    ? sprintf(q{<li><i>%s (%s)</i> would like to join your group <i>%s</i><br />%s &middot; %s &middot; %s</li>},
        map({ $self->html_encode($_->name), $_->email } $_->user),
        $self->js_link({'href' => {'action' => 'Groups',     'function' => 'View',       'id' => $_->group->group_id}, 'target' => 'page', 'caption' => $self->html_encode($_->group->name)}),
        $self->js_link({'href' => {'action' => 'Membership', 'function' => 'Allow',      'id' => $_->group_member_id}, 'target' => 'page', 'caption' => 'Allow'}),
        $self->js_link({'href' => {'action' => 'Membership', 'function' => 'Ignore',     'id' => $_->group_member_id}, 'target' => 'page', 'caption' => 'Ignore'}),
        $self->js_link({'href' => {'action' => 'Membership', 'function' => 'BlockUser',  'id' => $_->group_member_id}, 'target' => 'page', 'caption' => 'Block user from sending further requests'})
      )
    : ()
    } map {@{$_->group->memberships}} @{$user->admin_memberships}
  );

  return sprintf '%s%s',
    @invitations ? $self->_info($self->append_s_to_plural('Invitation', @invitations > 1), sprintf('<ul>%s</ul>', join('', @invitations)), '100%') : '',
    @requests    ? $self->_info($self->append_s_to_plural('Request',    @requests    > 1), sprintf('<ul>%s</ul>', join('', @requests   )), '100%') : ''
  ;    
}
1;<commit_msg>'target' key removed<commit_after>package EnsEMBL::Users::Component::Account::Groups::Notifications;

### Notifications component for a logged in user about group invitations or requests
### @author hr5

use strict;
use warnings;

use base qw(EnsEMBL::Users::Component::Account);

sub content {
  my $self  = shift;
  my $user  = $self->hub->user->rose_object;

  # if a group admin sent an invitation to the user
  my @invitations = map({ $_->is_pending_invitation
    ? sprintf(q{<li><i>%s (%s)</i> is inviting you to join the group <i>%s</i><br />%s &middot; %s &middot; %s</li>},
        map({ $self->html_encode($_->name), $_->email } $_->modified_by_user || $_->created_by_user),
        $self->html_encode($_->group->name),
        $self->js_link({'href' => {'action' => 'Membership', 'function' => 'Accept',     'id' => $_->group_member_id}, 'caption' => 'Accept'}),
        $self->js_link({'href' => {'action' => 'Membership', 'function' => 'Decline',    'id' => $_->group_member_id}, 'caption' => 'Decline'}),
        $self->js_link({'href' => {'action' => 'Membership', 'function' => 'BlockGroup', 'id' => $_->group_member_id}, 'caption' => 'Block group from sending further invitations'})
      )
    : ()
    } @{$user->memberships}
  );

  # if someone requested for membership of a group administrated by the user
  my @requests = map({ $_->is_pending_request
    ? sprintf(q{<li><i>%s (%s)</i> would like to join your group <i>%s</i><br />%s &middot; %s &middot; %s</li>},
        map({ $self->html_encode($_->name), $_->email } $_->user),
        $self->js_link({'href' => {'action' => 'Groups',     'function' => 'View',       'id' => $_->group->group_id}, 'caption' => $self->html_encode($_->group->name)}),
        $self->js_link({'href' => {'action' => 'Membership', 'function' => 'Allow',      'id' => $_->group_member_id}, 'caption' => 'Allow'}),
        $self->js_link({'href' => {'action' => 'Membership', 'function' => 'Ignore',     'id' => $_->group_member_id}, 'caption' => 'Ignore'}),
        $self->js_link({'href' => {'action' => 'Membership', 'function' => 'BlockUser',  'id' => $_->group_member_id}, 'caption' => 'Block user from sending further requests'})
      )
    : ()
    } map {@{$_->group->memberships}} @{$user->admin_memberships}
  );

  return sprintf '%s%s',
    @invitations ? $self->_info($self->append_s_to_plural('Invitation', @invitations > 1), sprintf('<ul>%s</ul>', join('', @invitations)), '100%') : '',
    @requests    ? $self->_info($self->append_s_to_plural('Request',    @requests    > 1), sprintf('<ul>%s</ul>', join('', @requests   )), '100%') : ''
  ;
}
1;
{'fraction_non_alphanumeric': 0.23990321980271728, 'fraction_numerical': 0.003722315280104225, 'mean_word_length': 4.127862595419847, 'pattern_counts': {'":': 0, '<': 39, '<?xml version=': 0, '>': 206, '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': '3873579', 'n_tokens_mistral': 1852, 'n_tokens_neox': 1840, 'n_words': 409}