forked from GithubBackups/healthchecks
Show a warning in project's top navigation if the project has no configured integrations. Fixes #327
This commit is contained in:
parent
c3608ac07c
commit
15b9611c5a
@ -15,6 +15,7 @@ All notable changes to this project will be documented in this file.
|
|||||||
- Added an example of capturing and submitting log output (#315)
|
- Added an example of capturing and submitting log output (#315)
|
||||||
- The sendalerts commands measures dwell time and reports it over statsd protocol
|
- The sendalerts commands measures dwell time and reports it over statsd protocol
|
||||||
- Django 3.0.3
|
- Django 3.0.3
|
||||||
|
- Show a warning in top navigation if the project has no integrations (#327)
|
||||||
|
|
||||||
### Bug Fixes
|
### Bug Fixes
|
||||||
- Increase the allowable length of Matrix room alias to 100 (#320)
|
- Increase the allowable length of Matrix room alias to 100 (#320)
|
||||||
|
@ -282,8 +282,15 @@ class Project(models.Model):
|
|||||||
break
|
break
|
||||||
return status
|
return status
|
||||||
|
|
||||||
def have_broken_channels(self):
|
def have_channel_issues(self):
|
||||||
return self.channel_set.exclude(last_error="").exists()
|
errors = list(self.channel_set.values_list("last_error", flat=True))
|
||||||
|
|
||||||
|
# It's a problem if a project has no integrations at all
|
||||||
|
if len(errors) == 0:
|
||||||
|
return True
|
||||||
|
|
||||||
|
# It's a problem if any integration has a logged error
|
||||||
|
return True if max(errors) else False
|
||||||
|
|
||||||
|
|
||||||
class Member(models.Model):
|
class Member(models.Model):
|
||||||
|
@ -15,9 +15,15 @@ class ProjectModelTestCase(BaseTestCase):
|
|||||||
self.assertEqual(self.project.num_checks_available(), 18)
|
self.assertEqual(self.project.num_checks_available(), 18)
|
||||||
|
|
||||||
def test_it_handles_zero_broken_channels(self):
|
def test_it_handles_zero_broken_channels(self):
|
||||||
self.assertFalse(self.project.have_broken_channels())
|
Channel.objects.create(kind="webhook", last_error="", project=self.project)
|
||||||
|
|
||||||
|
self.assertFalse(self.project.have_channel_issues())
|
||||||
|
|
||||||
def test_it_handles_one_broken_channel(self):
|
def test_it_handles_one_broken_channel(self):
|
||||||
Channel.objects.create(kind="webhook", last_error="x", project=self.project)
|
Channel.objects.create(kind="webhook", last_error="x", project=self.project)
|
||||||
|
|
||||||
self.assertTrue(self.project.have_broken_channels())
|
self.assertTrue(self.project.have_channel_issues())
|
||||||
|
|
||||||
|
def test_it_handles_no_channels(self):
|
||||||
|
# It's an issue if the project has no channels at all:
|
||||||
|
self.assertTrue(self.project.have_channel_issues())
|
||||||
|
@ -126,7 +126,7 @@ class ChannelsTestCase(BaseTestCase):
|
|||||||
r = self.client.get("/integrations/")
|
r = self.client.get("/integrations/")
|
||||||
self.assertRedirects(r, "/")
|
self.assertRedirects(r, "/")
|
||||||
|
|
||||||
def test_it_shows_broken_channel_indicator(self):
|
def test_it_shows_channel_issues_indicator(self):
|
||||||
Channel.objects.create(kind="sms", project=self.project, last_error="x")
|
Channel.objects.create(kind="sms", project=self.project, last_error="x")
|
||||||
|
|
||||||
self.client.login(username="alice@example.org", password="password")
|
self.client.login(username="alice@example.org", password="password")
|
||||||
|
@ -97,7 +97,7 @@
|
|||||||
<a href="{% url 'hc-checks' project.code %}">Checks</a>
|
<a href="{% url 'hc-checks' project.code %}">Checks</a>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
{% with b=project.have_broken_channels %}
|
{% with b=project.have_channel_issues %}
|
||||||
<li {% if b %}id="broken-channels"{% endif %} {% if page == 'channels' %}class="active"{% endif %}>
|
<li {% if b %}id="broken-channels"{% endif %} {% if page == 'channels' %}class="active"{% endif %}>
|
||||||
<a href="{% url 'hc-channels' %}">
|
<a href="{% url 'hc-channels' %}">
|
||||||
Integrations
|
Integrations
|
||||||
|
@ -150,8 +150,14 @@
|
|||||||
{% endfor %}
|
{% endfor %}
|
||||||
</table>
|
</table>
|
||||||
{% else %}
|
{% else %}
|
||||||
<div class="alert alert-info">
|
<div class="alert alert-danger">
|
||||||
The project <strong>{{ project }}</strong> has no integrations set up yet.
|
<p> The project "{{ project }}" does not have any integrations
|
||||||
|
set up yet.
|
||||||
|
</p>
|
||||||
|
<p>With no configured integrations, {% site_name %}
|
||||||
|
<strong>will not send any notifications</strong>
|
||||||
|
when checks change state.
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user