Skip to content

Commit 73418d5

Browse files
author
David Wang
authored
fix(crons): Pass environment to edit monitor page (#47435)
When saving the edit monitor page, we are redirected to the monitor details page with unfortunately no monitor environment in the URL. This causes us to query for no monitor environments from the backend and making the frontend believe that the monitor has not received any checkins. Hack in the environment through the URL to prevent this for now.
1 parent 725c696 commit 73418d5

File tree

3 files changed

+24
-3
lines changed

3 files changed

+24
-3
lines changed

static/app/views/monitors/components/monitorHeaderActions.tsx

+10-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import Confirm from 'sentry/components/confirm';
77
import {IconDelete, IconEdit, IconPause, IconPlay} from 'sentry/icons';
88
import {t} from 'sentry/locale';
99
import useApi from 'sentry/utils/useApi';
10+
import usePageFilters from 'sentry/utils/usePageFilters';
1011
import {normalizeUrl} from 'sentry/utils/withDomainRequired';
1112

1213
import {Monitor, MonitorStatus} from '../types';
@@ -21,6 +22,7 @@ type Props = {
2122

2223
function MonitorHeaderActions({monitor, orgId, onUpdate}: Props) {
2324
const api = useApi();
25+
const {selection} = usePageFilters();
2426

2527
const handleDelete = async () => {
2628
await deleteMonitor(api, orgId, monitor.slug);
@@ -64,7 +66,14 @@ function MonitorHeaderActions({monitor, orgId, onUpdate}: Props) {
6466
priority="primary"
6567
size="sm"
6668
icon={<IconEdit size="xs" />}
67-
to={`/organizations/${orgId}/crons/${monitor.slug}/edit/`}
69+
to={{
70+
pathname: `/organizations/${orgId}/crons/${monitor.slug}/edit/`,
71+
// TODO(davidenwang): Right now we have to pass the environment
72+
// through the URL so that when we save the monitor and are
73+
// redirected back to the details page it queries the backend
74+
// for a monitor environment with check-in data
75+
query: {environment: selection.environments},
76+
}}
6877
>
6978
{t('Edit')}
7079
</Button>

static/app/views/monitors/components/row.tsx

+8-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,14 @@ function MonitorRow({monitor, monitorEnv, organization, onDelete}: MonitorRowPro
102102
{
103103
key: 'edit',
104104
label: t('Edit'),
105-
to: normalizeUrl(`/organizations/${organization.slug}/crons/${monitor.slug}/edit/`),
105+
// TODO(davidenwang): Right now we have to pass the environment
106+
// through the URL so that when we save the monitor and are
107+
// redirected back to the details page it queries the backend
108+
// for a monitor environment with check-in data
109+
to: normalizeUrl({
110+
pathname: `/organizations/${organization.slug}/crons/${monitor.slug}/edit/`,
111+
query: {environment: monitorEnv?.name},
112+
}),
106113
},
107114
{
108115
key: 'delete',

static/app/views/monitors/edit.tsx

+6-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import SentryDocumentTitle from 'sentry/components/sentryDocumentTitle';
88
import {t} from 'sentry/locale';
99
import {setApiQueryData, useApiQuery, useQueryClient} from 'sentry/utils/queryClient';
1010
import useOrganization from 'sentry/utils/useOrganization';
11+
import usePageFilters from 'sentry/utils/usePageFilters';
1112
import {useParams} from 'sentry/utils/useParams';
1213
import {normalizeUrl} from 'sentry/utils/withDomainRequired';
1314

@@ -16,6 +17,7 @@ import {Monitor} from './types';
1617

1718
export default function EditMonitor() {
1819
const {monitorSlug} = useParams();
20+
const {selection} = usePageFilters();
1921
const organization = useOrganization();
2022
const queryClient = useQueryClient();
2123

@@ -33,7 +35,10 @@ export default function EditMonitor() {
3335
function onSubmitSuccess(data: Monitor) {
3436
setApiQueryData(queryClient, [queryKeyUrl], data);
3537
browserHistory.push(
36-
normalizeUrl(`/organizations/${organization.slug}/crons/${data.slug}/`)
38+
normalizeUrl({
39+
pathname: `/organizations/${organization.slug}/crons/${data.slug}/`,
40+
query: {environment: selection.environments},
41+
})
3742
);
3843
}
3944

0 commit comments

Comments
 (0)