Skip to content

Commit

Permalink
Adds util function to deslug and capitalize a resource type string an…
Browse files Browse the repository at this point in the history
…d fixes name for incident review document Slack bookmark name (#3125)
  • Loading branch information
mvilanova authored Mar 17, 2023
1 parent a649fad commit c2136b0
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/dispatch/conversation/flows.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from dispatch.plugin import service as plugin_service
from dispatch.storage.models import Storage
from dispatch.ticket.models import Ticket
from dispatch.utils import deslug_and_capitalize_resource_type

from .models import Conversation, ConversationCreate
from .service import create
Expand Down Expand Up @@ -174,10 +175,11 @@ def add_conversation_bookmark(incident: Incident, resource: Resource, db_session
return

try:
title = deslug_and_capitalize_resource_type(resource.resource_type)
plugin.instance.add_bookmark(
incident.conversation.channel_id,
resource.weblink,
title=resource.name,
title=title,
) if resource else log.warning(
f"{resource.name} bookmark not added. No {resource.name.lower()} available for this incident."
)
Expand Down
1 change: 1 addition & 0 deletions src/dispatch/static/dispatch/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ declare module 'vue' {
AnimatedNumber: typeof import('./src/components/AnimatedNumber.vue')['default']
AppDrawer: typeof import('./src/components/AppDrawer.vue')['default']
AppToolbar: typeof import('./src/components/AppToolbar.vue')['default']
BaseCombobox: typeof import('./src/components/BaseCombobox.vue')['default']
BasicLayout: typeof import('./src/components/layouts/BasicLayout.vue')['default']
ColorPickerInput: typeof import('./src/components/ColorPickerInput.vue')['default']
DashboardLayout: typeof import('./src/components/layouts/DashboardLayout.vue')['default']
Expand Down
3 changes: 3 additions & 0 deletions src/dispatch/utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
def deslug_and_capitalize_resource_type(resource_type: str) -> str:
"""Deslugs and capitalizes each word of a given resource type string."""
return " ".join([w.capitalize() for w in resource_type.split("-")[1:]])

0 comments on commit c2136b0

Please sign in to comment.