Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

TestStatusIcon.tsx 3.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /*
  2. * SonarQube
  3. * Copyright (C) 2009-2022 SonarSource SA
  4. * mailto:info AT sonarsource DOT com
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 3 of the License, or (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public License
  17. * along with this program; if not, write to the Free Software Foundation,
  18. * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  19. */
  20. import * as React from 'react';
  21. import { colors } from '../../app/theme';
  22. import { Dict } from '../../types/types';
  23. import Icon, { IconProps } from './Icon';
  24. interface Props extends IconProps {
  25. status: string;
  26. }
  27. const statusIcons: Dict<(props: IconProps) => React.ReactElement> = {
  28. ok: OkTestStatusIcon,
  29. failure: FailureTestStatusIcon,
  30. error: ErrorTestStatusIcon,
  31. skipped: SkippedTestStatusIcon
  32. };
  33. export default function TestStatusIcon({ status, ...iconProps }: Props) {
  34. const DesiredStatusIcon = statusIcons[status.toLowerCase()];
  35. return DesiredStatusIcon ? <DesiredStatusIcon {...iconProps} /> : null;
  36. }
  37. function OkTestStatusIcon(iconProps: IconProps) {
  38. return (
  39. <Icon {...iconProps}>
  40. <path
  41. d="M12.03 6.734a.49.49 0 0 0-.14-.36l-.71-.702a.48.48 0 0 0-.352-.15.474.474 0 0 0-.35.15l-3.19 3.18-1.765-1.766a.479.479 0 0 0-.35-.15.479.479 0 0 0-.353.15l-.71.703a.482.482 0 0 0-.14.358c0 .14.046.258.14.352l2.828 2.828c.098.1.216.15.35.15.142 0 .26-.05.36-.15l4.243-4.242a.475.475 0 0 0 .14-.352l-.001.001zM14 8c0 1.09-.268 2.092-.805 3.012a5.96 5.96 0 0 1-2.183 2.183A5.863 5.863 0 0 1 8 14a5.863 5.863 0 0 1-3.012-.805 5.96 5.96 0 0 1-2.183-2.183A5.863 5.863 0 0 1 2 8c0-1.09.268-2.092.805-3.012a5.96 5.96 0 0 1 2.183-2.183A5.863 5.863 0 0 1 8 2c1.09 0 2.092.268 3.012.805a5.96 5.96 0 0 1 2.183 2.183C13.732 5.908 14 6.91 14 8z"
  42. style={{ fill: colors.green }}
  43. />
  44. </Icon>
  45. );
  46. }
  47. function FailureTestStatusIcon(iconProps: IconProps) {
  48. return (
  49. <Icon {...iconProps}>
  50. <path
  51. d="M8 14c-3.311 0-6-2.689-6-6s2.689-6 6-6 6 2.689 6 6-2.689 6-6 6zM7 9h2V4H7v5zm0 3h2v-2H7v2z"
  52. style={{ fill: colors.orange, fillRule: 'nonzero' }}
  53. />
  54. </Icon>
  55. );
  56. }
  57. function ErrorTestStatusIcon(iconProps: IconProps) {
  58. return (
  59. <Icon {...iconProps}>
  60. <path
  61. d="M10.977 9.766a.497.497 0 0 0-.149-.352L9.414 8l1.414-1.414a.497.497 0 0 0 0-.711l-.703-.703a.497.497 0 0 0-.71 0L8 6.586 6.586 5.172a.497.497 0 0 0-.711 0l-.703.703a.497.497 0 0 0 0 .71L6.586 8 5.172 9.414a.497.497 0 0 0 0 .711l.703.703a.497.497 0 0 0 .71 0L8 9.414l1.414 1.414a.497.497 0 0 0 .711 0l.703-.703a.515.515 0 0 0 .149-.36zM14 8c0 3.313-2.688 6-6 6-3.313 0-6-2.688-6-6 0-3.313 2.688-6 6-6 3.313 0 6 2.688 6 6z"
  62. style={{ fill: colors.red, fillRule: 'nonzero' }}
  63. />
  64. </Icon>
  65. );
  66. }
  67. function SkippedTestStatusIcon(iconProps: IconProps) {
  68. return (
  69. <Icon {...iconProps}>
  70. <path
  71. d="M11.5 8.5v-1c0-.273-.227-.5-.5-.5H5c-.273 0-.5.227-.5.5v1c0 .273.227.5.5.5h6c.273 0 .5-.227.5-.5zM14 8c0 3.313-2.688 6-6 6-3.313 0-6-2.688-6-6 0-3.313 2.688-6 6-6 3.313 0 6 2.688 6 6z"
  72. style={{ fill: colors.gray71, fillRule: 'nonzero' }}
  73. />
  74. </Icon>
  75. );
  76. }