summaryrefslogtreecommitdiff
path: root/app/views/shared/members/_member.html.haml
blob: a884e78e6e7ecc276a6f377c3f5513b707b92a66 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
- show_roles = local_assigns.fetch(:show_roles, default_show_roles(member))
- show_controls = local_assigns.fetch(:show_controls, true)
- user = member.user

%li.js-toggle-container{ class: dom_class(member), id: dom_id(member) }
  %span{ class: ("list-item-name" if show_controls) }
    - if user
      = image_tag avatar_icon(user, 24), class: "avatar s24", alt: ''
      %strong
        = link_to user.name, user_path(user)
      %span.cgray= user.username

      - if user == current_user
        %span.label.label-success It's you

      - if user.blocked?
        %label.label.label-danger
          %strong Blocked

      - if member.request?
        %span.cgray
          – Requested
          = time_ago_with_tooltip(member.requested_at)
    - else
      = image_tag avatar_icon(member.invite_email, 24), class: "avatar s24", alt: ''
      %strong= member.invite_email
      %span.cgray
        – Invited
        - if member.created_by
          by
          = link_to member.created_by.name, user_path(member.created_by)
        = time_ago_with_tooltip(member.created_at)

      - if show_controls && can?(current_user, action_member_permission(:admin, member), member.source)
        = link_to 'Resend invite', polymorphic_path([:resend_invite, member]),
                  method: :post,
                  class: 'btn-xs btn'

  - if show_roles
    %span.pull-right
      %strong= member.human_access
      - if show_controls
        - if can?(current_user, action_member_permission(:update, member), member)
          = button_tag icon('pencil'),
                       type: 'button',
                       class: 'btn-xs btn btn-grouped inline js-toggle-button',
                       title: 'Edit access level'

          - if member.request?
             
            = link_to icon('check inverse'), polymorphic_path([:approve_access_request, member]),
                      method: :post,
                      class: 'btn-xs btn btn-success',
                      title: 'Grant access'

        - if can?(current_user, action_member_permission(:destroy, member), member)
           
          - if current_user == user
            = link_to icon('sign-out', text: 'Leave'), polymorphic_path([:leave, member.source, :members]),
                      method: :delete,
                      data: { confirm: leave_confirmation_message(member.source) },
                      class: 'btn-xs btn btn-remove'
          - else
            = link_to icon('trash'), member,
                      remote: true,
                      method: :delete,
                      data: { confirm: remove_member_message(member) },
                      class: 'btn-xs btn btn-remove',
                      title: remove_member_title(member)

    .edit-member.hide.js-toggle-content
      %br
      = form_for member, remote: true do |f|
        .prepend-top-10
          = f.select :access_level, options_for_select(member.class.access_level_roles, member.access_level), {}, class: 'form-control'
        .prepend-top-10
          = f.submit 'Save', class: 'btn btn-save btn-sm'