utils.tsx 1018 B

12345678910111213141516171819202122232425262728293031323334353637
  1. import isObject from 'lodash/isObject';
  2. import {EventGroupComponent} from 'sentry/types';
  3. export function hasNonContributingComponent(component: EventGroupComponent | undefined) {
  4. if (!component?.contributes) {
  5. return true;
  6. }
  7. for (const value of component.values) {
  8. if (isObject(value) && hasNonContributingComponent(value)) {
  9. return true;
  10. }
  11. }
  12. return false;
  13. }
  14. export function shouldInlineComponentValue(component: EventGroupComponent) {
  15. return (component.values as EventGroupComponent[]).every(value => !isObject(value));
  16. }
  17. export function groupingComponentFilter(
  18. value: EventGroupComponent | string,
  19. showNonContributing: boolean
  20. ) {
  21. if (isObject(value)) {
  22. // no point rendering such nodes at all, we never show them
  23. if (!value.contributes && !value.hint && value.values.length === 0) {
  24. return false;
  25. }
  26. // non contributing values are otherwise optional
  27. if (!showNonContributing && !value.contributes) {
  28. return false;
  29. }
  30. }
  31. return true;
  32. }