Skip to content

Commit

Permalink
Remove the deprecated "Format Alert" button from the Slack renderer (#…
Browse files Browse the repository at this point in the history
…5141)

# What this PR does

Removes the deprecated "Format Alert" button from the Slack renderer

## Which issue(s) this PR closes

Related to [issue link here]

<!--
*Note*: If you want the issue to be auto-closed once the PR is merged,
change "Related to" to "Closes" in the line above.
If you have more than one GitHub issue that this PR closes, be sure to
preface
each issue link with a [closing
keyword](https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/using-keywords-in-issues-and-pull-requests#linking-a-pull-request-to-an-issue).
This ensures that the issue(s) are auto-closed once the PR has been
merged.
-->

## Checklist

- [ ] Unit, integration, and e2e (if applicable) tests updated
- [ ] Documentation added (or `pr:no public docs` PR label added if not
required)
- [ ] Added the relevant release notes label (see labels prefixed w/
`release:`). These labels dictate how your PR will
    show up in the autogenerated release notes.
  • Loading branch information
iskhakov authored Oct 14, 2024
1 parent e0816dd commit 0672d06
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -202,9 +202,6 @@ def _make_button(text, action_id_step_class_name, action_id_scenario_step="distr
unsilence_button = _make_button("Unsilence", "UnSilenceGroupStep")
responders_button = _make_button("Responders", "StartManageResponders", "manage_responders")
attach_button = _make_button("Attach to ...", "SelectAttachGroupStep")
format_alert_button = _make_button(
":mag: Format Alert", "OpenAlertAppearanceDialogStep", "alertgroup_appearance"
)

resolution_notes_count = alert_group.resolution_notes.count()
resolution_notes_button = {
Expand Down Expand Up @@ -275,9 +272,6 @@ def _make_button(text, action_id_step_class_name, action_id_scenario_step="distr
else:
buttons.append(unresolve_button)

if integration.is_available_for_custom_templates:
buttons.append(format_alert_button)

buttons.append(resolution_notes_button)

if grafana_incident_enabled and not alert_group.acknowledged:
Expand Down
26 changes: 1 addition & 25 deletions engine/apps/slack/tests/test_slack_renderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,30 +235,6 @@ def test_slack_renderer_unattach_button(make_organization, make_alert_receive_ch
)


@pytest.mark.django_db
def test_slack_renderer_format_alert_button(
make_organization, make_alert_receive_channel, make_alert_group, make_alert
):
organization = make_organization()
alert_receive_channel = make_alert_receive_channel(organization)
alert_group = make_alert_group(alert_receive_channel)
make_alert(alert_group=alert_group, raw_request_data={})

elements = AlertGroupSlackRenderer(alert_group).render_alert_group_attachments()[0]["blocks"][0]["elements"]

button = elements[5]
assert button["text"]["text"] == ":mag: Format Alert"
assert json.loads(button["value"]) == json.loads(
make_value(
{
"organization_id": organization.pk,
"alert_group_ppk": alert_group.public_primary_key,
},
organization,
)
)


@pytest.mark.django_db
def test_slack_renderer_resolution_notes_button(
make_organization, make_alert_receive_channel, make_alert_group, make_alert
Expand All @@ -270,7 +246,7 @@ def test_slack_renderer_resolution_notes_button(

elements = AlertGroupSlackRenderer(alert_group).render_alert_group_attachments()[0]["blocks"][0]["elements"]

button = elements[6]
button = elements[5]
assert button["text"]["text"] == "Add Resolution notes"
assert json.loads(button["value"]) == json.loads(
make_value(
Expand Down
2 changes: 0 additions & 2 deletions engine/apps/slack/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,6 @@ def post(self, request):
if isinstance(payload, str):
payload = json.JSONDecoder().decode(payload)

logger.info(f"Slack payload is {payload}")

# Checking if it's repeated Slack request
if "HTTP_X_SLACK_RETRY_NUM" in request.META and int(request.META["HTTP_X_SLACK_RETRY_NUM"]) > 1:
logger.critical(
Expand Down

0 comments on commit 0672d06

Please sign in to comment.