1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2026-11-11 04:36:48 +00:00

fix(instances): a refused XML definition comes back in its editor

On the machine step, "Or define it from XML" lost the definition when it
was refused: a taken name re-rendered the page with an empty, collapsed
editor; malformed XML went on to libvirt, and libvirt's refusal sent the
browser back to an empty page with the reason at the top.

All three refusals now render the page with the section open, the
submitted XML in the editor (and in the field it posts, so it can be sent
again unchanged), and the reason above the editor, which takes the focus.

Fixes #174

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
catborise 2026-10-24 11:19:02 +03:00
parent 575077c8ac
commit 9c6e07a467
3 changed files with 48 additions and 13 deletions

View file

@ -48,14 +48,15 @@
<div class="card-body">
<h2 class="h5 card-title mb-0" id="xml-heading">
<button class="btn p-0 border-0 text-body fw-medium w-100 text-start focus-ring disclosure" type="button" data-bs-toggle="collapse" data-bs-target="#from-xml"
aria-expanded="false" aria-controls="from-xml">
aria-expanded="{% if xml_error %}true{% else %}false{% endif %}" aria-controls="from-xml">
{% bs_icon 'chevron-down' %} {% trans "Or define it from XML" %}
</button>
</h2>
<div class="collapse" id="from-xml">
<div class="collapse{% if xml_error %} show{% endif %}" id="from-xml">
<form method="post" class="pt-3" aria-label="{% trans "Create instance from XML" %}">{% csrf_token %}
<input type="hidden" name="dom_xml">
<div class="xmlheight mb-3"><textarea id="editor" aria-label="{% trans "Domain XML" %}"></textarea></div>
{% if xml_error %}<div class="alert alert-danger form-errors" role="alert">{{ xml_error }}</div>{% endif %}
<input type="hidden" name="dom_xml" value="{{ xml }}">
<div class="xmlheight mb-3"><textarea id="editor" aria-label="{% trans "Domain XML" %}">{{ xml }}</textarea></div>
<div class="d-flex justify-content-end">
<button type="submit" class="btn btn-primary" name="create_xml" onclick="showPleaseWaitDialog()">
{% trans "Create VM" %}