organizationCreate.tsx 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. import NarrowLayout from 'app/components/narrowLayout';
  2. import {t, tct} from 'app/locale';
  3. import ConfigStore from 'app/stores/configStore';
  4. import AsyncView from 'app/views/asyncView';
  5. import {ApiForm, CheckboxField, TextField} from 'app/views/settings/components/forms';
  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. inline={false}
  42. flexibleControlStateSize
  43. stacked
  44. required
  45. />
  46. {termsUrl && privacyUrl && (
  47. <CheckboxField
  48. name="agreeTerms"
  49. label={tct(
  50. 'I agree to the [termsLink:Terms of Service] and the [privacyLink:Privacy Policy]',
  51. {
  52. termsLink: <a href={termsUrl} />,
  53. privacyLink: <a href={privacyUrl} />,
  54. }
  55. )}
  56. inline={false}
  57. stacked
  58. required
  59. />
  60. )}
  61. </ApiForm>
  62. </NarrowLayout>
  63. );
  64. }
  65. }