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):
|
||||
trigger = SelectField("Trigger", [InputRequired()], choices=PackageUpdateTrigger.choices(), coerce=PackageUpdateTrigger.coerce,
|
||||
trigger = RadioField("Trigger", [InputRequired()], choices=PackageUpdateTrigger.choices(), coerce=PackageUpdateTrigger.coerce,
|
||||
default=PackageUpdateTrigger.TAG)
|
||||
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")
|
||||
disable = SubmitField("Disable Automation")
|
||||
|
||||
|
@ -154,19 +154,29 @@
|
||||
</div>
|
||||
{%- endmacro %}
|
||||
|
||||
{% macro render_radio_field(field) -%}
|
||||
{% for value, label, checked in field.iter_choices() %}
|
||||
<div class="form-check my-1">
|
||||
<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 %}
|
||||
{% macro render_radio_field(field, hint=None, label=None, label_visible=true) -%}
|
||||
<div class="form-group {% if field.errors %}has-danger{% endif %} {{ kwargs.pop('class_', '') }}">
|
||||
{% if label_visible %}
|
||||
{% if not label and label != "" %}{% set label=field.label.text %}{% endif %}
|
||||
{% if label %}<label for="{{ field.id }}">{{ label|safe }}</label>{% endif %}
|
||||
{% endif %}
|
||||
{% for value, label, checked in field.iter_choices() %}
|
||||
<div class="form-check my-1">
|
||||
<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 %}
|
||||
|
||||
{% 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() %}
|
||||
<label class="btn btn-primary{% if checked %} active{% endif %}">
|
||||
{% 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.") }}
|
||||
</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.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"),
|
||||
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.")) }}
|
||||
|
||||
{{ 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.disable, class_="btn btn-secondary ml-2") }}
|
||||
</p>
|
||||
|
Loading…
x
Reference in New Issue
Block a user