Skip to content

Commit

Permalink
Remove unefficient check and add post block warning to use critical c…
Browse files Browse the repository at this point in the history
…ommand
  • Loading branch information
jennafauconnier committed Nov 28, 2024
1 parent 2f7389a commit 2cb44cc
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions src/firefighter/slack/views/modals/critical.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
from slack_sdk.models.views import View

from firefighter.incidents.forms.create_incident import CreateIncidentForm
from firefighter.incidents.models.incident_membership import IncidentMembership
from firefighter.slack.slack_app import SlackApp
from firefighter.slack.utils import respond
from firefighter.slack.views.modals.base_modal.base import ModalForm

if TYPE_CHECKING:
Expand Down Expand Up @@ -78,7 +76,12 @@ class CriticalModal(ModalForm[CriticalFormSlack]):

def build_modal_fn(self, **kwargs: Any) -> View:
form_instance = self.get_form_class()()
blocks = form_instance.slack_blocks()
blocks = [
SectionBlock(
text="*Warning:* The use of `/critical` is reserved for experienced users."
),
*form_instance.slack_blocks(),
]

return View(
type="modal",
Expand All @@ -93,10 +96,6 @@ def build_modal_fn(self, **kwargs: Any) -> View:
def handle_modal_fn( # type: ignore
self, ack: Ack, body: dict[str, Any], user: User
) -> None :
if not self.is_user_member_of_incident(user):
ack()
respond(body, text=":x: You must be linked to an incident to use this command.")
return

slack_form = self.handle_form_errors(
ack, body, forms_kwargs={},
Expand All @@ -123,8 +122,5 @@ def handle_modal_fn( # type: ignore
logger.warning("Form is empty, no data captured.")
return

def is_user_member_of_incident(self, user: User) -> bool:
return IncidentMembership.objects.filter(user=user).exists()


modal_critical = CriticalModal()

0 comments on commit 2cb44cc

Please sign in to comment.