Skip to content

Commit

Permalink
Add Dispatch link to Jira ticket (#5352)
Browse files Browse the repository at this point in the history
  • Loading branch information
whitdog47 authored Oct 16, 2024
1 parent 581235c commit 8efea5c
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 25 deletions.
1 change: 1 addition & 0 deletions src/dispatch/plugins/dispatch_core/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ def update_case_ticket(
# reporter_email: str,
document_weblink: str,
storage_weblink: str,
dispatch_weblink: str,
case_type_plugin_metadata: dict = None,
):
"""Updates a Dispatch case ticket."""
Expand Down
8 changes: 8 additions & 0 deletions src/dispatch/plugins/dispatch_jira/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ def create_incident_issue_fields(
document_weblink: str,
storage_weblink: str,
conference_weblink: str,
dispatch_weblink: str,
cost: float,
):
"""Creates Jira issue fields."""
Expand Down Expand Up @@ -192,6 +193,7 @@ def create_incident_issue_fields(
conference_weblink=conference_weblink,
conversation_weblink=conversation_weblink,
storage_weblink=storage_weblink,
dispatch_weblink=dispatch_weblink,
)
issue_fields.update({"description": description})

Expand All @@ -210,6 +212,7 @@ def create_case_issue_fields(
assignee_username: str,
document_weblink: str,
storage_weblink: str,
dispatch_weblink: str,
):
"""Creates Jira issue fields."""
issue_fields = {}
Expand All @@ -226,6 +229,7 @@ def create_case_issue_fields(
document_weblink=document_weblink,
resolution=resolution,
storage_weblink=storage_weblink,
dispatch_weblink=dispatch_weblink,
)
issue_fields.update({"description": description})

Expand Down Expand Up @@ -329,6 +333,7 @@ def update(
document_weblink: str,
storage_weblink: str,
conference_weblink: str,
dispatch_weblink: str,
cost: float,
incident_type_plugin_metadata: dict = None,
):
Expand Down Expand Up @@ -357,6 +362,7 @@ def update(
document_weblink=document_weblink,
storage_weblink=storage_weblink,
conference_weblink=conference_weblink,
dispatch_weblink=dispatch_weblink,
cost=cost,
)

Expand Down Expand Up @@ -481,6 +487,7 @@ def update_case_ticket(
# reporter_email: str,
document_weblink: str,
storage_weblink: str,
dispatch_weblink: str,
case_type_plugin_metadata: dict = None,
):
"""Updates a case Jira issue."""
Expand All @@ -506,6 +513,7 @@ def update_case_ticket(
assignee_username=assignee_username,
document_weblink=document_weblink,
storage_weblink=storage_weblink,
dispatch_weblink=dispatch_weblink,
)

return update(self.configuration, client, issue, issue_fields, status)
Expand Down
2 changes: 2 additions & 0 deletions src/dispatch/plugins/dispatch_jira/templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
Cost: {{cost}}
*Incident Resources*
[Dispatch Link|{{dispatch_weblink}}]
[Conversation|{{conversation_weblink}}]
[Investigation Document|{{document_weblink}}]
[Storage|{{storage_weblink}}]
Expand Down Expand Up @@ -41,6 +42,7 @@
Priority: {{case_priority}}
*Case Resources*
[Dispatch Link|{{dispatch_weblink}}]
[Investigation Document|{{document_weblink}}]
[Storage|{{storage_weblink}}]
Expand Down
53 changes: 28 additions & 25 deletions src/dispatch/ticket/flows.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from dispatch.participant import service as participant_service
from dispatch.plugin import service as plugin_service
from dispatch.task.models import Task
from dispatch.config import DISPATCH_UI_URL

from .models import Ticket, TicketCreate
from .service import create
Expand Down Expand Up @@ -111,20 +112,21 @@ def update_incident_ticket(
# we update the external incident ticket
try:
plugin.instance.update(
incident.ticket.resource_id,
title,
description,
incident.incident_type.name,
incident.incident_severity.name,
incident.incident_priority.name,
incident.status.lower(),
incident.commander.individual.email,
incident.reporter.individual.email,
resolve_attr(incident, "conversation.weblink"),
resolve_attr(incident, "incident_document.weblink"),
resolve_attr(incident, "storage.weblink"),
resolve_attr(incident, "conference.weblink"),
total_cost,
ticket_id=incident.ticket.resource_id,
title=title,
description=description,
incident_type=incident.incident_type.name,
incident_severity=incident.incident_severity.name,
incident_priority=incident.incident_priority.name,
status=incident.status.lower(),
commander_email=incident.commander.individual.email,
reporter_email=incident.reporter.individual.email,
conversation_weblink=resolve_attr(incident, "conversation.weblink"),
document_weblink=resolve_attr(incident, "incident_document.weblink"),
storage_weblink=resolve_attr(incident, "storage.weblink"),
conference_weblink=resolve_attr(incident, "conference.weblink"),
dispatch_weblink=f"{DISPATCH_UI_URL}/{incident.project.organization.slug}/incidents/{incident.name}",
cost=total_cost,
incident_type_plugin_metadata=incident_type_plugin_metadata,
)
except Exception as e:
Expand Down Expand Up @@ -230,17 +232,18 @@ def update_case_ticket(
# we update the external case ticket
try:
plugin.instance.update_case_ticket(
case.ticket.resource_id,
title,
description,
case.resolution,
case.case_type.name,
case.case_severity.name,
case.case_priority.name,
case.status.lower(),
case.assignee.individual.email,
case_document_weblink,
case_storage_weblink,
ticket_id=case.ticket.resource_id,
title=title,
description=description,
resolution=case.resolution,
case_type=case.case_type.name,
case_severity=case.case_severity.name,
case_priority=case.case_priority.name,
status=case.status.lower(),
assignee_email=case.assignee.individual.email,
document_weblink=case_document_weblink,
storage_weblink=case_storage_weblink,
dispatch_weblink=f"{DISPATCH_UI_URL}/{case.project.organization.slug}/cases/{case.name}",
case_type_plugin_metadata=case_type_plugin_metadata,
)
except Exception as e:
Expand Down

0 comments on commit 8efea5c

Please sign in to comment.