| 1 |
{# Write controls for the notes on a commit. Expects `notes`, `can_write_notes`, |
| 2 |
`notes_merged`, `detail.oid`, and the csrf token. Deliberately separate from |
| 3 |
git_notes_panel.html, which is shared with the file view and stays read-only: |
| 4 |
P2 writes notes on commits, and a form that appeared beside a blob note would |
| 5 |
be offering something the routes do not accept. #} |
| 6 |
{% if can_write_notes %} |
| 7 |
{% if let Some(token) = csrf_token %} |
| 8 |
<div class="git-notes-edit"> |
| 9 |
{% if notes_merged %} |
| 10 |
<p class="git-note-merged"> |
| 11 |
Somebody edited this note while you were writing. Both versions were kept, |
| 12 |
so what is below is not exactly what you typed. |
| 13 |
</p> |
| 14 |
{% endif %} |
| 15 |
|
| 16 |
{# A note in a namespace the write routes refuse gets no form. makenot.work |
| 17 |
writes refs/notes/mnw/*, and offering an edit box that saves to a 422 is |
| 18 |
worse than offering nothing. #} |
| 19 |
{% for note in notes %} |
| 20 |
{% if !note.read_only %} |
| 21 |
<form class="git-note-form" method="post" action="/git/{{ owner }}/{{ repo_name }}/commit/{{ detail.oid }}/notes"> |
| 22 |
<input type="hidden" name="_csrf" value="{{ token }}"> |
| 23 |
<input type="hidden" name="namespace" value="{{ note.namespace }}"> |
| 24 |
<div class="form-group"> |
| 25 |
<label for="note-{{ loop.index }}">Edit the note in {{ note.namespace }}</label> |
| 26 |
<textarea id="note-{{ loop.index }}" name="content" rows="6" maxlength="50000">{{ note.source }}</textarea> |
| 27 |
</div> |
| 28 |
<button type="submit">Save note</button> |
| 29 |
</form> |
| 30 |
<form class="git-note-delete" method="post" action="/git/{{ owner }}/{{ repo_name }}/commit/{{ detail.oid }}/notes/delete"> |
| 31 |
<input type="hidden" name="_csrf" value="{{ token }}"> |
| 32 |
<input type="hidden" name="namespace" value="{{ note.namespace }}"> |
| 33 |
<button type="submit">Remove the note in {{ note.namespace }}</button> |
| 34 |
</form> |
| 35 |
{% endif %} |
| 36 |
{% endfor %} |
| 37 |
|
| 38 |
<form class="git-note-form" method="post" action="/git/{{ owner }}/{{ repo_name }}/commit/{{ detail.oid }}/notes"> |
| 39 |
<input type="hidden" name="_csrf" value="{{ token }}"> |
| 40 |
<div class="form-group"> |
| 41 |
<label for="note-new-namespace">Namespace</label> |
| 42 |
{# `commits` is what `git notes` writes with no namespace given, so a |
| 43 |
reader running stock git finds a note left at the default. #} |
| 44 |
<input id="note-new-namespace" name="namespace" value="commits" maxlength="64" required> |
| 45 |
</div> |
| 46 |
<div class="form-group"> |
| 47 |
<label for="note-new">Add a note</label> |
| 48 |
<textarea id="note-new" name="content" rows="6" maxlength="50000" placeholder="Markdown. Stored in the repository under refs/notes, and it travels with a clone that fetches them."></textarea> |
| 49 |
</div> |
| 50 |
<button type="submit">Add note</button> |
| 51 |
</form> |
| 52 |
</div> |
| 53 |
{% endif %} |
| 54 |
{% endif %} |
| 55 |
|