diff --git a/CHANGELOG.md b/CHANGELOG.md index 02293a92..fe112655 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ All notable changes to this project will be documented in this file. - Add the `pruneflips` management command - Add Mattermost integration (#276) - Three choices in timezone switcher (UTC / check's timezone / browser's timezone) (#278) +- After adding a new check redirect to the "Check Details" page ## Bug Fixes - Fix javascript code to construct correct URLs when running from a subdirectory (#273) diff --git a/hc/front/tests/test_add_check.py b/hc/front/tests/test_add_check.py index cf9d8443..3da7396e 100644 --- a/hc/front/tests/test_add_check.py +++ b/hc/front/tests/test_add_check.py @@ -12,20 +12,26 @@ class AddCheckTestCase(BaseTestCase): def test_it_works(self): self.client.login(username="alice@example.org", password="password") r = self.client.post(self.url) - self.assertRedirects(r, self.redirect_url) + check = Check.objects.get() self.assertEqual(check.project, self.project) + redirect_url = "/checks/%s/details/?new" % check.code + self.assertRedirects(r, redirect_url) + def test_it_handles_unset_current_project(self): self.profile.current_project = None self.profile.save() self.client.login(username="alice@example.org", password="password") r = self.client.post(self.url) - self.assertRedirects(r, self.redirect_url) + check = Check.objects.get() self.assertEqual(check.project, self.project) + redirect_url = "/checks/%s/details/?new" % check.code + self.assertRedirects(r, redirect_url) + def test_team_access_works(self): self.client.login(username="bob@example.org", password="password") self.client.post(self.url) diff --git a/hc/front/tests/test_details.py b/hc/front/tests/test_details.py index 8690df89..d3119134 100644 --- a/hc/front/tests/test_details.py +++ b/hc/front/tests/test_details.py @@ -43,3 +43,8 @@ class DetailsTestCase(BaseTestCase): self.client.login(username="bob@example.org", password="password") r = self.client.get(self.url) self.assertEqual(r.status_code, 200) + + def test_it_shows_new_check_notice(self): + self.client.login(username="alice@example.org", password="password") + r = self.client.get(self.url + "?new") + self.assertContains(r, "Your new check is ready!", status_code=200) diff --git a/hc/front/views.py b/hc/front/views.py index d4fe3bae..0f446e0c 100644 --- a/hc/front/views.py +++ b/hc/front/views.py @@ -292,7 +292,8 @@ def add_check(request, code): check.assign_all_channels() - return redirect("hc-checks", code) + url = reverse("hc-details", args=[check.code]) + return redirect(url + "?new") @require_POST @@ -478,6 +479,7 @@ def details(request, code): "channels": channels, "timezones": pytz.all_timezones, "downtimes": check.downtimes(months=3), + "is_new": "new" in request.GET, } return render(request, "front/details.html", ctx) diff --git a/static/css/details.css b/static/css/details.css index 188953bc..92066b0d 100644 --- a/static/css/details.css +++ b/static/css/details.css @@ -95,3 +95,11 @@ font-weight: normal; color: #888; } + +.alert.no-events { + border: #ddd; + background: #F5F5F5; + color: #444; + text-align: center; + padding: 32px; +} diff --git a/static/js/details.js b/static/js/details.js index 1488da70..8aecb87f 100644 --- a/static/js/details.js +++ b/static/js/details.js @@ -6,6 +6,11 @@ $(function () { return false; }); + $("#new-check-alert a").click(function() { + $("#" + this.dataset.target).click(); + return false; + }); + $("#edit-desc").click(function() { $('#update-name-modal').modal("show"); $("#update-desc-input").focus(); diff --git a/templates/front/details.html b/templates/front/details.html index 70210c11..ffa13f90 100644 --- a/templates/front/details.html +++ b/templates/front/details.html @@ -7,6 +7,26 @@ {% block content %}
+ Your new check is ready! + You can now + give it a name + or + set its schedule. +
+