createProjectButton.tsx 934 B

123456789101112131415161718192021222324252627
  1. import {Button} from 'sentry/components/button';
  2. import {useProjectCreationAccess} from 'sentry/components/projects/useProjectCreationAccess';
  3. import {IconAdd} from 'sentry/icons';
  4. import {t} from 'sentry/locale';
  5. import useOrganization from 'sentry/utils/useOrganization';
  6. import {useTeams} from 'sentry/utils/useTeams';
  7. export default function CreateProjectButton() {
  8. const organization = useOrganization();
  9. const {teams, initiallyLoaded} = useTeams();
  10. const {canCreateProject} = useProjectCreationAccess({organization, teams});
  11. return (
  12. <Button
  13. priority="primary"
  14. size="sm"
  15. disabled={!initiallyLoaded || !canCreateProject}
  16. title={
  17. !canCreateProject ? t('You do not have permission to create projects') : undefined
  18. }
  19. to={`/organizations/${organization.slug}/projects/new/`}
  20. icon={<IconAdd size="xs" isCircled />}
  21. >
  22. {t('Create Project')}
  23. </Button>
  24. );
  25. }