<h1>User: <b><%= fmt_string(user.name) %></b></h1>

<% if (permissions.length == 0) { %>
<p class="warning">
  This user does not have permission to access any virtual hosts.<br/>
  Use "Set Permission" below to grant permission to access virtual hosts.
</p>
<% } %>

<div class="section">
  <h2>Overview</h2>
  <div class="hider">
<table class="facts">
  <tr>
    <th>Tags</th>
    <td><%= fmt_string(user.tags) %></td>
  </tr>
  <tr>
    <th>Can log in with password</th>
    <td><%= fmt_boolean(user.password_hash.length > 0) %></td>
  </tr>
</table>
  </div>
</div>

<%= format('permissions', {'mode': 'user', 'permissions': permissions, 'vhosts': vhosts, 'parent': user}) %>

<div class="section-hidden">
  <h2>Update this user</h2>
  <div class="hider">
    <form action="#/users-modify" method="put">
      <input type="hidden" name="username" value="<%= fmt_string(user.name) %>"/>
      <table class="form">
        <tr>
          <th>
            <label>
              <select name="has-password" class="narrow controls-appearance">
                <option value="password">Password:</option>
                <option value="no-password">No password</option>
              </select>
            </label>
          </th>
          <td>
            <div id="password-div">
              <input type="password" name="password" />
              <span class="mand">*</span><br/>
              <input type="password" name="password_confirm" />
              <span class="mand">*</span>
              (confirm)
            </div>
            <div id="no-password-div" style="display: none;">
              User cannot log in using password.
            </div>
          </td>
        </tr>
        <tr>
          <th><label>Tags:</label></th>
          <td>
            <input type="text" name="tags" id="tags" value="<%= fmt_string(user.tags) %>" />
            <span class="help" id="user-tags"/>
            <sub>
              [<span class="tag-link" tag="administrator">Admin</span>]
              [<span class="tag-link" tag="monitoring">Monitoring</span>]
              [<span class="tag-link" tag="policymaker">Policymaker</span>]
              [<span class="tag-link" tag="management">Management</span>]
              [<span class="tag-link" tag="">None</span>]
            </sub>
          </td>
        </tr>
      </table>
      <input type="submit" value="Update user"/>
    </form>
  </div>
</div>


<div class="section-hidden">
  <h2>Delete this user</h2>
  <div class="hider">
    <form action="#/users" method="delete" class="confirm">
      <input type="hidden" name="username" value="<%= fmt_string(user.name) %>"/>
      <input type="submit" value="Delete"/>
    </form>
  </div>
</div>
