Skip to content

Commit

Permalink
Autofill the tactical report's action section with opened tasks (#3554)
Browse files Browse the repository at this point in the history
  • Loading branch information
metroid-samus authored Aug 9, 2023
1 parent 7288f74 commit 0888e2f
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/dispatch/incident/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,12 @@ class TaskRead(DispatchBase):
weblink: Optional[str]


class TaskReadMinimal(DispatchBase):
id: PrimaryKey
description: Optional[str] = Field(None, nullable=True)
status: TaskStatus = TaskStatus.open


# Pydantic models...
class IncidentBase(DispatchBase):
title: str
Expand Down Expand Up @@ -309,6 +315,7 @@ class IncidentReadMinimal(IncidentBase):
reporters_location: Optional[str]
stable_at: Optional[datetime] = None
tags: Optional[List[TagRead]] = []
tasks: Optional[List[TaskReadMinimal]] = []
total_cost: Optional[float]


Expand Down
10 changes: 10 additions & 0 deletions src/dispatch/plugins/dispatch_slack/incident/interactive.py
Original file line number Diff line number Diff line change
Expand Up @@ -1493,6 +1493,16 @@ def handle_report_tactical_command(
actions = tactical_report.details.get("actions")
needs = tactical_report.details.get("needs")

incident = incident_service.get(db_session=db_session, incident_id=context["subject"].id)
if incident.tasks:
actions = "\n".join(
[
"-" + task.description
for task in incident.tasks
if task.status != TaskStatus.resolved
]
)

blocks = [
Input(
label="Conditions",
Expand Down
7 changes: 7 additions & 0 deletions src/dispatch/static/dispatch/src/incident/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,13 @@ const actions = {
showReportDialog({ commit }, incident) {
commit("SET_DIALOG_REPORT", true)
commit("SET_SELECTED", incident)

state.report.tactical.actions = incident.tasks.reduce((result, task) => {
if (task.status == "Resolved") {
return result
}
return (result ? result + "\n" : "") + "- " + task.description
}, "")
},
closeReportDialog({ commit }) {
commit("SET_DIALOG_REPORT", false)
Expand Down

0 comments on commit 0888e2f

Please sign in to comment.