Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ describe('FeedbackActivitySection', () => {
{
type: GroupActivityType.NOTE,
id: 'note-1',
commentId: 'note-1',
data: {text: 'Existing feedback note'},
dateCreated: '2020-01-01T00:00:00',
user,
Expand Down Expand Up @@ -89,6 +90,7 @@ describe('FeedbackActivitySection', () => {
method: 'POST',
body: {
id: 'note-2',
commentId: 'note-2',
user,
type: 'note',
data: {text: comment},
Expand Down Expand Up @@ -127,6 +129,7 @@ describe('FeedbackActivitySection', () => {
{
type: GroupActivityType.NOTE,
id: 'note-1',
commentId: 'note-1',
data: {text: 'Existing feedback note'},
dateCreated: '2020-01-01T00:00:00',
user,
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 @@ -708,11 +708,11 @@ export interface GroupActivityIntegrationData {
}

export interface GroupActivityNote extends GroupActivityBase {
commentId: string;
data: {
text: string;
};
type: GroupActivityType.NOTE;
commentId?: string;
}

interface GroupActivitySetResolved extends GroupActivityBase {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,7 @@ function activity(
actor: GroupActivity['user'] = user
): GroupActivity {
return {
...(type === GroupActivityType.NOTE ? {commentId: type} : {}),
data,
dateCreated: '2025-01-01T00:00:00Z',
id: type,
Expand Down
27 changes: 22 additions & 5 deletions static/app/views/issueDetails/activitySection/index.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ describe('ActivitySection', () => {
{
type: GroupActivityType.NOTE,
id: 'note-1',
commentId: 'note-1',
data: {text: 'Test Note'},
dateCreated: '2020-01-01T00:00:00',
user,
Expand Down Expand Up @@ -82,6 +83,7 @@ describe('ActivitySection', () => {
method: 'POST',
body: {
id: 'note-2',
commentId: 'note-2',
user: UserFixture({id: '2'}),
type: 'note',
data: {text: comment},
Expand Down Expand Up @@ -122,6 +124,7 @@ describe('ActivitySection', () => {
method: 'POST',
body: {
id: 'note-3',
commentId: 'note-3',
user: UserFixture({id: '2'}),
type: 'note',
data: {text: comment},
Expand Down Expand Up @@ -152,6 +155,7 @@ describe('ActivitySection', () => {
method: 'POST',
body: {
id: 'note-4',
commentId: 'note-4',
user: UserFixture({id: '2'}),
type: 'note',
data: {text: '@Jane Doe'},
Expand Down Expand Up @@ -181,12 +185,14 @@ describe('ActivitySection', () => {
);
});

it.each([
{id: '123', commentId: undefined},
{id: '987', commentId: '123'},
])('deletes only the comment with identity %j', async identity => {
it('deletes only the referenced comment', async () => {
jest.spyOn(indicators, 'addSuccessMessage');
const note = ActivityFeedFixture({...identity, user, data: {text: 'Test Note'}});
const note = ActivityFeedFixture({
id: '987',
commentId: '123',
user,
data: {text: 'Test Note'},
});
const resolution = ActivityFeedFixture({
id: '123',
type: GroupActivityType.SET_RESOLVED,
Expand Down Expand Up @@ -234,6 +240,7 @@ describe('ActivitySection', () => {
{
type: GroupActivityType.NOTE,
id: 'note-1',
commentId: 'note-1',
data: {text: 'Undeletable Note'},
dateCreated: '2020-01-01T00:00:00',
user,
Expand Down Expand Up @@ -274,6 +281,7 @@ describe('ActivitySection', () => {
{
type: GroupActivityType.NOTE,
id: 'note-1',
commentId: 'note-1',
data: {text: '**Bold Note** and [docs](https://docs.sentry.io/)'},
dateCreated: tenMinutesAgo(),
user,
Expand Down Expand Up @@ -305,6 +313,7 @@ describe('ActivitySection', () => {
{
type: GroupActivityType.NOTE,
id: 'note-1',
commentId: 'note-1',
data: {text: 'User note'},
dateCreated: '2020-01-01T00:00:00',
user,
Expand Down Expand Up @@ -875,6 +884,7 @@ describe('ActivitySection', () => {
{
type: GroupActivityType.NOTE,
id: 'note-1',
commentId: 'note-1',
data: {text: 'This note came from my sentry app'},
dateCreated: '2020-01-01T00:00:00',
sentry_app: sentryApp,
Expand Down Expand Up @@ -932,6 +942,7 @@ describe('ActivitySection', () => {
{
type: GroupActivityType.NOTE,
id: 'note-1',
commentId: 'note-1',
data: {text: 'Test Note'},
dateCreated: '2020-01-01T00:00:00',
user: UserFixture({id: '2'}),
Expand Down Expand Up @@ -959,6 +970,7 @@ describe('ActivitySection', () => {
const activities: GroupActivity[] = Array.from({length: 7}, (_, index) => ({
type: GroupActivityType.NOTE,
id: `note-${index + 1}`,
commentId: `note-${index + 1}`,
data: {text: `Test Note ${index + 1}`},
dateCreated: '2020-01-01T00:00:00',
user: UserFixture({id: '2'}),
Expand Down Expand Up @@ -989,6 +1001,7 @@ describe('ActivitySection', () => {
const activities: GroupActivity[] = Array.from({length: 3}, (_, index) => ({
type: GroupActivityType.NOTE,
id: `note-${index + 1}`,
commentId: `note-${index + 1}`,
data: {text: `Test Note ${index + 1}`},
dateCreated: '2020-01-01T00:00:00',
user: UserFixture({id: '2'}),
Expand Down Expand Up @@ -1026,6 +1039,7 @@ describe('ActivitySection', () => {
const activities: GroupActivity[] = Array.from({length: 7}, (_, index) => ({
type: GroupActivityType.NOTE,
id: `note-${index + 1}`,
commentId: `note-${index + 1}`,
data: {text: `Test Note ${index + 1}`},
dateCreated: tenMinutesAgo(),
user: UserFixture({id: '2'}),
Expand Down Expand Up @@ -1114,6 +1128,7 @@ describe('ActivitySection', () => {
const activities: GroupActivity[] = Array.from({length: 3}, (_, index) => ({
type: GroupActivityType.NOTE,
id: `note-${index + 1}`,
commentId: `note-${index + 1}`,
data: {text: `Test Note ${index + 1}`},
dateCreated: '2020-01-01T00:00:00',
user: UserFixture({id: '2'}),
Expand Down Expand Up @@ -1788,6 +1803,7 @@ describe('ActivitySection', () => {
{
type: GroupActivityType.NOTE,
id: 'note-between-pull-request-activities',
commentId: 'note-between-pull-request-activities',
dateCreated: '2020-01-01T00:01:00',
data: {text: 'An activity between the pull request activities'},
user,
Expand Down Expand Up @@ -2065,6 +2081,7 @@ describe('ActivitySection', () => {
{
type: GroupActivityType.NOTE,
id: 'activity-during-rca',
commentId: 'activity-during-rca',
dateCreated: '2020-01-01T00:02:00Z',
data: {text: 'Checked during analysis'},
user,
Expand Down
13 changes: 6 additions & 7 deletions static/app/views/issueDetails/activitySection/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ interface ActivityFeedRowProps {

function getActivityKey(activity: GroupActivity): string {
return isActivityNote(activity)
? `comment:${activity.commentId ?? activity.id}`
? `comment:${activity.commentId}`
: `activity:${activity.id}`;
}

Expand Down Expand Up @@ -151,28 +151,27 @@ export function ActivitySection({
}

async function handleDelete(item: GroupActivityNote) {
const commentId = item.commentId ?? item.id;
const commentId = item.commentId;
await deleteComment(commentId);
trackAnalytics('issue_details.comment_deleted', {organization});
addSuccessMessage(t('Comment removed'));
onActivityChange?.(
activities.filter(
activity =>
!isActivityNote(activity) || (activity.commentId ?? activity.id) !== commentId
activity => !isActivityNote(activity) || activity.commentId !== commentId
)
);
}

async function handleUpdate(item: GroupActivityNote, data: NoteType) {
try {
const commentId = item.commentId ?? item.id;
const commentId = item.commentId;
const result = await updateComment(commentId, data);
trackAnalytics('issue_details.comment_updated', {organization});
addSuccessMessage(t('Comment updated'));
onActivityChange?.(
activities.map(activity =>
isActivityNote(activity) && (activity.commentId ?? activity.id) === commentId
? {...activity, commentId, data: {...activity.data, ...result.data}}
isActivityNote(activity) && activity.commentId === commentId
? {...activity, data: {...activity.data, ...result.data}}
: activity
)
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,9 @@ export function useMutateActivity({organization, group}: Props) {
case 'PUT':
return updateGroup(
prev.json.activity.map(item =>
item.type === GroupActivityType.NOTE &&
(item.commentId ?? item.id) === mutation.noteId
item.type === GroupActivityType.NOTE && item.commentId === mutation.noteId
? {
...item,
commentId: mutation.noteId,
data: {...item.data, ...result.data},
}
: item
Expand All @@ -102,7 +100,7 @@ export function useMutateActivity({organization, group}: Props) {
prev.json.activity.filter(
item =>
item.type !== GroupActivityType.NOTE ||
(item.commentId ?? item.id) !== mutation.noteId
item.commentId !== mutation.noteId
),
prev.json.numComments - 1
);
Expand Down
1 change: 1 addition & 0 deletions static/app/views/issueDetails/sidebar/sidebar.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ describe('IssueDetailsSidebar', () => {
{
type: GroupActivityType.NOTE,
id: 'note-1',
commentId: 'note-1',
data: {text: activityContent},
dateCreated: '2020-01-01T00:00:00',
user,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ describe('ProgressActivityTooltip', () => {
it('shows comment text', async () => {
const noteActivity: GroupActivity = {
id: 'activity-4',
commentId: 'activity-4',
type: GroupActivityType.NOTE,
data: {text: 'This is the useful part of the comment.'},
dateCreated: '2024-01-04T00:00:00.000Z',
Expand Down
1 change: 1 addition & 0 deletions tests/js/fixtures/activityFeed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {GroupActivityType, IssueCategory, IssueType} from 'sentry/types/group';

export function ActivityFeedFixture(params: Partial<Activity> = {}): Activity {
return {
commentId: params.id ?? '42',
data: {text: 'Very interesting comment'},
dateCreated: '2019-04-29T21:43:32.280Z',
user: UserFixture({
Expand Down
Loading