organizationRepositories.tsx 3.1 KB

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