BigW Consortium Gitlab

_member.html.haml 3.85 KB
Newer Older
1
- show_roles = local_assigns.fetch(:show_roles, true)
2
- show_controls = local_assigns.fetch(:show_controls, true)
Phil Hughes committed
3
- user = local_assigns.fetch(:user, member.user)
Phil Hughes committed
4
- source = member.source
5
- can_admin_member = can?(current_user, action_member_permission(:update, member), member)
6

Phil Hughes committed
7
%li.member{ class: dom_class(member), id: dom_id(member) }
8
  %span.list-item-name
9 10 11 12
    - if user
      = image_tag avatar_icon(user, 40), class: "avatar s40", alt: ''
      %strong
        = link_to user.name, user_path(user)
Phil Hughes committed
13
      %span.cgray= user.to_reference
14 15

      - if user == current_user
Phil Hughes committed
16
        %span.label.label-success.prepend-left-5 It's you
17 18 19 20 21

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

Phil Hughes committed
22 23 24
      - if source.instance_of?(Group) && !@group
        = link_to source, class: "member-group-link prepend-left-5" do
          = #{source.name}"
Phil Hughes committed
25

Phil Hughes committed
26
      .hidden-xs.cgray
27
        - if member.request?
28
          Requested
29 30 31
          = time_ago_with_tooltip(member.requested_at)
        - else
          Joined #{time_ago_with_tooltip(member.created_at)}
32
        - if member.expires?
33
          ·
34
          %span{ class: ('text-warning' if member.expires_soon?) }
35
            Expires in #{distance_of_time_in_words_to_now(member.expires_at)}
36 37 38 39 40 41 42 43 44 45

    - else
      = image_tag avatar_icon(member.invite_email, 40), class: "avatar s40", alt: ''
      %strong= member.invite_email
      .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)
46 47 48
  - if show_roles
    .controls.member-controls
      - if show_controls
Phil Hughes committed
49 50
        - if user != current_user
          = form_for member, remote: true, html: { class: 'form-horizontal js-edit-member-form' } do |f|
51
            = f.select :access_level, options_for_select(member.class.access_level_roles, member.access_level), {}, class: 'form-control member-form-control append-right-5 js-member-update-control', id: "member_access_level_#{member.id}", disabled: !can_admin_member
52
            .prepend-left-5.clearable-input.member-form-control
53
              = f.text_field :expires_at, class: 'form-control js-access-expiration-date js-member-update-control', placeholder: 'Expiration date', id: "member_expires_at_#{member.id}", disabled: !can_admin_member
Phil Hughes committed
54 55 56
              %i.clear-icon.js-clear-input
        - else
          %span.member-access-text= member.human_access
57 58

        - if member.invite? && can?(current_user, action_member_permission(:admin, member), member.source)
59 60
          = link_to 'Resend invite', polymorphic_path([:resend_invite, member]),
                    method: :post,
61
                    class: 'btn btn-default  prepend-left-10'
62

63
        - elsif member.request? && can_admin_member
64 65
          = link_to icon('check inverse'), polymorphic_path([:approve_access_request, member]),
                    method: :post,
66
                    class: 'btn btn-success prepend-left-10',
67 68 69 70 71 72 73
                    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) },
74
                      class: 'btn btn-remove prepend-left-10'
75
          - else
Phil Hughes committed
76
            = link_to member,
77 78 79
                      remote: true,
                      method: :delete,
                      data: { confirm: remove_member_message(member) },
80
                      class: 'btn btn-remove prepend-left-10',
Phil Hughes committed
81 82 83 84
                      title: remove_member_title(member) do
              %span.visible-xs-block
                Delete
              = icon('trash', class: 'hidden-xs')
Phil Hughes committed
85 86
      - else
        %span.member-access-text= member.human_access