Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow reducing the number of Slack buttons on every alert-group post #4206

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import json
import typing

from django.conf import settings
from django.utils.text import Truncator

from apps.alerts.incident_appearance.renderers.base_renderer import AlertBaseRenderer, AlertGroupBaseRenderer
Expand Down Expand Up @@ -245,23 +246,26 @@ def _get_buttons_blocks(self):
},
)

buttons.append(
{
"text": {"type": "plain_text", "text": "Responders", "emoji": True},
if not settings.FEATURE_FEWER_SLACK_BUTTONS:
buttons.append(
{
"text": {"type": "plain_text", "text": "Responders", "emoji": True},
"type": "button",
"value": self._alert_group_action_value(),
"action_id": ScenarioStep.get_step(
"manage_responders", "StartManageResponders"
).routing_uid(),
},
)

attach_button = {
"text": {"type": "plain_text", "text": "Attach to ...", "emoji": True},
"type": "button",
"action_id": ScenarioStep.get_step("distribute_alerts", "SelectAttachGroupStep").routing_uid(),
"value": self._alert_group_action_value(),
"action_id": ScenarioStep.get_step("manage_responders", "StartManageResponders").routing_uid(),
},
)

attach_button = {
"text": {"type": "plain_text", "text": "Attach to ...", "emoji": True},
"type": "button",
"action_id": ScenarioStep.get_step("distribute_alerts", "SelectAttachGroupStep").routing_uid(),
"value": self._alert_group_action_value(),
}
buttons.append(attach_button)
else:
}
buttons.append(attach_button)
elif not settings.FEATURE_FEWER_SLACK_BUTTONS:
buttons.append(
{
"text": {"type": "plain_text", "text": "Unresolve", "emoji": True},
Expand All @@ -271,7 +275,7 @@ def _get_buttons_blocks(self):
},
)

if self.alert_group.channel.is_available_for_custom_templates:
if self.alert_group.channel.is_available_for_custom_templates and not settings.FEATURE_FEWER_SLACK_BUTTONS:
buttons.append(
{
"text": {"type": "plain_text", "text": ":mag: Format Alert", "emoji": True},
Expand All @@ -298,7 +302,8 @@ def _get_buttons_blocks(self):
if resolution_notes_count == 0:
resolution_notes_button["style"] = "primary"
resolution_notes_button["text"]["text"] = "Add Resolution notes"
buttons.append(resolution_notes_button)
if resolution_notes_count > 0 or not settings.FEATURE_FEWER_SLACK_BUTTONS:
buttons.append(resolution_notes_button)

# Declare incident button
if self.alert_group.channel.organization.is_grafana_incident_enabled:
Expand Down
2 changes: 2 additions & 0 deletions engine/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@
FEATURE_LABELS_ENABLED_PER_ORG = getenv_list("FEATURE_LABELS_ENABLED_PER_ORG", default=list())
FEATURE_ALERT_GROUP_SEARCH_ENABLED = getenv_boolean("FEATURE_ALERT_GROUP_SEARCH_ENABLED", default=False)

FEATURE_FEWER_SLACK_BUTTONS = getenv_boolean("FEATURE_FEWER_SLACK_BUTTONS", default=False)

TWILIO_API_KEY_SID = os.environ.get("TWILIO_API_KEY_SID")
TWILIO_API_KEY_SECRET = os.environ.get("TWILIO_API_KEY_SECRET")
TWILIO_ACCOUNT_SID = os.environ.get("TWILIO_ACCOUNT_SID")
Expand Down