diff --git a/hc/front/tests/test_add_channel.py b/hc/front/tests/test_add_channel.py index 8d415487..854f0328 100644 --- a/hc/front/tests/test_add_channel.py +++ b/hc/front/tests/test_add_channel.py @@ -51,11 +51,29 @@ class AddChannelTestCase(BaseTestCase): def test_instructions_work(self): self.client.login(username="alice@example.org", password="password") - for frag in ("email", "webhook", "pd", "pushover", "slack", "hipchat", "victorops"): + for frag in ("email", "webhook", "pd", "pushover", "hipchat", "victorops"): url = "/integrations/add_%s/" % frag r = self.client.get(url) self.assertContains(r, "Integration Settings", status_code=200) + @override_settings(SLACK_CLIENT_ID=None) + def test_slack_webhook_instructions_work(self): + self.client.login(username="alice@example.org", password="password") + r = self.client.get("/integrations/add_slack/") + self.assertContains(r, "Integration Settings", status_code=200) + + @override_settings(SLACK_CLIENT_ID="foo") + def test_slack_button(self): + self.client.login(username="alice@example.org", password="password") + r = self.client.get("/integrations/add_slack/") + self.assertContains(r, "slack.com/oauth/authorize", status_code=200) + + @override_settings(SLACK_CLIENT_ID="foo") + def test_slack_landing_page(self): + r = self.client.get("/integrations/add_slack/") + self.assertContains(r, "Before adding Slack integration", + status_code=200) + def test_it_adds_pushover_channel(self): self.client.login(username="alice@example.org", password="password") diff --git a/hc/front/views.py b/hc/front/views.py index b06249da..2f877531 100644 --- a/hc/front/views.py +++ b/hc/front/views.py @@ -270,8 +270,7 @@ def channels(request): "page": "channels", "channels": channels, "num_checks": num_checks, - "enable_pushover": settings.PUSHOVER_API_TOKEN is not None, - "slack_client_id": settings.SLACK_CLIENT_ID + "enable_pushover": settings.PUSHOVER_API_TOKEN is not None } return render(request, "front/channels.html", ctx) @@ -374,9 +373,14 @@ def add_pd(request): return render(request, "integrations/add_pd.html", ctx) -@login_required def add_slack(request): - ctx = {"page": "channels"} + if not settings.SLACK_CLIENT_ID and not request.user.is_authenticated(): + return redirect("hc-login") + + ctx = { + "page": "channels", + "slack_client_id": settings.SLACK_CLIENT_ID + } return render(request, "integrations/add_slack.html", ctx) diff --git a/static/img/integrations/setup_slack_btn_1.png b/static/img/integrations/setup_slack_btn_1.png new file mode 100644 index 00000000..e7aaca70 Binary files /dev/null and b/static/img/integrations/setup_slack_btn_1.png differ diff --git a/static/img/integrations/setup_slack_btn_2.png b/static/img/integrations/setup_slack_btn_2.png new file mode 100644 index 00000000..f3afc397 Binary files /dev/null and b/static/img/integrations/setup_slack_btn_2.png differ diff --git a/static/img/integrations/setup_slack_btn_3.png b/static/img/integrations/setup_slack_btn_3.png new file mode 100644 index 00000000..f6df7086 Binary files /dev/null and b/static/img/integrations/setup_slack_btn_3.png differ diff --git a/templates/front/channels.html b/templates/front/channels.html index f84ab537..0e08ec4f 100644 --- a/templates/front/channels.html +++ b/templates/front/channels.html @@ -128,14 +128,7 @@

Slack

A messaging app for teams.

- - {% if slack_client_id %} - - Add to Slack - - {% else %} Add Integration - {% endif %}
  • + + {% if slack_client_id %} +
    + {% if request.user.is_authenticated %} +

    If your team uses Slack, you can set + up healthchecks.io to post status updates directly to an appropriate + Slack channel.

    + +
    + + Add to Slack + +
    + + {% else %} +

    + healthchecks.io is a free and + open source + service for monitoring your cron jobs, background processes and + scheduled tasks. Before adding Slack integration, please log into + healthchecks.io:

    + +
    +
    + {% csrf_token %} + +
    +
    +
    @
    + +
    +
    +
    + +
    +
    +
    + {% endif %} +
    + +

    Setup Guide

    + +
    +
    + 2 +

    + After {% if request.user.is_authenticated %}{% else %}logging in and{% endif %} + clicking on "Add to Slack", you should + be on a page that says "healthchecks.io would like access to + your Slack team". Select the team you want to add the + healthchecks.io integration app to. +

    +
    +
    + Screenshot +
    +
    + +
    +
    + 3 +

    + You should now be on a page that says "healthchecks.io would + like access to TEAM NAME". Select the channel you want to + post healthchecks.io notifications to. +

    +
    +
    + Screenshot +
    +
    + +
    +
    + 4 +

    + That is all! You will now be redirected back to + "Integrations" page on healthchecks.io and see + the new integration! +

    +
    +
    + Screenshot +
    +
    + {% else %}

    Slack

    If your team uses Slack, you can set @@ -14,6 +116,7 @@ Slack channel.

    Setup Guide

    +
    1 @@ -68,6 +171,8 @@
    + {% endif %} +