<section class="user-content">

<div class="group-members-actions">
    {{#if model.can_see_members}}
      {{text-field value=filterInput
          placeholderKey=filterPlaceholder
          autocomplete="discourse"
          class="group-username-filter no-blur"}}
    {{/if}}

  <div class="group-members-manage">
    {{#if canManageGroup}}
      {{d-button icon="plus"
      action=(route-action "showAddMembersModal")
      label="groups.add_members.title"
      class="group-members-add"}}
      {{#if currentUser.admin}}
        {{d-button icon="plus"
        action=(route-action "showBulkAddModal")
        label="admin.groups.bulk_add.title"
        class="group-bulk-add"}}
      {{/if}}
    {{/if}}
  </div>
</div>

{{#if hasMembers}}
  {{#load-more selector=".group-members tr" action=(action "loadMore")}}
    <table class='group-members'>
      <thead>
        {{group-index-toggle order=order desc=desc field='username_lower' i18nKey='username'}}
        <th class='group-owner'>{{i18n "groups.members.owner"}}</th>
        {{group-index-toggle order=order desc=desc field='added_at' i18nKey='groups.member_added'}}
        {{group-index-toggle order=order desc=desc field='last_posted_at' i18nKey='last_post'}}
        {{group-index-toggle order=order desc=desc field='last_seen_at'  i18nKey='last_seen'}}
        <th></th>
      </thead>

      <tbody>
        {{#each model.members as |m|}}
          <tr>
            <td class='avatar'>
              {{user-info user=m skipName=skipName}}
            </td>

            <td class='group-owner'>
              {{#if m.owner}}
                <strong class="group-owner-label">
                  {{d-icon "shield-alt"}}
                </strong>
              {{/if}}
            </td>
            <td>
              <span class="text">{{bound-date m.added_at}}</span>
            </td>
            <td>
              <span class="text">{{bound-date m.last_posted_at}}</span>
            </td>
            <td>
              <span class="text">{{bound-date m.last_seen_at}}</span>
            </td>

            <td>
              {{#if canManageGroup}}
                {{group-member-dropdown
                  removeMember=(action "removeMember")
                  makeOwner=(action "makeOwner")
                  removeOwner=(action "removeOwner")
                  member=m
                  group=model
                  onChange=(action "actOnGroup" m)
                }}
              {{/if}}
              {{!-- group parameter is used by plugins --}}
            </td>
          </tr>
        {{/each}}
      </tbody>
    </table>
  {{/load-more}}

  {{conditional-loading-spinner condition=loading}}
{{else if model.can_see_members}}
  <br>

  <div>{{i18n "groups.empty.members"}}</div>
{{else}}
  <br>

  <div>{{i18n "groups.members.forbidden"}}</div>
{{/if}}
</section>
