123 lines
9.3 KiB
HTML
123 lines
9.3 KiB
HTML
{# Ansicht „Änderungen“: Branch des Chats je Quelle, Aktionen nur auf Klick eines Menschen. Aktualisiert sich nach jeder Antwort. #}
|
|
<div id="changes" class="stack stack-sm" hx-get="/chats/{{ chat.id }}/changes" hx-trigger="aiw:run-done from:body" hx-swap="outerHTML">
|
|
{% if error %}<div class="alert alert-danger" role="alert"><div class="alert-content"><p>{{ error }}</p></div></div>{% endif %}
|
|
{% if notice %}<div class="alert alert-success" role="status"><div class="alert-content"><p>{{ notice }}</p></div></div>{% endif %}
|
|
{% for v in views %}{% set b = v.branch %}{% set hx = 'hx-target="#changes" hx-swap="outerHTML"' %}
|
|
<section class="card aiw-changes">
|
|
<div class="card-body stack stack-sm">
|
|
<div class="aiw-changes-head">
|
|
<div class="flex-1 min-w-0">
|
|
<strong>Änderungen</strong>
|
|
<code class="text-sm">{{ b.name }}</code>
|
|
{% if b.closed %}
|
|
<span class="badge {{ 'badge-success' if b.pr_state == 'MERGED' else 'badge-default' }}">{{ 'gemergt' if b.pr_state == 'MERGED' else 'abgelehnt' }}</span>
|
|
{% set remote = b.pr_info.get('remote_branch') %}
|
|
{% if remote in ('deleted', 'gone') %}<span class="badge badge-default" title="Commits und Diff bleiben hier sichtbar">im Git-Server gelöscht</span>
|
|
{% elif remote == 'changed' %}<span class="badge badge-warning" title="Auf dem Branch liegen Commits von außerhalb der Plattform; er wurde deshalb nicht gelöscht">Branch im Git-Server behalten</span>
|
|
{% elif remote == 'failed' %}<span class="badge badge-warning" title="Fehlt dem technischen Account das Recht, ai/*-Branches zu löschen? Details im Log">Branch nicht gelöscht</span>{% endif %}
|
|
{% elif b.pr_id %}
|
|
<span class="badge badge-info">PR #{{ b.pr_id }} {{ 'Entwurf' if b.pr_draft else 'offen' }}</span>
|
|
{% elif b.pushed %}
|
|
<span class="badge badge-default">gepusht</span>
|
|
{% else %}
|
|
<span class="badge badge-default">nur in der Plattform</span>
|
|
{% endif %}
|
|
{% if b.unpushed and b.pushed and not b.closed %}<span class="badge badge-warning">neue Commits nicht übertragen</span>{% endif %}
|
|
{% if v.commits and v.commits[-1].warnings and not b.closed %}<span class="badge badge-warning" title="Statische Prüfung beim Commit; Details unter „Commits und Diff“">Syntaxwarnung im letzten Commit</span>{% endif %}
|
|
{% if v.conflict %}<span class="badge badge-danger" title="Lässt sich nicht konfliktfrei mit dem aktuellen Stand von {{ b.target }} zusammenführen">Konflikt mit {{ b.target }}</span>
|
|
{% elif v.behind %}<span class="badge badge-warning" title="{{ b.target }} hat neue Commits, die im Branch fehlen">{{ b.target }} ist weiter</span>{% endif %}
|
|
<p class="text-xs text-muted">{{ v.source.name }} · Ziel {{ b.target }} · {{ v.commits|length }} Commit{{ 's' if v.commits|length != 1 }} · {{ v.files|length }} Datei{{ 'en' if v.files|length != 1 }}
|
|
{% if b.pr_id %} · {% for r in b.pr_info.get('reviewers', []) %}{{ r.name }} {{ {'APPROVED': '✓', 'NEEDS_WORK': '✗'}.get(r.status, '·') }}{% if not loop.last %}, {% endif %}{% endfor %}
|
|
{% if b.pr_info.get('comments') %} · {{ b.pr_info.comments }} Kommentar{{ 'e' if b.pr_info.comments != 1 }}{% endif %}
|
|
{% if b.pr_checked %} · Stand {{ b.pr_checked.astimezone().strftime('%d.%m. %H:%M') }}{% endif %}{% endif %}
|
|
</p>
|
|
</div>
|
|
<div class="cluster">
|
|
{% if b.pr_url %}<a class="btn btn-ghost btn-sm" href="{{ b.pr_url }}" target="_blank" rel="noopener noreferrer">PR #{{ b.pr_id }} öffnen</a>{% endif %}
|
|
{% if not b.closed %}
|
|
{% if b.unpushed %}
|
|
<form method="post" action="/branches/{{ b.id }}/push" hx-post="/branches/{{ b.id }}/push" {{ hx|safe }}>
|
|
<input type="hidden" name="_csrf" value="{{ p.csrf }}">
|
|
<button class="btn {{ 'btn-primary' if b.pr_id else 'btn-secondary' }} btn-sm" type="submit">{{ 'Änderungen übertragen' if b.pr_id else 'Branch pushen' }}</button>
|
|
</form>
|
|
{% endif %}
|
|
{% if not v.conflict %}
|
|
<form method="post" action="/branches/{{ b.id }}/sync" hx-post="/branches/{{ b.id }}/sync" {{ hx|safe }}>
|
|
<input type="hidden" name="_csrf" value="{{ p.csrf }}">
|
|
<button class="btn {{ 'btn-secondary' if v.behind else 'btn-ghost' }} btn-sm" type="submit" title="Neue Commits aus {{ b.target }} per Merge-Commit übernehmen">Mit {{ b.target }} abgleichen</button>
|
|
</form>
|
|
{% elif v.conflict %}
|
|
<form method="post" action="/branches/{{ b.id }}/resolve">
|
|
<input type="hidden" name="_csrf" value="{{ p.csrf }}">
|
|
<button class="btn btn-secondary btn-sm" type="submit" title="Die KI führt {{ b.target }} zusammen und löst die Konflikte; das Ergebnis ist ein Merge-Commit">Konflikte von der KI lösen lassen</button>
|
|
</form>
|
|
{% endif %}
|
|
{% if b.pr_draft %}
|
|
<form method="post" action="/branches/{{ b.id }}/ready" hx-post="/branches/{{ b.id }}/ready" {{ hx|safe }}>
|
|
<input type="hidden" name="_csrf" value="{{ p.csrf }}">
|
|
<button class="btn btn-secondary btn-sm" type="submit">Als bereit markieren</button>
|
|
</form>
|
|
{% endif %}
|
|
{% if b.pr_id %}
|
|
<form method="post" action="/branches/{{ b.id }}/refresh" hx-post="/branches/{{ b.id }}/refresh" {{ hx|safe }}>
|
|
<input type="hidden" name="_csrf" value="{{ p.csrf }}">
|
|
<button class="btn btn-ghost btn-sm" type="submit">Status aktualisieren</button>
|
|
</form>
|
|
{% if b.pr_info.get('comments') %}
|
|
<form method="post" action="/branches/{{ b.id }}/review-comments">
|
|
<input type="hidden" name="_csrf" value="{{ p.csrf }}">
|
|
<button class="btn btn-secondary btn-sm" type="submit">Kommentare einarbeiten</button>
|
|
</form>
|
|
{% endif %}
|
|
{% endif %}
|
|
{% endif %}
|
|
</div>
|
|
</div>
|
|
|
|
{% if not b.closed and not b.pr_id and v.commits %}
|
|
<details class="aiw-pr-form">
|
|
<summary class="btn btn-primary btn-sm">Pull Request erstellen</summary>
|
|
<form method="post" action="/branches/{{ b.id }}/pull-request" hx-post="/branches/{{ b.id }}/pull-request" {{ hx|safe }} class="stack stack-sm aiw-form">
|
|
<input type="hidden" name="_csrf" value="{{ p.csrf }}">
|
|
<div class="form-group"><label for="pr-title-{{ b.id }}">Titel</label>
|
|
<input id="pr-title-{{ b.id }}" name="title" required minlength="3" maxlength="200" value="{{ (v.commits[0].message.splitlines()[0] if v.commits|length == 1 else chat.title) }}"></div>
|
|
<div class="form-group"><label for="pr-text-{{ b.id }}">Beschreibung</label>
|
|
<textarea id="pr-text-{{ b.id }}" name="description" rows="4" maxlength="5000" placeholder="Was und warum; Commits und ein Link zum Chat werden angehängt."></textarea></div>
|
|
<label class="cluster text-sm"><input type="checkbox" name="draft" value="true" checked> Als Entwurf anlegen (später „Als bereit markieren“)</label>
|
|
<div class="cluster">
|
|
<button class="btn btn-primary btn-sm" type="submit">Pushen und Pull Request erstellen</button>
|
|
<span class="text-xs text-muted">Ziel {{ b.target }}. Geprüft wird im Review des Git-Servers.</span>
|
|
</div>
|
|
</form>
|
|
</details>
|
|
{% endif %}
|
|
|
|
<details>
|
|
<summary class="text-sm">Commits und Diff</summary>
|
|
<div class="stack stack-sm aiw-changes-detail">
|
|
<ul class="aiw-commit-list">
|
|
{% for c in v.commits|reverse %}
|
|
<li>
|
|
<code class="text-xs">{{ c.sha[:10] }}</code> {{ c.message.splitlines()[0] }}{% if c.merged %} <span class="badge badge-default">Abgleich{% if c.changes %}, {{ c.changes|length }} Konflikt{{ 'e' if c.changes|length != 1 }} gelöst{% endif %}</span>{% endif %}
|
|
<span class="text-xs text-muted">{{ c.created.astimezone().strftime('%d.%m. %H:%M') }} · {{ c.files|length }} Datei{{ 'en' if c.files|length != 1 }}{% if b.pushed and (c.sha == b.pushed) %} · bis hier übertragen{% endif %}</span>
|
|
{% if c.warnings %}<span class="badge badge-warning">{{ c.warnings|length }} Syntaxwarnung{{ 'en' if c.warnings|length != 1 }}</span>
|
|
<ul class="text-xs text-danger aiw-commit-warnings">{% for w in c.warnings %}<li><code>{{ w }}</code></li>{% endfor %}</ul>{% endif %}
|
|
</li>
|
|
{% endfor %}
|
|
</ul>
|
|
{% if not b.closed and b.unpushed and v.commits %}
|
|
<form method="post" action="/branches/{{ b.id }}/undo" hx-post="/branches/{{ b.id }}/undo" {{ hx|safe }} data-confirm="Letzten Commit zurücknehmen?">
|
|
<input type="hidden" name="_csrf" value="{{ p.csrf }}">
|
|
<button class="btn btn-ghost btn-sm" type="submit">Letzten Commit zurücknehmen</button>
|
|
</form>
|
|
{% endif %}
|
|
{% if v.diff %}
|
|
{% from "_diff.html" import diff %}{{ diff(v.diff) }}
|
|
{% if v.truncated %}<p class="text-xs text-muted">Diff gekürzt; vollständig im Pull Request bzw. nach dem Push im Git-Server.</p>{% endif %}
|
|
{% endif %}
|
|
</div>
|
|
</details>
|
|
</div>
|
|
</section>
|
|
{% endfor %}
|
|
</div>
|