footerWithButtons.tsx 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import styled from '@emotion/styled';
  2. import Button from 'sentry/components/actions/button';
  3. import {ButtonProps} from 'sentry/components/button';
  4. import space from 'sentry/styles/space';
  5. interface FooterWithButtonsProps
  6. extends Partial<Pick<ButtonProps, 'disabled' | 'onClick' | 'href'>> {
  7. buttonText: string;
  8. formFields?: Array<{name: string; value: any}>;
  9. formProps?: React.FormHTMLAttributes<HTMLFormElement>;
  10. }
  11. export default function FooterWithButtons({
  12. buttonText,
  13. formFields,
  14. formProps,
  15. ...rest
  16. }: FooterWithButtonsProps) {
  17. /**
  18. * We use a form post here to replicate what we do with standard HTML views for the integration pipeline.
  19. * Since this is a form post, we need to pass a hidden replica of the form inputs
  20. * so we can submit this form instead of the one collecting the user inputs.
  21. */
  22. return (
  23. <Footer data-test-id="aws-lambda-footer-form" {...formProps}>
  24. {formFields?.map(field => {
  25. return <input type="hidden" key={field.name} {...field} />;
  26. })}
  27. <Button priority="primary" type="submit" size="xs" {...rest}>
  28. {buttonText}
  29. </Button>
  30. </Footer>
  31. );
  32. }
  33. // wrap in form so we can keep form submission behavior
  34. const Footer = styled('form')`
  35. width: 100%;
  36. position: fixed;
  37. display: flex;
  38. justify-content: flex-end;
  39. bottom: 0;
  40. z-index: 100;
  41. background-color: ${p => p.theme.bodyBackground};
  42. border-top: 1px solid ${p => p.theme.innerBorder};
  43. padding: ${space(2)};
  44. `;