organizationCreate.tsx 2.3 KB

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