Skip to content

Commit 07fe05e

Browse files
authored
fix(performance): Display thresholds in all summary tabs (#27256)
Display the threshold and metric in all the transaction summary tabs. Perviously it only showed up in the main summary page.
1 parent 276ba81 commit 07fe05e

File tree

6 files changed

+295
-133
lines changed

6 files changed

+295
-133
lines changed

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

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,6 @@ type Props = {
7070
onChangeFilter: (newFilter: SpanOperationBreakdownFilter) => void;
7171
onChangeThreshold?: (threshold: number, metric: TransactionThresholdMetric) => void;
7272
spanOperationBreakdownFilter: SpanOperationBreakdownFilter;
73-
transactionThreshold?: number;
74-
transactionThresholdMetric?: TransactionThresholdMetric;
75-
loadingThreshold?: boolean;
7673
};
7774

7875
type State = {
@@ -219,9 +216,6 @@ class SummaryContent extends React.Component<Props, State> {
219216
onChangeFilter,
220217
onChangeThreshold,
221218
spanOperationBreakdownFilter,
222-
transactionThreshold,
223-
transactionThresholdMetric,
224-
loadingThreshold,
225219
} = this.props;
226220
const hasPerformanceEventsPage = organization.features.includes(
227221
'performance-events-page'
@@ -334,9 +328,6 @@ class SummaryContent extends React.Component<Props, State> {
334328
hasWebVitals={hasWebVitals}
335329
handleIncompatibleQuery={this.handleIncompatibleQuery}
336330
onChangeThreshold={onChangeThreshold}
337-
transactionThreshold={transactionThreshold}
338-
transactionThresholdMetric={transactionThresholdMetric}
339-
loadingThreshold={loadingThreshold}
340331
/>
341332
<Layout.Body>
342333
<StyledSdkUpdatesAlert />

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

Lines changed: 8 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import * as React from 'react';
22
import styled from '@emotion/styled';
33
import {Location} from 'history';
44

5-
import {openModal} from 'app/actionCreators/modal';
65
import Feature from 'app/components/acl/feature';
76
import {GuideAnchor} from 'app/components/assistant/guideAnchor';
87
import Button from 'app/components/button';
@@ -25,10 +24,8 @@ import {tagsRouteWithQuery} from './transactionTags/utils';
2524
import {vitalsRouteWithQuery} from './transactionVitals/utils';
2625
import KeyTransactionButton from './keyTransactionButton';
2726
import TeamKeyTransactionButton from './teamKeyTransactionButton';
28-
import TransactionThresholdModal, {
29-
modalCss,
30-
TransactionThresholdMetric,
31-
} from './transactionThresholdModal';
27+
import TransactionThresholdButton from './transactionThresholdButton';
28+
import {TransactionThresholdMetric} from './transactionThresholdModal';
3229
import {transactionSummaryRouteWithQuery} from './utils';
3330

3431
export enum Tab {
@@ -50,9 +47,6 @@ type Props = {
5047
handleIncompatibleQuery: React.ComponentProps<
5148
typeof CreateAlertFromViewButton
5249
>['onIncompatibleQuery'];
53-
transactionThreshold?: number;
54-
transactionThresholdMetric?: TransactionThresholdMetric;
55-
loadingThreshold?: boolean;
5650
};
5751

5852
class TransactionHeader extends React.Component<Props> {
@@ -140,33 +134,8 @@ class TransactionHeader extends React.Component<Props> {
140134
);
141135
}
142136

143-
openModal() {
144-
const {
145-
organization,
146-
transactionName,
147-
eventView,
148-
transactionThreshold,
149-
transactionThresholdMetric,
150-
onChangeThreshold,
151-
} = this.props;
152-
openModal(
153-
modalProps => (
154-
<TransactionThresholdModal
155-
{...modalProps}
156-
organization={organization}
157-
transactionName={transactionName}
158-
eventView={eventView}
159-
transactionThreshold={transactionThreshold}
160-
transactionThresholdMetric={transactionThresholdMetric}
161-
onApply={onChangeThreshold}
162-
/>
163-
),
164-
{modalCss, backdrop: 'static'}
165-
);
166-
}
167-
168137
renderSettingsButton() {
169-
const {organization, loadingThreshold} = this.props;
138+
const {organization, transactionName, eventView, onChangeThreshold} = this.props;
170139

171140
return (
172141
<Feature
@@ -179,12 +148,11 @@ class TransactionHeader extends React.Component<Props> {
179148
target="project_transaction_threshold_override"
180149
position="bottom"
181150
>
182-
<Button
183-
onClick={() => this.openModal()}
184-
data-test-id="set-transaction-threshold"
185-
icon={<IconSettings />}
186-
disabled={loadingThreshold}
187-
aria-label={t('Settings')}
151+
<TransactionThresholdButton
152+
organization={organization}
153+
transactionName={transactionName}
154+
eventView={eventView}
155+
onChangeThreshold={onChangeThreshold}
188156
/>
189157
</GuideAnchor>
190158
) : (

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

Lines changed: 1 addition & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import styled from '@emotion/styled';
55
import {Location} from 'history';
66
import isEqual from 'lodash/isEqual';
77

8-
import {addErrorMessage} from 'app/actionCreators/indicator';
98
import {loadOrganizationTags} from 'app/actionCreators/tags';
109
import {Client} from 'app/api';
1110
import LightWeightNoProjectMessage from 'app/components/lightWeightNoProjectMessage';
@@ -14,7 +13,6 @@ import SentryDocumentTitle from 'app/components/sentryDocumentTitle';
1413
import {t} from 'app/locale';
1514
import {PageContent} from 'app/styles/organization';
1615
import {GlobalSelection, Organization, Project} from 'app/types';
17-
import {defined} from 'app/utils';
1816
import {trackAnalyticsEvent} from 'app/utils/analytics';
1917
import DiscoverQuery from 'app/utils/discover/discoverQuery';
2018
import EventView from 'app/utils/discover/eventView';
@@ -62,7 +60,6 @@ type State = {
6260
eventView: EventView | undefined;
6361
transactionThreshold: number | undefined;
6462
transactionThresholdMetric: TransactionThresholdMetric | undefined;
65-
loadingThreshold: boolean;
6663
};
6764

6865
// Used to cast the totals request to numbers
@@ -73,7 +70,6 @@ class TransactionSummary extends Component<Props, State> {
7370
state: State = {
7471
transactionThreshold: undefined,
7572
transactionThresholdMetric: undefined,
76-
loadingThreshold: false,
7773
spanOperationBreakdownFilter: decodeFilterFromLocation(this.props.location),
7874
eventView: generateSummaryEventView(
7975
this.props.location,
@@ -95,9 +91,6 @@ class TransactionSummary extends Component<Props, State> {
9591
componentDidMount() {
9692
const {api, organization, selection} = this.props;
9793
loadOrganizationTags(api, organization.slug, selection);
98-
if (organization.features.includes('project-transaction-threshold-override')) {
99-
this.fetchTransactionThreshold();
100-
}
10194
addRoutePerformanceContext(selection);
10295
}
10396

@@ -137,72 +130,6 @@ class TransactionSummary extends Component<Props, State> {
137130
});
138131
};
139132

140-
getProject() {
141-
const {projects} = this.props;
142-
const {eventView} = this.state;
143-
if (!defined(eventView)) {
144-
return undefined;
145-
}
146-
147-
const projectId = String(eventView.project[0]);
148-
const project = projects.find(proj => proj.id === projectId);
149-
150-
return project;
151-
}
152-
153-
fetchTransactionThreshold = () => {
154-
const {api, organization, location} = this.props;
155-
const transactionName = getTransactionName(location);
156-
157-
const project = this.getProject();
158-
if (!defined(project)) {
159-
return;
160-
}
161-
const transactionThresholdUrl = `/organizations/${organization.slug}/project-transaction-threshold-override/`;
162-
163-
this.setState({loadingThreshold: true});
164-
165-
api
166-
.requestPromise(transactionThresholdUrl, {
167-
method: 'GET',
168-
includeAllArgs: true,
169-
query: {
170-
project: project.id,
171-
transaction: transactionName,
172-
},
173-
})
174-
.then(([data]) => {
175-
this.setState({
176-
loadingThreshold: false,
177-
transactionThreshold: data.threshold,
178-
transactionThresholdMetric: data.metric,
179-
});
180-
})
181-
.catch(() => {
182-
const projectThresholdUrl = `/projects/${organization.slug}/${project.slug}/transaction-threshold/configure/`;
183-
this.props.api
184-
.requestPromise(projectThresholdUrl, {
185-
method: 'GET',
186-
includeAllArgs: true,
187-
query: {
188-
project: project.id,
189-
},
190-
})
191-
.then(([data]) => {
192-
this.setState({
193-
loadingThreshold: false,
194-
transactionThreshold: data.threshold,
195-
transactionThresholdMetric: data.metric,
196-
});
197-
})
198-
.catch(err => {
199-
this.setState({loadingThreshold: false});
200-
const errorMessage = err.responseJSON?.threshold ?? null;
201-
addErrorMessage(errorMessage);
202-
});
203-
});
204-
};
205-
206133
getDocumentTitle(): string {
207134
const name = getTransactionName(this.props.location);
208135

@@ -296,12 +223,7 @@ class TransactionSummary extends Component<Props, State> {
296223

297224
render() {
298225
const {organization, projects, location} = this.props;
299-
const {
300-
eventView,
301-
transactionThreshold,
302-
transactionThresholdMetric,
303-
loadingThreshold,
304-
} = this.state;
226+
const {eventView, transactionThreshold, transactionThresholdMetric} = this.state;
305227
const transactionName = getTransactionName(location);
306228
if (!eventView || transactionName === undefined) {
307229
// If there is no transaction name, redirect to the Performance landing page
@@ -371,9 +293,6 @@ class TransactionSummary extends Component<Props, State> {
371293
transactionThresholdMetric: metric,
372294
})
373295
}
374-
transactionThreshold={transactionThreshold}
375-
transactionThresholdMetric={transactionThresholdMetric}
376-
loadingThreshold={loadingThreshold}
377296
/>
378297
);
379298
}}

0 commit comments

Comments
 (0)