organizationRepositories.tsx 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. import AlertLink from 'sentry/components/alertLink';
  2. import {Button} from 'sentry/components/button';
  3. import EmptyMessage from 'sentry/components/emptyMessage';
  4. import ExternalLink from 'sentry/components/links/externalLink';
  5. import {Panel, PanelBody, PanelHeader} from 'sentry/components/panels';
  6. import RepositoryRow from 'sentry/components/repositoryRow';
  7. import {IconCommit} from 'sentry/icons';
  8. import {t, tct} from 'sentry/locale';
  9. import {Organization, Repository, RepositoryStatus} from 'sentry/types';
  10. import useApi from 'sentry/utils/useApi';
  11. import SettingsPageHeader from 'sentry/views/settings/components/settingsPageHeader';
  12. import TextBlock from 'sentry/views/settings/components/text/textBlock';
  13. type Props = {
  14. itemList: Repository[];
  15. onRepositoryChange: (data: {id: string; status: RepositoryStatus}) => void;
  16. organization: Organization;
  17. };
  18. function OrganizationRepositories({itemList, onRepositoryChange, organization}: Props) {
  19. const api = useApi();
  20. const hasItemList = itemList && itemList.length > 0;
  21. return (
  22. <div>
  23. <SettingsPageHeader title={t('Repositories')} />
  24. <AlertLink to={`/settings/${organization.slug}/integrations/`}>
  25. {t(
  26. 'Want to add a repository to start tracking commits? Install or configure your version control integration here.'
  27. )}
  28. </AlertLink>
  29. {!hasItemList && (
  30. <div className="m-b-2">
  31. <TextBlock>
  32. {t(
  33. "Connecting a repository allows Sentry to capture commit data via webhooks. This enables features like suggested assignees and resolving issues via commit message. Once you've connected a repository, you can associate commits with releases via the API."
  34. )}
  35. &nbsp;
  36. {tct('See our [link:documentation] for more details.', {
  37. link: <ExternalLink href="https://docs.sentry.io/learn/releases/" />,
  38. })}
  39. </TextBlock>
  40. </div>
  41. )}
  42. {hasItemList ? (
  43. <Panel>
  44. <PanelHeader>{t('Added Repositories')}</PanelHeader>
  45. <PanelBody>
  46. <div>
  47. {itemList.map(repo => (
  48. <RepositoryRow
  49. api={api}
  50. key={repo.id}
  51. repository={repo}
  52. showProvider
  53. orgId={organization.slug}
  54. onRepositoryChange={onRepositoryChange}
  55. />
  56. ))}
  57. </div>
  58. </PanelBody>
  59. </Panel>
  60. ) : (
  61. <Panel>
  62. <EmptyMessage
  63. icon={<IconCommit size="xl" />}
  64. title={t('Sentry is better with commit data')}
  65. description={t(
  66. 'Adding one or more repositories will enable enhanced releases and the ability to resolve Sentry Issues via git message.'
  67. )}
  68. action={
  69. <Button external href="https://docs.sentry.io/learn/releases/">
  70. {t('Learn more')}
  71. </Button>
  72. }
  73. />
  74. </Panel>
  75. )}
  76. </div>
  77. );
  78. }
  79. export default OrganizationRepositories;