Improve update config form
This commit is contained in:
parent
0cd23f7883
commit
a67e3af172
@ -253,10 +253,10 @@ def delete_release(package, id):
|
|||||||
|
|
||||||
|
|
||||||
class PackageUpdateConfigFrom(FlaskForm):
|
class PackageUpdateConfigFrom(FlaskForm):
|
||||||
trigger = SelectField("Trigger", [InputRequired()], choices=PackageUpdateTrigger.choices(), coerce=PackageUpdateTrigger.coerce,
|
trigger = RadioField("Trigger", [InputRequired()], choices=PackageUpdateTrigger.choices(), coerce=PackageUpdateTrigger.coerce,
|
||||||
default=PackageUpdateTrigger.TAG)
|
default=PackageUpdateTrigger.TAG)
|
||||||
ref = StringField("Branch name", [Optional()], default=None)
|
ref = StringField("Branch name", [Optional()], default=None)
|
||||||
action = SelectField("Action", [InputRequired()], choices=[("notification", "Notification"), ("make_release", "Create Release")], default="make_release")
|
action = RadioField("Action", [InputRequired()], choices=[("notification", "Send notification and mark as outdated"), ("make_release", "Create release")], default="make_release")
|
||||||
submit = SubmitField("Save Settings")
|
submit = SubmitField("Save Settings")
|
||||||
disable = SubmitField("Disable Automation")
|
disable = SubmitField("Disable Automation")
|
||||||
|
|
||||||
|
@ -154,19 +154,29 @@
|
|||||||
</div>
|
</div>
|
||||||
{%- endmacro %}
|
{%- endmacro %}
|
||||||
|
|
||||||
{% macro render_radio_field(field) -%}
|
{% macro render_radio_field(field, hint=None, label=None, label_visible=true) -%}
|
||||||
{% for value, label, checked in field.iter_choices() %}
|
<div class="form-group {% if field.errors %}has-danger{% endif %} {{ kwargs.pop('class_', '') }}">
|
||||||
<div class="form-check my-1">
|
{% if label_visible %}
|
||||||
<label class="form-check-label">
|
{% if not label and label != "" %}{% set label=field.label.text %}{% endif %}
|
||||||
<input class="form-check-input" type="radio" name="{{ field.id }}" id="{{ field.id }}" value="{{ value }}"{% if checked %} checked{% endif %}>
|
{% if label %}<label for="{{ field.id }}">{{ label|safe }}</label>{% endif %}
|
||||||
{{ label }}
|
{% endif %}
|
||||||
</label>
|
{% for value, label, checked in field.iter_choices() %}
|
||||||
</div>
|
<div class="form-check my-1">
|
||||||
{% endfor %}
|
<label class="form-check-label">
|
||||||
|
<input class="form-check-input" type="radio" name="{{ field.id }}" id="{{ field.id }}" value="{{ value }}"{% if checked %} checked{% endif %}>
|
||||||
|
{{ label }}
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
{% if hint %}
|
||||||
|
<small class="form-text text-muted">{{ hint | safe }}</small>
|
||||||
|
{% endif %}
|
||||||
|
{{ render_errors(field) }}
|
||||||
|
</div>
|
||||||
{%- endmacro %}
|
{%- endmacro %}
|
||||||
|
|
||||||
{% macro render_toggle_field(field, icons=[]) -%}
|
{% macro render_toggle_field(field, icons=[]) -%}
|
||||||
<div class="btn-group btn-group-toggle" data-toggle="buttons">
|
<div class="btn-group btn-group-toggle {{ kwargs.pop('class_', '') }}" data-toggle="buttons">
|
||||||
{% for value, label, checked in field.iter_choices() %}
|
{% for value, label, checked in field.iter_choices() %}
|
||||||
<label class="btn btn-primary{% if checked %} active{% endif %}">
|
<label class="btn btn-primary{% if checked %} active{% endif %}">
|
||||||
{% set icon = icons[value] %}
|
{% set icon = icons[value] %}
|
||||||
|
@ -18,19 +18,33 @@
|
|||||||
{{ _("Git Update Detection is clever enough to not create a release again if you've already created it manually or using webhooks/the API.") }}
|
{{ _("Git Update Detection is clever enough to not create a release again if you've already created it manually or using webhooks/the API.") }}
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
{% from "macros/forms.html" import render_field, render_submit_field, render_checkbox_field %}
|
{% from "macros/forms.html" import render_field, render_submit_field, render_radio_field %}
|
||||||
<form method="POST" action="">
|
<form method="POST" action="">
|
||||||
{{ form.hidden_tag() }}
|
{{ form.hidden_tag() }}
|
||||||
|
|
||||||
{{ render_field(form.trigger, class_="mt-5", hint=_("The event which triggers the action to occur.")) }}
|
<h3 class="mt-5">Trigger</h3>
|
||||||
|
|
||||||
|
<p class="text-muted">
|
||||||
|
{{ _("The trigger is the event that triggers the action.") }}
|
||||||
|
</p>
|
||||||
|
|
||||||
|
{{ render_radio_field(form.trigger, label_visible=false) }}
|
||||||
|
|
||||||
{{ render_field(form.ref, placeholder=_("Leave blank to use default branch"),
|
{{ render_field(form.ref, placeholder=_("Leave blank to use default branch"),
|
||||||
pattern="[A-Za-z0-9/._-]+",
|
pattern="[A-Za-z0-9/._-]+", class_="mt-3",
|
||||||
hint=_("Currently, the branch name field is only used by the New Commit trigger.")) }}
|
hint=_("Currently, the branch name field is only used by the New Commit trigger.")) }}
|
||||||
|
|
||||||
{{ render_field(form.action, hint=_("The action to perform.")) }}
|
|
||||||
|
|
||||||
<p class="mt-5">
|
<h3 class="mt-5">Action</h3>
|
||||||
|
|
||||||
|
<p class="text-muted">
|
||||||
|
{{ _("The action to perform when the trigger happens.") }}
|
||||||
|
{{ _("Once a package is marked as outdated, you won't receive any more notifications until it is marked up to date.") }}
|
||||||
|
</p>
|
||||||
|
|
||||||
|
{{ render_radio_field(form.action, label_visible=false) }}
|
||||||
|
|
||||||
|
<p class="mt-5 pt-4">
|
||||||
{{ render_submit_field(form.submit) }}
|
{{ render_submit_field(form.submit) }}
|
||||||
{{ render_submit_field(form.disable, class_="btn btn-secondary ml-2") }}
|
{{ render_submit_field(form.disable, class_="btn btn-secondary ml-2") }}
|
||||||
</p>
|
</p>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user