import {deleteMonitor, updateMonitor} from 'sentry/actionCreators/monitors'; import {Button} from 'sentry/components/button'; import ButtonBar from 'sentry/components/buttonBar'; import Confirm from 'sentry/components/confirm'; import FeedbackWidgetButton from 'sentry/components/feedback/widget/feedbackWidgetButton'; import {IconDelete, IconEdit, IconSubscribed, IconUnsubscribed} from 'sentry/icons'; import {t} from 'sentry/locale'; import {browserHistory} from 'sentry/utils/browserHistory'; import useApi from 'sentry/utils/useApi'; import usePageFilters from 'sentry/utils/usePageFilters'; import {normalizeUrl} from 'sentry/utils/withDomainRequired'; import type {Monitor} from '../types'; import {StatusToggleButton} from './statusToggleButton'; type Props = { monitor: Monitor; onUpdate: (data: Monitor) => void; orgSlug: string; }; function MonitorHeaderActions({monitor, orgSlug, onUpdate}: Props) { const api = useApi(); const {selection} = usePageFilters(); const endpointOptions = { query: { project: selection.projects, environment: selection.environments, }, }; const handleDelete = async () => { await deleteMonitor(api, orgSlug, monitor); browserHistory.push( normalizeUrl({ pathname: `/organizations/${orgSlug}/crons/`, query: endpointOptions.query, }) ); }; const handleUpdate = async (data: Partial) => { const resp = await updateMonitor(api, orgSlug, monitor, data); if (resp !== null) { onUpdate?.(resp); } }; return ( handleUpdate({status})} /> ); } export default MonitorHeaderActions;