footer.tsx 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. import styled from '@emotion/styled';
  2. import Button from 'sentry/components/button';
  3. import ButtonBar from 'sentry/components/buttonBar';
  4. import Confirm from 'sentry/components/confirm';
  5. import type {LinkProps} from 'sentry/components/links/link';
  6. import {t} from 'sentry/locale';
  7. import space from 'sentry/styles/space';
  8. interface Props {
  9. goBackLocation: LinkProps['to'];
  10. invalidForm: boolean;
  11. onSave: (event: React.MouseEvent) => void;
  12. isEditing?: boolean;
  13. onDelete?: () => void;
  14. }
  15. export function Footer({
  16. goBackLocation,
  17. onSave,
  18. onDelete,
  19. invalidForm,
  20. isEditing,
  21. }: Props) {
  22. return (
  23. <Wrapper>
  24. <Actions gap={1}>
  25. <Button to={goBackLocation}>{t('Cancel')}</Button>
  26. {isEditing && onDelete && (
  27. <Confirm
  28. priority="danger"
  29. message={t('Are you sure you want to delete this widget?')}
  30. onConfirm={onDelete}
  31. >
  32. <Button priority="danger">{t('Delete')}</Button>
  33. </Confirm>
  34. )}
  35. <Button
  36. priority="primary"
  37. onClick={onSave}
  38. disabled={invalidForm}
  39. title={invalidForm ? t('Required fields must be filled out') : undefined}
  40. >
  41. {isEditing ? t('Update Widget') : t('Add Widget')}
  42. </Button>
  43. </Actions>
  44. </Wrapper>
  45. );
  46. }
  47. const Actions = styled(ButtonBar)`
  48. justify-content: flex-end;
  49. max-width: 1000px;
  50. padding: ${space(4)} ${space(2)};
  51. /* to match Layout.Main padding + Field padding-right */
  52. padding-right: calc(${space(2)} + ${space(2)});
  53. @media (min-width: ${p => p.theme.breakpoints.medium}) {
  54. padding: ${space(4)};
  55. /* to match Layout.Main padding + Field padding-right */
  56. padding-right: calc(${space(4)} + ${space(2)});
  57. }
  58. `;
  59. const Wrapper = styled('div')`
  60. background: ${p => p.theme.background};
  61. border-top: 1px solid ${p => p.theme.gray200};
  62. `;