Skip to content

Commit

Permalink
Revert "ref(uptiem): Remove uptime-api-create-update flag in fe (#78150
Browse files Browse the repository at this point in the history
…)"

This reverts commit fa2be10.
  • Loading branch information
gaprl committed Sep 26, 2024
1 parent 729a0e9 commit 0486208
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
3 changes: 2 additions & 1 deletion static/app/views/alerts/create.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,8 @@ function Create(props: Props) {
<LoadingIndicator />
) : (
<Fragment>
{alertType === AlertRuleType.UPTIME ? (
{alertType === AlertRuleType.UPTIME &&
organization.features.includes('uptime-api-create-update') ? (
<UptimeAlertForm {...props} />
) : !hasMetricAlerts || alertType === AlertRuleType.ISSUE ? (
<IssueRuleEditor
Expand Down
17 changes: 13 additions & 4 deletions static/app/views/alerts/rules/uptime/uptimeAlertForm.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {ActorFixture} from 'sentry-fixture/actor';
import {MemberFixture} from 'sentry-fixture/member';
import {OrganizationFixture} from 'sentry-fixture/organization';
import {TeamFixture} from 'sentry-fixture/team';
import {UptimeRuleFixture} from 'sentry-fixture/uptimeRule';

Expand Down Expand Up @@ -27,7 +28,9 @@ describe('Uptime Alert Form', function () {
}

it('can create a new rule', async function () {
const {organization, project} = initializeOrg();
const {organization, project} = initializeOrg({
organization: OrganizationFixture({features: ['uptime-api-create-update']}),
});
OrganizationStore.onUpdate(organization);

render(<UptimeAlertForm organization={organization} project={project} />, {
Expand Down Expand Up @@ -77,7 +80,9 @@ describe('Uptime Alert Form', function () {
});

it('renders existing rule', async function () {
const {organization, project} = initializeOrg();
const {organization, project} = initializeOrg({
organization: OrganizationFixture({features: ['uptime-api-create-update']}),
});
OrganizationStore.onUpdate(organization);

const rule = UptimeRuleFixture({
Expand Down Expand Up @@ -110,7 +115,9 @@ describe('Uptime Alert Form', function () {
});

it('can edit an existing rule', async function () {
const {organization, project} = initializeOrg();
const {organization, project} = initializeOrg({
organization: OrganizationFixture({features: ['uptime-api-create-update']}),
});
OrganizationStore.onUpdate(organization);

const rule = UptimeRuleFixture({
Expand Down Expand Up @@ -173,7 +180,9 @@ describe('Uptime Alert Form', function () {
});

it('does not show body for GET and HEAD', async function () {
const {organization, project} = initializeOrg();
const {organization, project} = initializeOrg({
organization: OrganizationFixture({features: ['uptime-api-create-update']}),
});
OrganizationStore.onUpdate(organization);

const rule = UptimeRuleFixture({
Expand Down
7 changes: 6 additions & 1 deletion static/app/views/alerts/rules/uptime/uptimeAlertForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export function UptimeAlertForm({project, handleDelete, rule}: Props) {
const organization = useOrganization();
const {projects} = useProjects();

const enabledConfiguration = organization.features.includes('uptime-api-create-update');
const initialData = rule
? getFormDataFromRule(rule)
: {projectSlug: project.slug, method: 'GET', headers: []};
Expand Down Expand Up @@ -116,7 +117,7 @@ export function UptimeAlertForm({project, handleDelete, rule}: Props) {
<AlertListItem>{t('Select a project')}</AlertListItem>
<FormRow>
<SentryProjectSelectorField
disabled={rule !== undefined}
disabled={rule !== undefined || !enabledConfiguration}
disabledReason={t('Existing uptime rules cannot be moved between projects')}
name="projectSlug"
label={t('Project')}
Expand All @@ -133,6 +134,7 @@ export function UptimeAlertForm({project, handleDelete, rule}: Props) {
<AlertListItem>{t('Configure Request')}</AlertListItem>
<ConfigurationPanel>
<TextField
disabled={!enabledConfiguration}
name="url"
label={t('URL')}
placeholder={t('The URL to monitor')}
Expand All @@ -141,6 +143,7 @@ export function UptimeAlertForm({project, handleDelete, rule}: Props) {
required
/>
<SelectField
disabled={!enabledConfiguration}
name="method"
label={t('Method')}
placeholder={'GET'}
Expand All @@ -155,6 +158,7 @@ export function UptimeAlertForm({project, handleDelete, rule}: Props) {
name="headers"
label={t('Headers')}
flexibleControlStateSize
disabled={!enabledConfiguration}
/>
<TextareaField
name="body"
Expand All @@ -166,6 +170,7 @@ export function UptimeAlertForm({project, handleDelete, rule}: Props) {
monospace
placeholder='{"key": "value"}'
flexibleControlStateSize
disabled={!enabledConfiguration}
/>
</ConfigurationPanel>
<Observer>
Expand Down

0 comments on commit 0486208

Please sign in to comment.