organizationCreate.tsx 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. import {ApiForm, BooleanField, TextField} from 'app/components/forms';
  2. import NarrowLayout from 'app/components/narrowLayout';
  3. import {t, tct} from 'app/locale';
  4. import ConfigStore from 'app/stores/configStore';
  5. import AsyncView from 'app/views/asyncView';
  6. export default class OrganizationCreate extends AsyncView {
  7. onSubmitSuccess = data => {
  8. // redirect to project creation *(BYPASS REACT ROUTER AND FORCE PAGE REFRESH TO GRAB CSRF TOKEN)*
  9. // browserHistory.pushState(null, `/organizations/${data.slug}/projects/new/`);
  10. window.location.href = `/organizations/${data.slug}/projects/new/`;
  11. };
  12. getEndpoints(): ReturnType<AsyncView['getEndpoints']> {
  13. return [];
  14. }
  15. getTitle() {
  16. return t('Create Organization');
  17. }
  18. renderBody() {
  19. const termsUrl = ConfigStore.get('termsUrl');
  20. const privacyUrl = ConfigStore.get('privacyUrl');
  21. return (
  22. <NarrowLayout showLogout>
  23. <h3>{t('Create a New Organization')}</h3>
  24. <p>
  25. {t(
  26. "Organizations represent the top level in your hierarchy. You'll be able to bundle a collection of teams within an organization as well as give organization-wide permissions to users."
  27. )}
  28. </p>
  29. <ApiForm
  30. initialData={{defaultTeam: true}}
  31. submitLabel={t('Create Organization')}
  32. apiEndpoint="/organizations/"
  33. apiMethod="POST"
  34. onSubmitSuccess={this.onSubmitSuccess}
  35. requireChanges
  36. >
  37. <TextField
  38. name="name"
  39. label={t('Organization Name')}
  40. placeholder={t('e.g. My Company')}
  41. required
  42. />
  43. {termsUrl && privacyUrl && (
  44. <BooleanField
  45. name="agreeTerms"
  46. label={tct(
  47. 'I agree to the [termsLink:Terms of Service] and the [privacyLink:Privacy Policy]',
  48. {
  49. termsLink: <a href={termsUrl} />,
  50. privacyLink: <a href={privacyUrl} />,
  51. }
  52. )}
  53. required
  54. />
  55. )}
  56. </ApiForm>
  57. </NarrowLayout>
  58. );
  59. }
  60. }