Skip to content
Merged
Show file tree
Hide file tree
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
7 changes: 6 additions & 1 deletion src/sentry/api/serializers/models/group.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@ def merge_list_dictionaries(
dict1.setdefault(key, []).extend(val)


class GroupAnnotation(TypedDict):
displayName: str
url: str


class GroupStatusDetailsResponseOptional(TypedDict, total=False):
autoResolved: bool
ignoreCount: int
Expand Down Expand Up @@ -145,7 +150,7 @@ class BaseGroupSerializerResponse(BaseGroupResponseOptional):
isSubscribed: bool
subscriptionDetails: GroupSubscriptionResponseOptional | None
hasSeen: bool
annotations: Sequence[str]
annotations: Sequence[GroupAnnotation]


class SeenStats(TypedDict):
Expand Down
2 changes: 1 addition & 1 deletion src/sentry/integrations/mixins/issues.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ def map_external_issues_to_annotations(self, external_issues):
for ei in external_issues:
link = self.get_issue_url(ei.key)
label = self.get_issue_display_name(ei) or ei.key
annotations.append(f'<a href="{link}">{label}</a>')
annotations.append({"url": link, "displayName": label})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see no more usage of a href in the APIs 👍🏻


return annotations

Expand Down
2 changes: 1 addition & 1 deletion src/sentry/models/platformexternalissue.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def get_annotations_for_group_list(cls, group_list):
# group annotations by group id
annotations_by_group_id = defaultdict(list)
for ei in external_issues:
annotation = f'<a href="{ei.web_url}">{ei.display_name}</a>'
annotation = {"url": ei.web_url, "displayName": ei.display_name}
annotations_by_group_id[ei.group_id].append(annotation)

return annotations_by_group_id
10 changes: 4 additions & 6 deletions src/sentry/plugins/bases/issue.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

from django import forms
from django.conf import settings
from django.utils.html import format_html
from rest_framework.request import Request

from sentry.models.activity import Activity
Expand Down Expand Up @@ -312,11 +311,10 @@ def tags(self, request: Request, group, tag_list, **kwargs):
return tag_list

tag_list.append(
format_html(
'<a href="{}" rel="noreferrer">{}</a>',
self.get_issue_url(group=group, issue_id=issue_id),
self.get_issue_label(group=group, issue_id=issue_id),
)
{
"url": self.get_issue_url(group=group, issue_id=issue_id),
"displayName": self.get_issue_label(group=group, issue_id=issue_id),
}
)

return tag_list
Expand Down
10 changes: 4 additions & 6 deletions src/sentry/plugins/bases/issue2.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

from django.conf import settings
from django.urls import re_path, reverse
from django.utils.html import format_html
from rest_framework.request import Request
from rest_framework.response import Response

Expand Down Expand Up @@ -431,11 +430,10 @@ def tags(self, request: Request, group, tag_list, **kwargs):
return tag_list

tag_list.append(
format_html(
'<a href="{}">{}</a>',
self._get_issue_url_compat(group, issue),
self._get_issue_label_compat(group, issue),
)
{
"url": self._get_issue_url_compat(group, issue),
"displayName": self._get_issue_label_compat(group, issue),
}
)

return tag_list
Expand Down
8 changes: 5 additions & 3 deletions tests/sentry/api/endpoints/test_group_details.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ def test_platform_external_issue_annotation(self):
response = self.client.get(url, format="json")

assert response.data["annotations"] == [
'<a href="https://example.com/issues/2">Issue#2</a>'
{"url": "https://example.com/issues/2", "displayName": "Issue#2"}
]

def test_plugin_external_issue_annotation(self):
Expand All @@ -172,7 +172,9 @@ def test_plugin_external_issue_annotation(self):
url = f"/api/0/issues/{group.id}/"
response = self.client.get(url, format="json")

assert response.data["annotations"] == ['<a href="https://trello.com/c/134">Trello-134</a>']
assert response.data["annotations"] == [
{"url": "https://trello.com/c/134", "displayName": "Trello-134"}
]

def test_integration_external_issue_annotation(self):
group = self.create_group()
Expand All @@ -191,7 +193,7 @@ def test_integration_external_issue_annotation(self):
response = self.client.get(url, format="json")

assert response.data["annotations"] == [
'<a href="https://example.com/browse/api-123">api-123</a>'
{"url": "https://example.com/browse/api-123", "displayName": "api-123"}
]

def test_permalink_superuser(self):
Expand Down
2 changes: 1 addition & 1 deletion tests/sentry/integrations/test_issues.py
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ def test_annotations(self):
link = self.installation.get_issue_url(self.external_issue.key)

assert self.installation.get_annotations_for_group_list([self.group]) == {
self.group.id: [f'<a href="{link}">{label}</a>']
self.group.id: [{"url": link, "displayName": label}]
}

with assume_test_silo_mode(SiloMode.CONTROL):
Expand Down