import {browserHistory, RouteComponentProps} from 'react-router'; import Breadcrumbs from 'sentry/components/breadcrumbs'; import * as Layout from 'sentry/components/layouts/thirds'; import {t} from 'sentry/locale'; import {Organization} from 'sentry/types'; import {normalizeUrl} from 'sentry/utils/withDomainRequired'; import withOrganization from 'sentry/utils/withOrganization'; import AsyncView from 'sentry/views/asyncView'; import MonitorForm from './monitorForm'; import {Monitor} from './types'; type Props = AsyncView['props'] & RouteComponentProps<{monitorId: string}, {}> & { organization: Organization; }; type State = AsyncView['state'] & { monitor: Monitor | null; }; class EditMonitor extends AsyncView { get orgSlug() { return this.props.organization.slug; } getEndpoints(): ReturnType { const {params} = this.props; return [['monitor', `/organizations/${this.orgSlug}/monitors/${params.monitorId}/`]]; } onUpdate = (data: Monitor) => this.setState(state => ({monitor: {...state.monitor, ...data}})); onSubmitSuccess = (data: Monitor) => browserHistory.push(normalizeUrl(`/organizations/${this.orgSlug}/crons/${data.id}/`)); getTitle() { if (this.state.monitor) { return `${this.state.monitor.name} - Crons - ${this.orgSlug}`; } return `Crons - ${this.orgSlug}`; } renderBody() { const {monitor} = this.state; if (monitor === null) { return null; } return ( {t('Edit Monitor')} ); } } export default withOrganization(EditMonitor);