Skip to content

Commit 61dfc50

Browse files
committed
fix(performance): restore project prop usage and error handling in transaction threshold modal
- Fix dropped project prop by updating useEventViewProject to accept optional project parameter - Fix missing DELETE error handler in handleReset by adding .catch() block - Ensures correct project is used in multi-project views - Prevents unhandled promise rejections when reset fails
1 parent fb3127f commit 61dfc50

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

static/app/views/performance/transactionSummary/projectUtils.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,22 @@ import type {Project} from 'sentry/types/project';
44
import {defined} from 'sentry/utils';
55
import type EventView from 'sentry/utils/discover/eventView';
66

7-
export function useEventViewProject(eventView: EventView, projects: Project[]) {
7+
export function useEventViewProject(
8+
eventView: EventView,
9+
projects: Project[],
10+
project?: string
11+
) {
812
return useMemo(() => {
913
if (!defined(eventView)) {
1014
return undefined;
1115
}
1216

17+
if (defined(project)) {
18+
return projects.find(proj => proj.id === project);
19+
}
20+
1321
const projectId = String(eventView.project[0]);
1422

1523
return projects.find(proj => proj.id === projectId);
16-
}, [eventView, projects]);
24+
}, [eventView, projects, project]);
1725
}

static/app/views/performance/transactionSummary/transactionThresholdModal.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ function TransactionThresholdModal({
5555
organization,
5656
closeModal,
5757
onApply,
58+
project: projectProp,
5859
projects,
5960
transactionName,
6061
transactionThreshold,
@@ -66,7 +67,7 @@ function TransactionThresholdModal({
6667
const [metric, setMetric] = useState<TransactionThresholdMetric | undefined>(
6768
transactionThresholdMetric
6869
);
69-
const project = useEventViewProject(eventView, projects);
70+
const project = useEventViewProject(eventView, projects, projectProp);
7071

7172
const handleApply = (event: React.FormEvent) => {
7273
event.preventDefault();
@@ -148,6 +149,14 @@ function TransactionThresholdModal({
148149
const errorMessage = err.responseJSON?.threshold ?? null;
149150
addErrorMessage(errorMessage);
150151
});
152+
})
153+
.catch(err => {
154+
let errorMessage =
155+
err.responseJSON?.threshold ?? err.responseJSON?.non_field_errors ?? null;
156+
if (Array.isArray(errorMessage)) {
157+
errorMessage = errorMessage[0];
158+
}
159+
addErrorMessage(errorMessage);
151160
});
152161
};
153162

0 commit comments

Comments
 (0)