{{ define "permissions.gohtml" }}{{ template "base" . }}{{ end }}

{{ define "permissions_content" }}
<section class="permissions-shell">
  <header class="permissions-header">
    <div>
      <p class="eyebrow">Access control</p>
      <h1>{{ .Title }}</h1>
    </div>
    {{ if eq .ResourceType "document" }}
    <a class="account-action" href="/docs/{{ trimMd .ResourceID }}">Back to page</a>
    {{ end }}
  </header>

  <form class="permissions-form" method="post" action="/permissions">
    <input type="hidden" name="resourceType" value="{{ .ResourceType }}" />
    <input type="hidden" name="resourceId" value="{{ .ResourceID }}" />
    <section class="permissions-panel">
      <header class="permissions-panel__header">
        <div>
          <p class="account-section__kicker">People</p>
          <h2>User permissions</h2>
        </div>
        <div class="permission-bulk-actions" data-permission-bulk>
          <label class="permission-select-all">
            <input type="checkbox" data-permission-select-all />
            <span>Select all</span>
          </label>
          <select data-permission-bulk-level aria-label="Access level for selected users">
            <option value="">No access</option>
            <option value="read">View</option>
            <option value="write">Edit</option>
            <option value="admin">Admin</option>
          </select>
          <button class="btn-secondary permission-apply" type="button" data-permission-apply>Apply</button>
        </div>
      </header>
      <div class="permission-user-list">
        {{ range .Users }}
        <label class="permission-user-row">
          <input class="permission-user-check" type="checkbox" data-permission-user />
          <span class="permission-user-main">
            <span class="permission-user-name">
              <strong>{{ .DisplayName }}</strong>
              <em>{{ .Role }}</em>
            </span>
            <span class="permission-user-email">{{ .Email }}</span>
            <span class="permission-user-meta">Created {{ .CreatedAt }} · Last seen {{ .LastSeenAt }}</span>
          </span>
          <span class="permission-grant-meta">
            <strong>{{ .PermissionText }}</strong>
            <small>{{ .GrantSummary }}</small>
          </span>
          <span class="permission-select-wrap">
            <select name="permission:{{ .ID }}" aria-label="Permission for {{ .DisplayName }}" data-permission-select>
              <option value="" {{ if eq .Permission "" }}selected{{ end }}>No access</option>
              <option value="read" {{ if eq .Permission "read" }}selected{{ end }}>View</option>
              <option value="write" {{ if eq .Permission "write" }}selected{{ end }}>Edit</option>
              <option value="admin" {{ if eq .Permission "admin" }}selected{{ end }}>Admin</option>
            </select>
          </span>
        </label>
        {{ end }}
      </div>
      <div class="permissions-footer">
        <button class="btn-primary" type="submit">Save permissions</button>
      </div>
    </section>
  </form>
</section>
{{ end }}
