editRulesModal.tsx 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. import {Fragment} from 'react';
  2. import styled from '@emotion/styled';
  3. import {EditOwnershipRulesModalOptions} from 'sentry/actionCreators/modal';
  4. import ExternalLink from 'sentry/components/links/externalLink';
  5. import {t, tct} from 'sentry/locale';
  6. import ConfigStore from 'sentry/stores/configStore';
  7. import {space} from 'sentry/styles/space';
  8. import TextBlock from 'sentry/views/settings/components/text/textBlock';
  9. import OwnerInput from 'sentry/views/settings/project/projectOwnership/ownerInput';
  10. interface EditOwnershipRulesModalProps extends EditOwnershipRulesModalOptions {
  11. onCancel: () => void;
  12. }
  13. export function EditOwnershipRules({ownership, ...props}: EditOwnershipRulesModalProps) {
  14. const hasStreamlineTargetingFeature = props.organization.features.includes(
  15. 'streamline-targeting-context'
  16. );
  17. const email = ConfigStore.get('user')?.email ?? '#team-slug';
  18. return (
  19. <Fragment>
  20. {hasStreamlineTargetingFeature ? (
  21. <Fragment>
  22. <Description>
  23. {tct(
  24. 'Assign issues based on custom rules. To learn more, [docs:read the docs].',
  25. {
  26. docs: (
  27. <ExternalLink href="https://docs.sentry.io/product/issues/issue-owners/" />
  28. ),
  29. }
  30. )}
  31. </Description>
  32. <StyledPre>
  33. # {t("Here's an example")}
  34. <br />
  35. path:src/views/checkout {email}
  36. <br />
  37. url:https://example.com/checkout {email}
  38. <br />
  39. tags.transaction:/checkout/:page {email}
  40. </StyledPre>
  41. </Fragment>
  42. ) : (
  43. <Fragment>
  44. <Block>
  45. {t('Globbing Syntax')}
  46. <CodeBlock>
  47. {'* matches everything\n? matches any single character'}
  48. </CodeBlock>
  49. </Block>
  50. <Block>
  51. {t('Examples')}
  52. <CodeBlock>
  53. path:src/example/pipeline/* person@sentry.io #infra
  54. {'\n'}
  55. module:com.module.name.example #sdks
  56. {'\n'}
  57. url:http://example.com/settings/* #product #infra
  58. {'\n'}
  59. tags.sku_class:enterprise #enterprise
  60. </CodeBlock>
  61. </Block>
  62. </Fragment>
  63. )}
  64. {ownership && (
  65. <OwnerInput
  66. {...props}
  67. dateUpdated={ownership.lastUpdated}
  68. initialText={ownership.raw || ''}
  69. page="project_settings"
  70. />
  71. )}
  72. </Fragment>
  73. );
  74. }
  75. const Block = styled(TextBlock)`
  76. margin-bottom: ${space(2)};
  77. `;
  78. const CodeBlock = styled('pre')`
  79. word-break: break-all;
  80. white-space: pre-wrap;
  81. `;
  82. const StyledPre = styled('pre')`
  83. word-break: break-word;
  84. padding: ${space(2)};
  85. line-height: 1.6;
  86. color: ${p => p.theme.subText};
  87. `;
  88. const Description = styled('p')`
  89. margin-bottom: ${space(1)};
  90. `;