Skip to content
Merged
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
29 changes: 29 additions & 0 deletions static/app/views/detectors/components/forms/uptime/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import styled from '@emotion/styled';

import {useFormField} from 'sentry/components/workflowEngine/form/useFormField';
import {t} from 'sentry/locale';
import type {UptimeDetector} from 'sentry/types/workflowEngine/detectors';
import {HTTPSnippet} from 'sentry/views/alerts/rules/uptime/httpSnippet';
import {AutomateSection} from 'sentry/views/detectors/components/forms/automateSection';
import {AssignSection} from 'sentry/views/detectors/components/forms/common/assignSection';
import {useSetAutomaticName} from 'sentry/views/detectors/components/forms/common/useSetAutomaticName';
Expand All @@ -15,6 +17,32 @@ import {
import {UptimeRegionWarning} from 'sentry/views/detectors/components/forms/uptime/regionWarning';
import {UptimeDetectorResolveSection} from 'sentry/views/detectors/components/forms/uptime/resolve';

const HTTP_METHODS_NO_BODY = ['GET', 'HEAD', 'OPTIONS'];

function ConnectedHttpSnippet() {
const url = useFormField<string>('url');
const method = useFormField<string>('method');
const headers = useFormField<Array<[string, string]>>('headers');
const body = useFormField<string>('body');
const traceSampling = useFormField<boolean>('traceSampling');

if (!url || !method) {
return null;
}

const shouldIncludeBody = !HTTP_METHODS_NO_BODY.includes(method);

return (
<HTTPSnippet
url={url}
method={method}
headers={headers ?? []}
body={shouldIncludeBody ? (body ?? null) : null}
traceSampling={traceSampling ?? false}
/>
);
}

function UptimeDetectorForm() {
useSetAutomaticName(form => {
const url = form.getValue('url');
Expand All @@ -38,6 +66,7 @@ function UptimeDetectorForm() {
<FormStack>
<UptimeRegionWarning />
<UptimeDetectorFormDetectSection />
<ConnectedHttpSnippet />
<UptimeDetectorResolveSection />
<AssignSection />
<AutomateSection />
Expand Down
Loading