mutedBox.tsx 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. import {PureComponent} from 'react';
  2. import DateTime from 'app/components/dateTime';
  3. import Duration from 'app/components/duration';
  4. import {BannerContainer, BannerSummary} from 'app/components/events/styles';
  5. import {IconMute} from 'app/icons';
  6. import {t} from 'app/locale';
  7. import {ResolutionStatusDetails} from 'app/types';
  8. type Props = {
  9. statusDetails: ResolutionStatusDetails;
  10. };
  11. class MutedBox extends PureComponent<Props> {
  12. renderReason = () => {
  13. const {ignoreUntil, ignoreCount, ignoreWindow, ignoreUserCount, ignoreUserWindow} =
  14. this.props.statusDetails;
  15. if (ignoreUntil) {
  16. return t(
  17. 'This issue has been ignored until %s',
  18. <strong>
  19. <DateTime date={ignoreUntil} />
  20. </strong>
  21. );
  22. } else if (ignoreCount && ignoreWindow) {
  23. return t(
  24. 'This issue has been ignored until it occurs %s time(s) in %s',
  25. <strong>{ignoreCount.toLocaleString()}</strong>,
  26. <strong>
  27. <Duration seconds={ignoreWindow * 60} />
  28. </strong>
  29. );
  30. } else if (ignoreCount) {
  31. return t(
  32. 'This issue has been ignored until it occurs %s more time(s)',
  33. <strong>{ignoreCount.toLocaleString()}</strong>
  34. );
  35. } else if (ignoreUserCount && ignoreUserWindow) {
  36. return t(
  37. 'This issue has been ignored until it affects %s user(s) in %s',
  38. <strong>{ignoreUserCount.toLocaleString()}</strong>,
  39. <strong>
  40. <Duration seconds={ignoreUserWindow * 60} />
  41. </strong>
  42. );
  43. } else if (ignoreUserCount) {
  44. return t(
  45. 'This issue has been ignored until it affects %s more user(s)',
  46. <strong>{ignoreUserCount.toLocaleString()}</strong>
  47. );
  48. }
  49. return t('This issue has been ignored');
  50. };
  51. render = () => (
  52. <BannerContainer priority="default">
  53. <BannerSummary>
  54. <IconMute color="red300" size="sm" />
  55. <span>
  56. {this.renderReason()}&nbsp;&mdash;&nbsp;
  57. {t(
  58. 'You will not be notified of any changes and it will not show up by default in feeds.'
  59. )}
  60. </span>
  61. </BannerSummary>
  62. </BannerContainer>
  63. );
  64. }
  65. export default MutedBox;