reportUri.tsx 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import FieldGroup from 'sentry/components/forms/fieldGroup';
  2. import Link from 'sentry/components/links/link';
  3. import Panel from 'sentry/components/panels/panel';
  4. import PanelAlert from 'sentry/components/panels/panelAlert';
  5. import PanelBody from 'sentry/components/panels/panelBody';
  6. import PanelHeader from 'sentry/components/panels/panelHeader';
  7. import TextCopyInput from 'sentry/components/textCopyInput';
  8. import {t, tct} from 'sentry/locale';
  9. import {ProjectKey} from 'sentry/types';
  10. import getDynamicText from 'sentry/utils/getDynamicText';
  11. const DEFAULT_ENDPOINT = 'https://sentry.example.com/api/security-report/';
  12. export function getSecurityDsn(keyList: ProjectKey[]) {
  13. const endpoint = keyList.length ? keyList[0].dsn.security : DEFAULT_ENDPOINT;
  14. return getDynamicText({
  15. value: endpoint,
  16. fixed: DEFAULT_ENDPOINT,
  17. });
  18. }
  19. type Props = {
  20. keyList: ProjectKey[];
  21. orgId: string;
  22. projectId: string;
  23. };
  24. export default function ReportUri({keyList, orgId, projectId}: Props) {
  25. return (
  26. <Panel>
  27. <PanelHeader>{t('Report URI')}</PanelHeader>
  28. <PanelBody>
  29. <PanelAlert type="info">
  30. {tct(
  31. "We've automatically pulled these credentials from your available [link:Client Keys]",
  32. {
  33. link: <Link to={`/settings/${orgId}/projects/${projectId}/keys/`} />,
  34. }
  35. )}
  36. </PanelAlert>
  37. <FieldGroup inline={false} flexibleControlStateSize>
  38. <TextCopyInput>{getSecurityDsn(keyList)}</TextCopyInput>
  39. </FieldGroup>
  40. </PanelBody>
  41. </Panel>
  42. );
  43. }