Skip to content

Commit

Permalink
Squash a few routing / UI bugs (#1957)
Browse files Browse the repository at this point in the history
* Squash a few routing / UI bugs

- The delete button is not longer displayed when there isn't a callback configured
- Fixed an issue where the delete confirmation banner wasn't displaying in some circumstances
- Fixed a routing issue where deleting a received-text-messages callback was deleting the delivery status callback
- Fixed an issue where the Test callback button was not remaining on the same page after clicking

* Squash validation bug
  • Loading branch information
whabanks authored Sep 25, 2024
1 parent 5d71ce6 commit 381aac0
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 21 deletions.
69 changes: 53 additions & 16 deletions app/main/views/api_keys.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,8 @@ def delete_delivery_status_callback(service_id):
"default_with_tick")
return redirect(url_for(back_link, service_id=service_id))

flash(["{}".format(
_l("Are you sure you want to delete this callback configuration?"))], "delete")
flash(["{}".format(
_l("Are you sure you want to delete this callback configuration?"))], "delete")

form = ServiceDeliveryStatusCallbackForm(
url=delivery_status_callback.get(
Expand Down Expand Up @@ -250,26 +250,34 @@ def delivery_status_callback(service_id):
callback_api_id=delivery_status_callback.get("id"),
)

# If the user is just testing their URL, don't send them back to the API Integration page
if request.form.get("button_pressed") == "test_response_time":
flash(
_l("The service {} responded in {} seconds.").format(
url_hostname,
response_time,
),
"default_with_tick",
)
return redirect(url_for("main.delivery_status_callback", service_id=service_id))

# If the user is just testing their URL, don't send them back to the API Integration page
if request.form.get("button_pressed") == "test_response_time" and g.callback_response_time >= 1:
flash(
_l("We’ve saved your callback configuration. {} responded in {} seconds.").format(
_l("The service {} took longer than 1 second to respond.").format(
url_hostname,
),
"error",
)
return redirect(url_for("main.delivery_status_callback", service_id=service_id))
else:
flash(
_l("The service {} responded in {} seconds.").format(
url_hostname,
response_time,
),
"default_with_tick",
)
return redirect(url_for("main.delivery_status_callback", service_id=service_id))

return redirect(url_for(back_link, service_id=service_id))
flash(
_l("We’ve saved your callback configuration. {} responded in {} seconds.").format(
url_hostname,
response_time,
),
"default_with_tick",
)

return redirect(url_for(back_link, service_id=service_id))
# Create a new callback
elif form.url.data:
service_api_client.create_service_callback_api(
Expand Down Expand Up @@ -312,6 +320,16 @@ def delivery_status_callback(service_id):
)
return redirect(url_for("main.delivery_status_callback", service_id=service_id))

flash(
_l("We’ve saved your callback configuration. {} responded in {} seconds.").format(
url_hostname,
response_time,
),
"default_with_tick",
)

return redirect(url_for(back_link, service_id=service_id))

return render_template(
"views/api/callbacks/delivery-status-callback.html",
has_callback_config=delivery_status_callback is not None,
Expand Down Expand Up @@ -362,7 +380,15 @@ def received_text_messages_callback(service_id):
)

# If the user is just testing their URL, don't send them back to the API Integration page
if request.form.get("button_pressed") == "test_response_time":
if request.form.get("button_pressed") == "test_response_time" and g.callback_response_time >= 1:
flash(
_l("The service {} took longer than 1 second to respond.").format(
url_hostname,
),
"error",
)
return redirect(url_for("main.received_text_messages_callback", service_id=service_id))
else:
flash(
_l("The service {} responded in {} seconds.").format(
url_hostname,
Expand All @@ -379,6 +405,7 @@ def received_text_messages_callback(service_id):
),
"default_with_tick",
)
return redirect(url_for(back_link, service_id=service_id))

elif received_text_messages_callback and not form.url.data:
service_api_client.delete_service_inbound_api(
Expand Down Expand Up @@ -420,6 +447,16 @@ def received_text_messages_callback(service_id):
)
return redirect(url_for("main.received_text_messages_callback", service_id=service_id))

flash(
_l("We’ve saved your callback configuration. {} responded in {} seconds.").format(
url_hostname,
response_time,
),
"default_with_tick",
)

return redirect(url_for(back_link, service_id=service_id))

return render_template(
"views/api/callbacks/received-text-messages-callback.html",
has_callback_config=received_text_messages_callback is not None,
Expand Down
2 changes: 1 addition & 1 deletion app/templates/components/page-footer.html
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
button1_value="b1",
button2_text=None,
button2_value=None,
delete_link=False,
delete_link=None,
delete_link_text=_("Delete")) %}
<div class="js-stick-at-bottom-when-scrolling">
<div class="page-footer">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@ <h2 class="heading-small">
{% set test_response_txt = _('Test response time') if has_callback_config else None %}
{% set test_response_value = _('test_response_time') if has_callback_config else None %}
{% set display_footer = is_deleting if is_deleting else False %}
{% set delete_link = url_for('.delete_delivery_status_callback', service_id=current_service.id) if has_callback_config else None%}
{% if not display_footer %}
{{ sticky_page_footer_two_submit_buttons_and_delete_link(
button1_text=_('Save'),
button1_value=_('save'),
button2_text=test_response_txt,
button2_value=test_response_value,
delete_link=url_for('.delete_delivery_status_callback', service_id=current_service.id),
delete_link_text=_('Delete')
delete_link=delete_link,
) }}
{% endif %}
{% endcall %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,15 @@ <h2 class="heading-small">
{% set test_response_txt = _('Test response time') if has_callback_config else None %}
{% set test_response_value = _('test_response_time') if has_callback_config else None %}
{% set display_footer = is_deleting if is_deleting else False %}
{% set delete_link = url_for('.delete_received_text_messages_callback', service_id=current_service.id) if has_callback_config else None%}
{% set delete_link_text = _('Delete') if has_callback_config else None %}
{% if not display_footer %}
{{ sticky_page_footer_two_submit_buttons_and_delete_link(
button1_text=_('Save'),
button1_value=_('save'),
button2_text=test_response_txt,
button2_value=test_response_value,
delete_link=url_for('.delete_received_text_messages_callback', service_id=current_service.id),
delete_link_text=_('Delete')
delete_link=delete_link,
) }}
{% endif %}
{% endcall %}
Expand Down

0 comments on commit 381aac0

Please sign in to comment.