- user = member.user
- return unless user
- show_roles = true if show_roles.nil?
%li{class: "#{dom_class(member)} js-toggle-container", id: dom_id(member)}
  %span{class: ("list-item-name" if show_controls)}
    = image_tag avatar_icon(user.email, 16), class: "avatar s16"
    %strong= user.name
    %span.cgray= user.username
    - if user == current_user
      %span.label.label-success It's you

  - if show_roles
    %span.pull-right
      %strong= member.human_access
      - if show_controls
        - if can?(current_user, :modify, member)
          = link_to '#', class: "btn-tiny btn js-toggle-button", title: 'Edit access level' do
            %i.icon-edit
        - if can?(current_user, :destroy, member)
          - if current_user == member.user
            = link_to leave_profile_group_path(@group), data: { confirm: leave_group_message(@group.name)}, method: :delete, class: "btn-tiny btn btn-remove", title: 'Remove user from group' do
              %i.icon-minus.icon-white
          - else
            = link_to group_users_group_path(@group, member), data: { confirm: remove_user_from_group_message(@group, user) }, method: :delete, remote: true, class: "btn-tiny btn btn-remove", title: 'Remove user from group' do
              %i.icon-minus.icon-white

    .edit-member.hide.js-toggle-content
      = form_for [@group, member], remote: true do |f|
        .alert.prepend-top-20
          = f.select :group_access, options_for_select(UsersGroup.group_access_roles, member.group_access)
          = f.submit 'Save', class: 'btn btn-save btn-small'
