organizationCreate.tsx 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. import {ApiForm, CheckboxField, TextField} from 'sentry/components/forms';
  2. import NarrowLayout from 'sentry/components/narrowLayout';
  3. import SentryDocumentTitle from 'sentry/components/sentryDocumentTitle';
  4. import {t, tct} from 'sentry/locale';
  5. import ConfigStore from 'sentry/stores/configStore';
  6. import {OrganizationSummary} from 'sentry/types';
  7. import {normalizeUrl} from 'sentry/utils/withDomainRequired';
  8. function OrganizationCreate() {
  9. const termsUrl = ConfigStore.get('termsUrl');
  10. const privacyUrl = ConfigStore.get('privacyUrl');
  11. return (
  12. <SentryDocumentTitle title={t('Create Organization')}>
  13. <NarrowLayout showLogout>
  14. <h3>{t('Create a New Organization')}</h3>
  15. <p>
  16. {t(
  17. "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."
  18. )}
  19. </p>
  20. <ApiForm
  21. initialData={{defaultTeam: true}}
  22. submitLabel={t('Create Organization')}
  23. apiEndpoint="/organizations/"
  24. apiMethod="POST"
  25. onSubmitSuccess={(createdOrg: OrganizationSummary) => {
  26. const hasCustomerDomain = createdOrg?.features.includes('customer-domains');
  27. let nextUrl = normalizeUrl(
  28. `/organizations/${createdOrg.slug}/projects/new/`,
  29. {forceCustomerDomain: hasCustomerDomain}
  30. );
  31. if (hasCustomerDomain) {
  32. nextUrl = `${createdOrg.links.organizationUrl}${nextUrl}`;
  33. }
  34. // redirect to project creation *(BYPASS REACT ROUTER AND FORCE PAGE REFRESH TO GRAB CSRF TOKEN)*
  35. // browserHistory.pushState(null, `/organizations/${data.slug}/projects/new/`);
  36. window.location.assign(nextUrl);
  37. }}
  38. requireChanges
  39. >
  40. <TextField
  41. id="organization-name"
  42. name="name"
  43. label={t('Organization Name')}
  44. placeholder={t('e.g. My Company')}
  45. inline={false}
  46. flexibleControlStateSize
  47. stacked
  48. required
  49. />
  50. {termsUrl && privacyUrl && (
  51. <CheckboxField
  52. name="agreeTerms"
  53. label={tct(
  54. 'I agree to the [termsLink:Terms of Service] and the [privacyLink:Privacy Policy]',
  55. {
  56. termsLink: <a href={termsUrl} />,
  57. privacyLink: <a href={privacyUrl} />,
  58. }
  59. )}
  60. inline={false}
  61. stacked
  62. required
  63. />
  64. )}
  65. </ApiForm>
  66. </NarrowLayout>
  67. </SentryDocumentTitle>
  68. );
  69. }
  70. export default OrganizationCreate;