Skip to content

Commit

Permalink
fix(slack): display edits in Slack update
Browse files Browse the repository at this point in the history
  • Loading branch information
GabDug committed Sep 27, 2024
1 parent 4dfee1d commit ccd7cf2
Showing 1 changed file with 54 additions and 32 deletions.
86 changes: 54 additions & 32 deletions src/firefighter/slack/messages/slack_messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,18 +359,20 @@ def get_blocks(self) -> list[Block]:
if len(fields) == 0:
fields.append("_No changes detected._")

blocks.extend([
DividerBlock(),
SectionBlock(
block_id="message_role_update",
fields=fields,
accessory=ButtonElement(
text="Update",
value=str(self.incident.id),
action_id=UpdateRolesModal.open_action,
blocks.extend(
[
DividerBlock(),
SectionBlock(
block_id="message_role_update",
fields=fields,
accessory=ButtonElement(
text="Update",
value=str(self.incident.id),
action_id=UpdateRolesModal.open_action,
),
),
),
])
]
)
if not self.first_update:
blocks.append(
ContextBlock(
Expand Down Expand Up @@ -457,6 +459,16 @@ def get_blocks(self) -> list[Block]:
blocks.append(
slack_block_quote(self.incident_update.message),
)
if self.incident_update.title and self.incident_update.title != "":
blocks.append(
SectionBlock(
text=f"New title: *{shorten(self.incident_update.title, 2985)}*"
),
)
if self.incident_update.description and self.incident_update.description != "":
blocks.append(
slack_block_quote(self.incident_update.description),
)
fields = []
if self.in_channel:
if self.incident_update.status:
Expand All @@ -477,24 +489,32 @@ def get_blocks(self) -> list[Block]:
text=f":package: *Component:* {self.incident.component.group.name} - {self.incident.component.name}"
)
)
if self.incident_update.environment:
fields.append(
MarkdownTextObject(
text=f":round_pushpin: *Environment:* {self.incident_update.environment.value}"
)
)

if len(fields) > 0:
blocks.extend([
DividerBlock(),
SectionBlock(
block_id="message_status_update",
fields=fields,
accessory=(
ButtonElement(
text="Update",
value=str(self.incident.id),
action_id=UpdateStatusModal.open_action,
)
if self.in_channel
else None
blocks.extend(
[
DividerBlock(),
SectionBlock(
block_id="message_status_update",
fields=fields,
accessory=(
ButtonElement(
text="Update",
value=str(self.incident.id),
action_id=UpdateStatusModal.open_action,
)
if self.in_channel
else None
),
),
),
])
]
)

if self.incident_update.created_by:
blocks.append(
Expand Down Expand Up @@ -683,13 +703,15 @@ def get_blocks(self) -> list[Block]:
]

if self.incident.status >= IncidentStatus.FIXED:
blocks.extend([
SectionBlock(
text=MarkdownTextObject(
text=f":white_check_mark: *UPDATE*: Incident #{self.incident.conversation.name} has been mitigated, you can resume your deployments."
blocks.extend(
[
SectionBlock(
text=MarkdownTextObject(
text=f":white_check_mark: *UPDATE*: Incident #{self.incident.conversation.name} has been mitigated, you can resume your deployments."
)
)
)
])
]
)
return blocks

def get_text(self) -> str:
Expand Down

0 comments on commit ccd7cf2

Please sign in to comment.