Skip to content

Commit 53dfa89

Browse files
evanpurkhiserpriscilawebdev
authored andcommitted
ref(uptime): Move ConnectedHttpSnippet into Detect panel (#102799)
Fixes: [NEW-585: HTTP check details should be embedded in the detect panel](https://linear.app/getsentry/issue/NEW-585/http-check-details-should-be-embedded-in-the-detect-panel)
1 parent 41ee8d0 commit 53dfa89

File tree

2 files changed

+27
-29
lines changed

2 files changed

+27
-29
lines changed

static/app/views/detectors/components/forms/uptime/detect/index.tsx

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,12 @@ import SelectField from 'sentry/components/forms/fields/selectField';
99
import TextareaField from 'sentry/components/forms/fields/textareaField';
1010
import TextField from 'sentry/components/forms/fields/textField';
1111
import type FormModel from 'sentry/components/forms/model';
12+
import {useFormField} from 'sentry/components/workflowEngine/form/useFormField';
1213
import {Container} from 'sentry/components/workflowEngine/ui/container';
1314
import Section from 'sentry/components/workflowEngine/ui/section';
1415
import {t, tct} from 'sentry/locale';
1516
import getDuration from 'sentry/utils/duration/getDuration';
17+
import {HTTPSnippet} from 'sentry/views/alerts/rules/uptime/httpSnippet';
1618
import {UptimeHeadersField} from 'sentry/views/detectors/components/forms/uptime/detect/uptimeHeadersField';
1719
import {UPTIME_DEFAULT_DOWNTIME_THRESHOLD} from 'sentry/views/detectors/components/forms/uptime/fields';
1820

@@ -32,6 +34,30 @@ function methodHasBody(model: FormModel) {
3234
return !HTTP_METHODS_NO_BODY.includes(model.getValue('method'));
3335
}
3436

37+
function ConnectedHttpSnippet() {
38+
const url = useFormField<string>('url');
39+
const method = useFormField<string>('method');
40+
const headers = useFormField<Array<[string, string]>>('headers');
41+
const body = useFormField<string>('body');
42+
const traceSampling = useFormField<boolean>('traceSampling');
43+
44+
if (!url || !method) {
45+
return null;
46+
}
47+
48+
const shouldIncludeBody = !HTTP_METHODS_NO_BODY.includes(method);
49+
50+
return (
51+
<HTTPSnippet
52+
url={url}
53+
method={method}
54+
headers={headers ?? []}
55+
body={shouldIncludeBody ? (body ?? null) : null}
56+
traceSampling={traceSampling ?? false}
57+
/>
58+
);
59+
}
60+
3561
export function UptimeDetectorFormDetectSection() {
3662
return (
3763
<Container>
@@ -152,6 +178,7 @@ export function UptimeDetectorFormDetectSection() {
152178
flexibleControlStateSize
153179
/>
154180
</ConfigurationFieldsContainer>
181+
<ConnectedHttpSnippet />
155182
</Section>
156183
</Container>
157184
);

static/app/views/detectors/components/forms/uptime/index.tsx

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
import styled from '@emotion/styled';
22

3-
import {useFormField} from 'sentry/components/workflowEngine/form/useFormField';
43
import {t} from 'sentry/locale';
54
import type {UptimeDetector} from 'sentry/types/workflowEngine/detectors';
6-
import {HTTPSnippet} from 'sentry/views/alerts/rules/uptime/httpSnippet';
75
import {AutomateSection} from 'sentry/views/detectors/components/forms/automateSection';
86
import {AssignSection} from 'sentry/views/detectors/components/forms/common/assignSection';
97
import {useSetAutomaticName} from 'sentry/views/detectors/components/forms/common/useSetAutomaticName';
@@ -17,32 +15,6 @@ import {
1715
import {UptimeRegionWarning} from 'sentry/views/detectors/components/forms/uptime/regionWarning';
1816
import {UptimeDetectorResolveSection} from 'sentry/views/detectors/components/forms/uptime/resolve';
1917

20-
const HTTP_METHODS_NO_BODY = ['GET', 'HEAD', 'OPTIONS'];
21-
22-
function ConnectedHttpSnippet() {
23-
const url = useFormField<string>('url');
24-
const method = useFormField<string>('method');
25-
const headers = useFormField<Array<[string, string]>>('headers');
26-
const body = useFormField<string>('body');
27-
const traceSampling = useFormField<boolean>('traceSampling');
28-
29-
if (!url || !method) {
30-
return null;
31-
}
32-
33-
const shouldIncludeBody = !HTTP_METHODS_NO_BODY.includes(method);
34-
35-
return (
36-
<HTTPSnippet
37-
url={url}
38-
method={method}
39-
headers={headers ?? []}
40-
body={shouldIncludeBody ? (body ?? null) : null}
41-
traceSampling={traceSampling ?? false}
42-
/>
43-
);
44-
}
45-
4618
function UptimeDetectorForm() {
4719
useSetAutomaticName(form => {
4820
const url = form.getValue('url');
@@ -66,7 +38,6 @@ function UptimeDetectorForm() {
6638
<FormStack>
6739
<UptimeRegionWarning />
6840
<UptimeDetectorFormDetectSection />
69-
<ConnectedHttpSnippet />
7041
<UptimeDetectorResolveSection />
7142
<AssignSection />
7243
<AutomateSection />

0 commit comments

Comments
 (0)