education/classroom

View on GitHub
app/views/stafftools/users/show.html.erb

Summary

Maintainability
Test Coverage
<div class="site-content">
  <div class="d-flex flex-md-row flex-items-center stafftools-page-header">
    <div class="col-1 d-flexp">
      <span class="assignment-icon assignment-icon-individual left">
        <%= image_tag @user.github_user.github_avatar_url(96), height: 48, width: 48, class: 'avatar left', alt: "@#{@user.github_user.login}" %>
      </span>
    </div>

    <div class="col-10 col-md-10 d-flex flex-column">
      <h2 class="stafftools-heading">
        <%= @user.github_user.login %>
      </h2>

      <p class="assignment-type text-gray">
        <%= content_tag(:span, 'Staff', class: 'staff-badge') if @user.staff? %> User
      </p>
    </div>
  </div>

  <div class="boxed-group">
    <h3>User information</h3>

    <div class="boxed-group-inner">
      <table>
        <tr>
          <td class="text-emphasized">ID</td>
          <td><%= @user.id %></td>
        </tr>
        <tr>
          <td class="text-emphasized">GitHub ID</td>
          <td><%= @user.uid %></td>
        </tr>
        <tr>
          <td class="text-emphasized">GitHub profile</td>
          <td><%= link_to @user.github_user.html_url, @user.github_user.html_url %></td>
        </tr>
        <tr>
         <td class="text-emphasized">Joined on</td>
         <td><%= local_time(@user.created_at) %></td>
        </tr>
        <tr>
         <td class="text-emphasized">Last active</td>
         <td><%= local_time(@user.last_active_at) %></td>
        </tr>
        <tr>
          <td class="text-emphasized">Access token</td>
          <td><%= @user.authorized_access_token? ? 'Authorized' : 'Rejected' %></td>
        </tr>
        <tr>
          <td class="text-emphasized">Scopes</td>
          <td><%= @user.github_client_scopes.join(', ') %></td>
        </tr>
      </table>
    </div>
  </div>

  <% if @user.organizations.present? %>
    <div class="boxed-group">
      <h3>Classrooms</h3>

      <div class="boxed-group-inner">
        <ul class="boxed-group-list standalone">
          <%= render partial: 'stafftools/users/organization', collection: @user.organizations %>
        </ul>
      </div>
    </div>
  <% end %>

  <% if @user.repo_accesses.present? %>
    <div class="boxed-group">
      <h3>Organization Memberships</h3>

      <div class="boxed-group-inner">
        <ul class="boxed-group-list standalone">
          <% @user.repo_accesses.each do |repo_access| %>
            <%= render partial: 'stafftools/users/organization', locals: { organization: repo_access.organization } %>
          <% end %>
        </ul>
      </div>
    </div>
  <% end %>

  <% if @user.id != current_user.id %>
    <div class="boxed-group dangerzone">
      <h3>Dangerzone</h3>

      <div class="boxed-group-inner">
        <h4>Impersonate <%= "@#{@user.github_user.login}" %></h4>
        <a data-remodal-target="impersonate-user" class="btn btn-danger boxed-action">Impersonate <%= "@#{@user.github_user.login}" %></a>
        <p>This will send you to <strong><%= @user.github_user.login %></strong>'s Classroom dashboard as <strong><%= @user.github_user.login %></strong>.</p>

        <%= render partial: 'stafftools/users/impersonate_user_confirmation_modal', locals: { user: @user } %>
      </div>
    </div>
  <% end %>
</div>