def create_rating_feedback_modal( user_id: str, user_email: str, channel_id: str, incident_id: int, action: dict, db_session=None, slack_client=None, ): """Creates a modal for rating and providing feedback about an incident.""" trigger_id = action["trigger_id"] incident = incident_service.get(db_session=db_session, incident_id=incident_id) if not incident: message = ( "Sorry, you cannot submit feedback about this incident. The incident does not exist." ) send_ephemeral_message(slack_client, channel_id, user_id, message) else: modal_create_template = rating_feedback_view(incident=incident) open_modal_with_user( client=slack_client, trigger_id=trigger_id, modal=modal_create_template )
def create_run_workflow_modal(incident_id: int, command: dict = None, db_session=None): """Creates a modal for running a workflow.""" trigger_id = command.get("trigger_id") incident = incident_service.get(db_session=db_session, incident_id=incident_id) workflows = workflow_service.get_enabled(db_session=db_session) if workflows: modal_create_template = build_workflow_blocks(incident=incident, workflows=workflows) dispatch_slack_service.open_modal_with_user( client=slack_client, trigger_id=trigger_id, modal=modal_create_template) else: blocks = [{ "type": "section", "text": { "type": "mrkdwn", "text": "No workflows are enabled. You can enable one in the Dispatch UI at /workflows.", }, }] dispatch_slack_service.send_ephemeral_message( slack_client, command["channel_id"], command["user_id"], "No workflows enabled.", blocks=blocks, )
def create_report_incident_modal(command: dict = None, db_session=None): """ Prepare the Modal / View x Ask slack to open a modal with the prepared Modal / View content """ channel_id = command.get("channel_id") trigger_id = command.get("trigger_id") type_options = [] for t in incident_type_service.get_all(db_session=db_session): type_options.append({"label": t.name, "value": t.name}) priority_options = [] for priority in incident_priority_service.get_all(db_session=db_session): priority_options.append({ "label": priority.name, "value": priority.name }) modal_view_template = create_modal_content( channel_id=channel_id, incident_types=type_options, incident_priorities=priority_options) dispatch_slack_service.open_modal_with_user(client=slack_client, trigger_id=trigger_id, modal=modal_view_template)
def create_update_incident_modal( user_id: str, user_email: str, channel_id: str, incident_id: int, command: dict = None, db_session=None, slack_client=None, ): """Creates a dialog for updating incident information.""" modal = update_incident(db_session=db_session, channel_id=channel_id, incident_id=incident_id) open_modal_with_user(client=slack_client, trigger_id=command["trigger_id"], modal=modal)
def create_report_incident_modal(incident_id: int, command: dict = None, db_session=None): """Creates a modal for reporting an incident.""" channel_id = command.get("channel_id") trigger_id = command.get("trigger_id") modal_create_template = build_report_incident_blocks(channel_id=channel_id, db_session=db_session) dispatch_slack_service.open_modal_with_user(client=slack_client, trigger_id=trigger_id, modal=modal_create_template)
def create_report_incident_modal( user_id: str, user_email: str, channel_id: str, incident_id: int, command: dict = None, db_session=None, slack_client=None, ): """Creates a modal for reporting an incident.""" trigger_id = command.get("trigger_id") modal_create_template = report_incident(channel_id=channel_id, db_session=db_session) open_modal_with_user(client=slack_client, trigger_id=trigger_id, modal=modal_create_template)
def create_add_timeline_event_modal(incident_id: int, command: dict, db_session=None): """Creates a modal for adding events to the incident timeline.""" trigger_id = command["trigger_id"] incident = incident_service.get(db_session=db_session, incident_id=incident_id) modal_create_template = build_add_timeline_event_blocks(incident=incident) dispatch_slack_service.open_modal_with_user(client=slack_client, trigger_id=trigger_id, modal=modal_create_template)
def create_update_participant_modal(incident_id: int, command: dict, db_session=None): """Creates a modal for updating a participant.""" trigger_id = command["trigger_id"] incident = incident_service.get(db_session=db_session, incident_id=incident_id) modal_create_template = build_update_participant_blocks(incident=incident) dispatch_slack_service.open_modal_with_user(client=slack_client, trigger_id=trigger_id, modal=modal_create_template)
def create_add_timeline_event_modal( user_id: str, user_email: str, channel_id: str, incident_id: int, command: dict, db_session=None, slack_client=None, ): """Creates a modal for adding events to the incident timeline.""" trigger_id = command["trigger_id"] incident = incident_service.get(db_session=db_session, incident_id=incident_id) modal_create_template = add_timeline_event(incident=incident) open_modal_with_user(client=slack_client, trigger_id=trigger_id, modal=modal_create_template)
def create_update_participant_modal( user_id: str, user_email: str, channel_id: str, incident_id: int, command: dict, db_session=None, slack_client=None, ): """Creates a modal for updating a participant.""" trigger_id = command["trigger_id"] incident = incident_service.get(db_session=db_session, incident_id=incident_id) modal_create_template = update_participant(incident=incident) open_modal_with_user(client=slack_client, trigger_id=trigger_id, modal=modal_create_template)
def create_update_notifications_group_modal(incident_id: int, command: dict, db_session=None): """Creates a modal for editing members of the notifications group.""" trigger_id = command["trigger_id"] incident = incident_service.get(db_session=db_session, incident_id=incident_id) modal_create_template = build_update_notifications_group_blocks( incident=incident, db_session=db_session) dispatch_slack_service.open_modal_with_user(client=slack_client, trigger_id=trigger_id, modal=modal_create_template)
def create_rating_feedback_modal(user_id: str, user_email: str, incident_id: int, action: dict, db_session=None): """Creates a modal for rating and providing feedback about an incident.""" trigger_id = action["trigger_id"] incident = incident_service.get(db_session=db_session, incident_id=incident_id) modal_create_template = build_rating_feedback_blocks(incident=incident) dispatch_slack_service.open_modal_with_user(client=slack_client, trigger_id=trigger_id, modal=modal_create_template)
def create_update_notifications_group_modal( user_id: str, user_email: str, channel_id: str, incident_id: int, command: dict, db_session=None, slack_client=None, ): """Creates a modal for editing members of the notifications group.""" trigger_id = command["trigger_id"] incident = incident_service.get(db_session=db_session, incident_id=incident_id) modal_create_template = update_notifications_group(incident=incident, db_session=db_session) open_modal_with_user(client=slack_client, trigger_id=trigger_id, modal=modal_create_template)
def create_run_workflow_modal( user_id: str, user_email: str, channel_id: str, incident_id: int, command: dict, config: SlackConversationConfiguration = None, db_session=None, slack_client=None, ): """Creates a modal for running a workflow.""" trigger_id = command.get("trigger_id") incident = incident_service.get(db_session=db_session, incident_id=incident_id) workflows = workflow_service.get_enabled(db_session=db_session) workflows = [x for x in workflows if x.plugin_instance.enabled] if workflows: modal_create_template = run_workflow_view(incident=incident, workflows=workflows) open_modal_with_user(client=slack_client, trigger_id=trigger_id, modal=modal_create_template) else: blocks = [{ "type": "section", "text": { "type": "mrkdwn", "text": "No workflows are enabled or workflows plugin is not enabled. You can enable one in the Dispatch UI at /workflows.", }, }] send_ephemeral_message( slack_client, command["channel_id"], command["user_id"], "No workflows enabled.", blocks=blocks, )