addTempestCredentialsForm.tsx 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. import {Fragment} from 'react';
  2. import TextField from 'sentry/components/forms/fields/textField';
  3. import Form from 'sentry/components/forms/form';
  4. import {t} from 'sentry/locale';
  5. import type {Organization} from 'sentry/types/organization';
  6. import type {Project} from 'sentry/types/project';
  7. type Payload = {
  8. clientId: string;
  9. clientSecret: string;
  10. };
  11. type Props = {
  12. organization: Organization;
  13. project: Project;
  14. formProps?: Partial<typeof Form>;
  15. onSuccess?: (data: Payload) => void;
  16. };
  17. export default function AddTempestCredentialsForm({
  18. organization,
  19. project,
  20. formProps,
  21. ...props
  22. }: Props) {
  23. return (
  24. <Fragment>
  25. <Form
  26. submitLabel={t('Add Credentials')}
  27. apiEndpoint={`/projects/${organization.slug}/${project.slug}/tempest-credentials/`}
  28. apiMethod="POST"
  29. onSubmitSuccess={data => props.onSuccess?.(data)}
  30. requireChanges
  31. data-test-id="add-tempest-credentials-form"
  32. {...formProps}
  33. >
  34. <TextField
  35. name="clientId"
  36. label={t('Client ID')}
  37. required
  38. stacked
  39. flexibleControlStateSize
  40. inline={false}
  41. />
  42. <TextField
  43. name="clientSecret"
  44. label={t('Client Secret')}
  45. required
  46. stacked
  47. flexibleControlStateSize
  48. inline={false}
  49. />
  50. </Form>
  51. </Fragment>
  52. );
  53. }