Skip to content

Commit

Permalink
chore(issues): cleanup old issue annotations (#74684)
Browse files Browse the repository at this point in the history
  • Loading branch information
oioki authored Jul 23, 2024
1 parent 9e27c8e commit c86e5a2
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 46 deletions.
15 changes: 12 additions & 3 deletions static/app/components/eventOrGroupExtraDetails.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,10 @@ describe('EventOrGroupExtraDetails', function () {
numComments: 14,
shortId: 'shortId',
logger: 'javascript logger',
annotations: ['annotation1', 'annotation2'],
annotations: [
{url: 'http://example.com', displayName: 'annotation1'},
{url: 'http://example.com', displayName: 'annotation2'},
],
assignedTo: {
name: 'Assignee Name',
},
Expand All @@ -80,7 +83,10 @@ describe('EventOrGroupExtraDetails', function () {
numComments: 14,
shortId: 'shortId',
logger: 'javascript logger',
annotations: ['annotation1', 'annotation2'],
annotations: [
{url: 'http://example.com', displayName: 'annotation1'},
{url: 'http://example.com', displayName: 'annotation2'},
],
assignedTo: {
name: 'Assignee Name',
},
Expand All @@ -103,7 +109,10 @@ describe('EventOrGroupExtraDetails', function () {
numComments: 14,
shortId: 'shortId',
logger: 'javascript logger',
annotations: ['annotation1', 'annotation2'],
annotations: [
{url: 'http://example.com', displayName: 'annotation1'},
{url: 'http://example.com', displayName: 'annotation2'},
],
subscriptionDetails: {reason: 'mentioned'},
} as Group
}
Expand Down
19 changes: 5 additions & 14 deletions static/app/components/eventOrGroupExtraDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,20 +95,11 @@ function EventOrGroupExtraDetails({data, showAssignee, organization}: Props) {
</GlobalSelectionLink>
</LoggerAnnotation>
)}
{annotations?.map((annotation, key) =>
typeof annotation === 'string' ? (
<AnnotationNoMargin
dangerouslySetInnerHTML={{
__html: annotation,
}}
key={key}
/>
) : (
<AnnotationNoMargin key={key}>
<ExternalLink href={annotation.url}>{annotation.displayName}</ExternalLink>
</AnnotationNoMargin>
)
)}
{annotations?.map((annotation, key) => (
<AnnotationNoMargin key={key}>
<ExternalLink href={annotation.url}>{annotation.displayName}</ExternalLink>
</AnnotationNoMargin>
))}

{showAssignee && assignedTo && (
<div>{tct('Assigned to [name]', {name: assignedTo.name})}</div>
Expand Down
2 changes: 1 addition & 1 deletion static/app/types/group.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -782,7 +782,7 @@ export const enum PriorityLevel {
// TODO(ts): incomplete
export interface BaseGroup {
activity: GroupActivity[];
annotations: string[] | Annotation[];
annotations: Annotation[];
assignedTo: Actor | null;
culprit: string;
firstSeen: string;
Expand Down
7 changes: 5 additions & 2 deletions static/app/utils/dashboards/issueFieldRenderers.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ describe('getIssueFieldRenderer', function () {
filteredEvents: 3000,
events: 6000,
period: '7d',
links: '<a href="sentry.io">ANNO-123</a>',
links: [{url: 'sentry.io', displayName: 'ANNO-123'}],
};

MockApiClient.addMockResponse({
Expand Down Expand Up @@ -152,7 +152,10 @@ describe('getIssueFieldRenderer', function () {
{
data,
...{
links: '<a href="sentry.io">ANNO-123</a>, <a href="sentry.io">ANNO-456</a>',
links: [
{url: 'sentry.io', displayName: 'ANNO-123'},
{url: 'sentry.io', displayName: 'ANNO-456'},
],
},
},
{
Expand Down
31 changes: 9 additions & 22 deletions static/app/utils/dashboards/issueFieldRenderers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import {DEFAULT_STATS_PERIOD} from 'sentry/constants';
import {t} from 'sentry/locale';
import MemberListStore from 'sentry/stores/memberListStore';
import {space} from 'sentry/styles/space';
import type {Annotation} from 'sentry/types/group';
import type {Organization} from 'sentry/types/organization';
import type {EventData} from 'sentry/utils/discover/eventView';
import EventView from 'sentry/utils/discover/eventView';
Expand Down Expand Up @@ -143,23 +142,15 @@ const SPECIAL_FIELDS: SpecialFields = {
},
links: {
sortField: null,
renderFunc: ({links}) => {
if (typeof links === 'string') {
return <LinksContainer dangerouslySetInnerHTML={{__html: links}} />;
}
if (isLinkAnnotation(links)) {
return (
<LinksContainer>
{links.map((link, index) => (
<ExternalLink key={index} href={link.url}>
{link.displayName}
</ExternalLink>
))}
</LinksContainer>
);
}
return <LinksContainer />;
},
renderFunc: ({links}) => (
<LinksContainer>
{links.map((link, index) => (
<ExternalLink key={index} href={link.url}>
{link.displayName}
</ExternalLink>
))}
</LinksContainer>
),
},
};

Expand Down Expand Up @@ -259,10 +250,6 @@ export function getSortField(field: string): string | null {
}
}

function isLinkAnnotation(value: unknown): value is Annotation[] {
return Array.isArray(value) && value.every(v => typeof v === 'object');
}

const contentStyle = css`
width: 100%;
justify-content: space-between;
Expand Down
2 changes: 1 addition & 1 deletion static/app/views/dashboards/datasetConfig/issues.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ describe('transformIssuesResponseToTable', function () {
id: '1',
'issue.id': '1',
lifetimeUsers: 5,
links: '',
links: [],
period: '',
projectId: '3',
status: 'unresolved',
Expand Down
4 changes: 1 addition & 3 deletions static/app/views/dashboards/datasetConfig/issues.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,7 @@ export function transformIssuesResponseToTable(
issue: shortId,
title,
project: project.slug,
links: annotations?.every(a => typeof a === 'string')
? annotations.join(', ')
: ((annotations ?? []) as any),
links: (annotations ?? []) as any,
};

// Get lifetime stats
Expand Down

0 comments on commit c86e5a2

Please sign in to comment.