From b751d48702908f640b4db0a4db237bfd5cee9569 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Tue, 13 Oct 2020 21:28:10 -0700 Subject: [PATCH] Introduce a new modal view when the user clicks the "New Hunt" button This modal doesn't yet _do_ anything but it shows the basic idea of how we'll be collecting data. --- turbot/actions.py | 5 +++++ turbot/views.py | 31 +++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/turbot/actions.py b/turbot/actions.py index f9dc83d..c68de14 100644 --- a/turbot/actions.py +++ b/turbot/actions.py @@ -1,6 +1,11 @@ +import turbot.views + def new_hunt(turb, payload): print("In new_hunt function") + view = turbot.views.new_hunt() + turb.slack_client.views_open(trigger_id=payload['trigger_id'], + view=view) return { 'statusCode': 200, diff --git a/turbot/views.py b/turbot/views.py index 2acc474..fdd5eeb 100644 --- a/turbot/views.py +++ b/turbot/views.py @@ -29,6 +29,23 @@ def button(label, name): "value": name } +def input(label, name, placeholder): + return { + "type": "input", + "element": { + "type": "plain_text_input", + "action_id": name, + "placeholder": { + "type": "plain_text", + "text": placeholder, + } + }, + "label": { + "type": "plain_text", + "text": label + } + } + def hunt_block(hunt): text = "{}: <#{}>".format(hunt['name'], hunt['channel']) return section(text_block(text)) @@ -51,3 +68,17 @@ def home(turb, user_id, body): actions(button("New hunt", "new_hunt")) ] } + +def new_hunt(): + """Returns a view to be published as the new_hunt modal""" + + return { + "type": "modal", + "title": { "type": "plain_text", "text": "New Hunt" }, + "submit": { "type": "plain_text", "text": "Create" }, + "blocks": [ + input("Hunt name", "name", "Name of the hunt"), + input("Hunt ID", "slug", "Short prefix for hunt (no spaces)"), + input("Hunt URL", "url", "External URL of hunt") + ] + } -- 2.43.0