Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the Dispatch UI bookmark to incident channel #3680

Merged
merged 2 commits into from
Aug 9, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion src/dispatch/conversation/flows.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from dispatch.storage.models import Storage
from dispatch.ticket.models import Ticket
from dispatch.utils import deslug_and_capitalize_resource_type
from dispatch.config import DISPATCH_UI_URL

from .models import Conversation, ConversationCreate
from .service import create
Expand Down Expand Up @@ -233,13 +234,27 @@ def add_conversation_bookmarks(incident: Incident, db_session: SessionLocal):
"Storage bookmark not added. No storage available for this incident."
)

ticket_weblink = resolve_attr(incident, "ticket.weblink")
plugin.instance.add_bookmark(
incident.conversation.channel_id,
resolve_attr(incident, "ticket.weblink"),
ticket_weblink,
title="Ticket",
) if incident.ticket else log.warning(
"Ticket bookmark not added. No ticket available for this incident."
)

resource_id = (
f"dispatch-{incident.project.organization.slug}-{incident.project.slug}-{incident.id}"
)
dispatch_weblink = f"{DISPATCH_UI_URL}/{incident.project.organization.name}/incidents/{resource_id}?project={incident.project.name}"

# only add Dispatch UI ticket if not using Dispatch ticket plugin
if ticket_weblink != dispatch_weblink:
plugin.instance.add_bookmark(
incident.conversation.channel_id,
dispatch_weblink,
title="Dispatch UI",
)
except Exception as e:
event_service.log_incident_event(
db_session=db_session,
Expand Down