editOnDemandButton.tsx 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import {openModal} from 'sentry/actionCreators/modal';
  2. import {Button} from 'sentry/components/button';
  3. import {IconEdit} from 'sentry/icons';
  4. import {t} from 'sentry/locale';
  5. import type {Organization} from 'sentry/types/organization';
  6. import type {Subscription} from 'getsentry/types';
  7. import OnDemandBudgetEditModal from 'getsentry/views/onDemandBudgets/onDemandBudgetEditModal';
  8. interface EditOnDemandButtonProps {
  9. organization: Organization;
  10. subscription: Subscription;
  11. }
  12. export function openOnDemandBudgetEditModal({
  13. organization,
  14. subscription,
  15. }: EditOnDemandButtonProps) {
  16. openModal(
  17. modalProps => (
  18. <OnDemandBudgetEditModal
  19. {...modalProps}
  20. subscription={subscription}
  21. organization={organization}
  22. />
  23. ),
  24. {
  25. closeEvents: 'escape-key',
  26. }
  27. );
  28. }
  29. export function EditOnDemandButton(props: EditOnDemandButtonProps) {
  30. return (
  31. <Button
  32. priority="primary"
  33. onClick={() => {
  34. openOnDemandBudgetEditModal(props);
  35. }}
  36. size="sm"
  37. icon={<IconEdit size="xs" />}
  38. >
  39. {t('Edit')}
  40. </Button>
  41. );
  42. }