reportUri.tsx 1.4 KB

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