kitgit

tirbofish/kitgit

main / templates / pull_view.html · 9680 bytes

templates/pull_view.html
{% extends "layout.html" %}

{% block title %}#{{ pull.number }} {{ pull.title }} — kitgit{% endblock %}

{% block content %}
<section class="kg-section">
  <h1 class="kg-title">
    <span class="kg-badge {% if pull.state == "open" %}kg-badge--open{% else %}kg-badge--closed{% endif %}">{{ pull.state }}</span>
    #{{ pull.number }} {{ pull.title }}
  </h1>
  <p class="kg-meta">{{ pull.source_branch }} → {{ pull.target_branch }}</p>
  <aside class="kg-issue-sidebar" style="margin:1rem 0">
    <div class="kg-sidebar-block">
      <h2 class="kg-kicker">labels</h2>
      {% if labels.is_empty() %}<p class="kg-muted">None yet.</p>{% else %}<div class="kg-label-row">{% for l in labels %}<span class="kg-label-chip" style="background:{{ l.bg_color() }};color:{{ l.text_color() }}">{{ l.name }}</span>{% endfor %}</div>{% endif %}
      {% if can_triage %}<form class="kg-form" method="post" action="/{{ owner.username }}/{{ repo.name }}/pulls/{{ pull.number }}/labels">{% for opt in label_options %}<label class="row"><input type="checkbox" name="label_id" value="{{ opt.label.id }}"{% if opt.selected %} checked{% endif %} /> <span class="kg-label-chip" style="background:{{ opt.label.bg_color() }};color:{{ opt.label.text_color() }}">{{ opt.label.name }}</span></label>{% endfor %}{% if !label_options.is_empty() %}<button class="kg-btn kg-btn--ghost" type="submit">save labels</button>{% endif %}</form>{% endif %}
    </div>
    <div class="kg-sidebar-block">
      <h2 class="kg-kicker">milestone</h2>
      {% if let Some(m) = milestone %}<p>{{ m.title }}</p>{% else %}<p class="kg-muted">No milestone</p>{% endif %}
      {% if can_triage %}<form class="kg-form" method="post" action="/{{ owner.username }}/{{ repo.name }}/pulls/{{ pull.number }}/milestone"><label><select name="milestone_id"><option value="">none</option>{% for opt in milestone_options %}<option value="{{ opt.milestone.id }}"{% if opt.selected %} selected{% endif %}>{{ opt.milestone.title }}</option>{% endfor %}</select></label><button class="kg-btn kg-btn--ghost" type="submit">save milestone</button></form>{% endif %}
    </div>
  </aside>

  {% let pr_tab = tab %}
  {% let tab = "pulls" %}
  {% let archive_ref = repo.default_branch %}
  {% include "partials/repo_tabs.html" %}

  <nav class="kg-pr-tabs" aria-label="Pull request">
    <a href="/{{ owner.username }}/{{ repo.name }}/pulls/{{ pull.number }}?tab=conversation"{% if pr_tab == "conversation" %} aria-current="page"{% endif %}>
      <span class="kg-icon" style="--icon:url('/static/icons/circle.svg')"></span>
      conversation
      <span class="kg-pr-tabs__count">{{ conversation_count }}</span>
    </a>
    <a href="/{{ owner.username }}/{{ repo.name }}/pulls/{{ pull.number }}?tab=commits"{% if pr_tab == "commits" %} aria-current="page"{% endif %}>
      <span class="kg-icon" style="--icon:url('/static/icons/history.svg')"></span>
      commits
      <span class="kg-pr-tabs__count">{{ commits.len() }}</span>
    </a>
    <a href="/{{ owner.username }}/{{ repo.name }}/pulls/{{ pull.number }}?tab=files{% if show_full %}&amp;full=1{% endif %}"{% if pr_tab == "files" %} aria-current="page"{% endif %}>
      <span class="kg-icon" style="--icon:url('/static/icons/file.svg')"></span>
      files
      <span class="kg-pr-tabs__count">{{ diff_files.len() }}</span>
    </a>
  </nav>

  {% if pr_tab == "conversation" %}
  <article class="kg-comment">
    <header>
      <span>
        <img class="kg-avatar kg-avatar--sm" src="{{ author_avatar }}" alt="" />
        <a href="/{{ author.username }}">{{ author.username }}</a>
      </span>
      <span>{{ pull.created_at }}</span>
    </header>
    <div class="kg-readme">{{ body_html|safe }}</div>
  </article>

  {% for c in comments %}
  <article class="kg-comment">
    <header>
      <span>
        <img class="kg-avatar kg-avatar--sm" src="{{ c.avatar_url }}" alt="" />
        <a href="/{{ c.author.username }}">{{ c.author.username }}</a>
      </span>
      <span>{{ c.created_at }}</span>
    </header>
    <div class="kg-readme">{{ c.body_html|safe }}</div>
    {% include "partials/reactions.html" %}
  </article>
  {% endfor %}

  {% for r in reviews %}
  <article class="kg-comment kg-review">
    <header>
      <span>
        <img class="kg-avatar kg-avatar--sm" src="{{ r.avatar_url }}" alt="" />
        <a href="/{{ r.reviewer.username }}">{{ r.reviewer.username }}</a>
        <span class="kg-badge {{ r.state_class() }}">{{ r.state_label() }}</span>
      </span>
      <span>{{ r.created_at }}</span>
    </header>
    {% if !r.body.is_empty() %}
    <div class="kg-readme">{{ r.body_html|safe }}</div>
    {% endif %}
  </article>
  {% endfor %}

  {% if viewer.is_some() && pull.state == "open" %}
    <form class="kg-form" method="post" action="/{{ owner.username }}/{{ repo.name }}/pulls/{{ pull.number }}/review">
      <fieldset class="kg-review-state">
        <legend>review</legend>
        {% if !is_author %}
        <label class="row">
          <input type="radio" name="state" value="approved" />
          approve
        </label>
        <label class="row">
          <input type="radio" name="state" value="changes_requested" />
          request changes
        </label>
        {% endif %}
        <label class="row">
          <input type="radio" name="state" value="commented" checked />
          comment
        </label>
      </fieldset>
      <label>
        review notes
        <textarea name="body" rows="4" placeholder="Leave a review comment (optional)"></textarea>
      </label>
      <div class="kg-actions">
        <button class="kg-btn" type="submit">submit review</button>
      </div>
    </form>
  {% endif %}

  {% if viewer.is_some() %}
    <form class="kg-form" method="post" action="/{{ owner.username }}/{{ repo.name }}/pulls/{{ pull.number }}">
      <label>
        comment
        <textarea name="body" rows="4" required></textarea>
      </label>
      <div class="kg-actions">
        <button class="kg-btn" type="submit">comment</button>
        {% if pull.state == "open" %}
          <button class="kg-btn kg-btn--ghost" formaction="/{{ owner.username }}/{{ repo.name }}/pulls/{{ pull.number }}/close" formmethod="post" type="submit" formnovalidate>close</button>
        {% endif %}
      </div>
    </form>
  {% endif %}

  {% if can_merge && !merge_styles.is_empty() %}
    <form class="kg-form" method="post" action="/{{ owner.username }}/{{ repo.name }}/pulls/{{ pull.number }}/merge">
      <label>
        merge style
        <select name="style">
          {% for style in merge_styles %}
            <option value="{{ style }}"{% if style.as_str() == repo.default_merge_style.as_str() %} selected{% endif %}>{{ style }}</option>
          {% endfor %}
        </select>
      </label>
      <div class="kg-actions">
        <button class="kg-btn" type="submit">merge</button>
      </div>
    </form>
  {% endif %}
  {% else if pr_tab == "commits" %}
    {% if commits.is_empty() %}
      <p class="kg-muted">No commits on this pull request.</p>
    {% else %}
      <ul class="kg-list">
        {% for c in commits %}
        <li>
          <span>
            <a href="/{{ owner.username }}/{{ repo.name }}/commits" title="View commits"><code>{{ c.short_id }}</code></a>
            <a href="/{{ owner.username }}/{{ repo.name }}/commit/{{ c.id }}">{{ c.message }}</a>
            {% let show_unverified = false %}
            {% include "partials/verified_badge.html" %}
          </span>
          <span class="kg-meta">{{ c.author }}</span>
        </li>
        {% endfor %}
      </ul>
    {% endif %}
  {% else %}
    {% if diff_files.is_empty() %}
      <p class="kg-muted">No file changes.</p>
    {% else %}
      <div class="kg-pr-files">
        <aside class="kg-pr-files__nav" aria-label="Changed files">
          <p class="kg-pr-files__nav-title">{{ diff_files.len() }} files</p>
          <ul>
            {% for f in diff_files %}
            <li>
              <a href="#{{ f.anchor }}">
                <span class="kg-pr-files__path">{{ f.path }}</span>
                <span class="kg-pr-files__stat">
                  {% if f.binary %}
                    binary
                  {% else %}
                    <span class="kg-pr-files__add">+{{ f.additions }}</span>
                    <span class="kg-pr-files__del">−{{ f.deletions }}</span>
                  {% endif %}
                </span>
              </a>
            </li>
            {% endfor %}
          </ul>
        </aside>
        <div class="kg-pr-files__panels">
          {% for f in diff_files %}
          <section class="kg-diff-file" id="{{ f.anchor }}">
            <header class="kg-diff-file__head">
              <strong>{{ f.path }}</strong>
              <span class="kg-meta">
                {% if f.binary %}
                  binary
                {% else %}
                  <span class="kg-pr-files__add">+{{ f.additions }}</span>
                  <span class="kg-pr-files__del">−{{ f.deletions }}</span>
                {% endif %}
              </span>
            </header>
            {{ f.html|safe }}
            {% if f.truncated && !show_full %}
              <p class="kg-diff__truncated">
                Large diffs are not rendered by default.
                Showing the first 50 of {{ f.total_lines }} lines.
                <a class="kg-btn kg-btn--ghost" href="/{{ owner.username }}/{{ repo.name }}/pulls/{{ pull.number }}?tab=files&amp;full=1#{{ f.anchor }}">Show full diff</a>
              </p>
            {% endif %}
          </section>
          {% endfor %}
        </div>
      </div>
    {% endif %}
  {% endif %}
</section>
{% endblock %}