createTeamForm.tsx 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. import {Fragment} from 'react';
  2. import Form from 'sentry/components/forms/form';
  3. import TextField from 'sentry/components/forms/textField';
  4. import {t} from 'sentry/locale';
  5. import {Organization} from 'sentry/types';
  6. import slugify from 'sentry/utils/slugify';
  7. type Payload = {
  8. slug: string;
  9. };
  10. type Props = {
  11. organization: Organization;
  12. formProps?: Partial<typeof Form>;
  13. onSubmit?: (data: Payload, onSuccess: Function, onError: Function) => void;
  14. onSuccess?: (data: Payload) => void;
  15. };
  16. function CreateTeamForm({organization, formProps, ...props}: Props) {
  17. return (
  18. <Fragment>
  19. <p>
  20. {t(
  21. 'Members of a team have access to specific areas, such as a new release or a new application feature.'
  22. )}
  23. </p>
  24. <Form
  25. submitLabel={t('Create Team')}
  26. apiEndpoint={`/organizations/${organization.slug}/teams/`}
  27. apiMethod="POST"
  28. onSubmit={(data, onSuccess, onError) =>
  29. props.onSubmit?.(data as Payload, onSuccess, onError)
  30. }
  31. onSubmitSuccess={data => props.onSuccess?.(data)}
  32. requireChanges
  33. data-test-id="create-team-form"
  34. {...formProps}
  35. >
  36. <TextField
  37. name="slug"
  38. label={t('Team Name')}
  39. placeholder={t('e.g. operations, web-frontend, desktop')}
  40. help={t('May contain lowercase letters, numbers, dashes and underscores.')}
  41. required
  42. stacked
  43. flexibleControlStateSize
  44. inline={false}
  45. transformInput={slugify}
  46. />
  47. </Form>
  48. </Fragment>
  49. );
  50. }
  51. export default CreateTeamForm;