def handle_edit_incident_button(incident: Incident, user_id: str, message: json, trigger_id: str): dialog = Dialog( title=f"Edit Incident {incident.pk}", submit_label="Save", state=incident.pk, elements=[ Text(label="Report", name="report", value=incident.report), TextArea(label="Summary", name="summary", value=incident.summary, optional=True, placeholder="Can you share any more details?"), TextArea( label="Impact", name="impact", value=incident.impact, optional=True, placeholder="Who or what might be affected?", hint="Think about affected people, systems, and processes"), SelectFromUsers(label="Lead", name="lead", value=incident.lead, optional=True), SelectWithOptions([(i, s.capitalize()) for i, s in Incident.SEVERITIES], value=incident.severity, label="Severity", name="severity", optional=True) ]) dialog.send_open_dialog(INCIDENT_EDIT_DIALOG, trigger_id)
def handle_page_oncall_engineer(context: ActionContext): dialog = Dialog( title=f"Escalate to {context.button_value}", submit_label="Escalate", elements=[ DialogText(label="Message", name="message", placeholder="Why do you need them?", hint="You might be waking this person up. Please make this friendly and clear."), ], state=context.button_value ) dialog.send_open_dialog(PAGE_SPECIALIST_DIALOG, context.trigger_id) return True
def slash_command(request): """ Handles slash commands from slack More details here: https://api.slack.com/slash-commands @param request the request from slack containing the slash command @return: return a HTTP response to indicate the request was handled """ user_id = request.POST.get('user_id') trigger_id = request.POST.get('trigger_id') report = request.POST.get('text') dialog = Dialog( title="Report an Incident", submit_label="Report", elements=[ Text(label="Report", name="report", placeholder="What's the tl;dr?", value=report), TextArea(label="Summary", name="summary", optional=True, placeholder="Can you share any more details?"), TextArea( label="Impact", name="impact", optional=True, placeholder="Who or what might be affected?", hint="Think about affected people, systems, and processes"), SelectFromUsers(label="Lead", name="lead", optional=True), SelectWithOptions([(i, s.capitalize()) for i, s in Incident.SEVERITIES], label="Severity", name="severity", optional=True) ]) dialog.send_open_dialog(INCIDENT_REPORT_DIALOG, trigger_id) return HttpResponse()