organizationRegionAction.tsx 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import styled from '@emotion/styled';
  2. import FieldHelp from 'sentry/components/forms/fieldGroup/fieldHelp';
  3. import {t} from 'sentry/locale';
  4. import {space} from 'sentry/styles/space';
  5. import type {Organization} from 'sentry/types/organization';
  6. import {getRegionDataFromOrganization, getRegions} from 'sentry/utils/regions';
  7. import {DATA_STORAGE_DOCS_LINK} from 'sentry/views/organizationCreate';
  8. type Props = {
  9. organization?: Organization;
  10. };
  11. const OrganizationRegionInformationWrapper = styled('div')`
  12. margin-top: ${space(2)};
  13. text-align: end;
  14. `;
  15. const OrganizationFlag = styled('span')`
  16. font-size: ${p => p.theme.fontSizeLarge};
  17. `;
  18. export function OrganizationRegionAction({organization, ...props}: Props) {
  19. const regionCount = getRegions().length;
  20. if (!organization || regionCount <= 1) {
  21. return null;
  22. }
  23. const regionData = getRegionDataFromOrganization(organization);
  24. if (!regionData) {
  25. return null;
  26. }
  27. return (
  28. <OrganizationRegionInformationWrapper {...props}>
  29. <div>
  30. {`${regionData.displayName} `}
  31. <OrganizationFlag>{regionData.flag}</OrganizationFlag>
  32. </div>
  33. <FieldHelp>
  34. {t("Your organization's data storage location. ")}
  35. <a href={DATA_STORAGE_DOCS_LINK}>{t('Learn More')}</a>
  36. </FieldHelp>
  37. </OrganizationRegionInformationWrapper>
  38. );
  39. }